summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>2015-10-08 11:27:24 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2015-10-08 18:16:44 +0200
commit366a8853076d891f5079d651465a8c9d160bc027 (patch)
tree7f3b8b1b30fce172a00701b53a3958e7c8663935 /src
parente6c83f45f522283c7afff4de7a71113116352dbf (diff)
rule: fix printing of rule comments
Several fixes: * handles are printed last * simplify space games (an extra space was being printed) * comments are shown with `nft monitor' as well (missing before this patch) Before this patch: % nft list ruleset -a [...] chain test { iifname eth0 # handle 1 comment "test" } [...] % nft list ruleset [...] chain test { iifname eth0 comment "test" ^^ } [...] % nft monitor & % nft add rule test test iifname eth0 comment "test" add rule test test iifname eth0 After this patch: % nft list ruleset -a chain test { iifname eth0 comment "test" # handle 1 ^ } % nft monitor -a & % nft add rule test test iifname eth0 comment "test" add rule test test iifname eth0 comment "test" # handle 1 Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r--src/rule.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/rule.c b/src/rule.c
index 92b83f08..1bf0e03e 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -383,6 +383,10 @@ void rule_print(const struct rule *rule)
stmt->ops->print(stmt);
printf(" ");
}
+
+ if (rule->handle.comment)
+ printf("comment \"%s\" ", rule->handle.comment);
+
if (handle_output > 0)
printf("# handle %" PRIu64, rule->handle.handle);
}
@@ -622,10 +626,7 @@ static void chain_print(const struct chain *chain)
list_for_each_entry(rule, &chain->rules, list) {
printf("\t\t");
rule_print(rule);
- if (rule->handle.comment)
- printf(" comment \"%s\"\n", rule->handle.comment);
- else
- printf("\n");
+ printf("\n");
}
printf("\t}\n");
}