rule: fix printing of rule comments
PATCH 1/1 rule: fix printing of rule comments
From: Arturo Borrero Gonzalez <[email protected]>
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
--- src/rule.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
src/rule.c +5 -4
@@ -383,6 +383,10 @@ void rule_print(const struct rule *rule) stmt->ops->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" ); }
Quoted 6 lines · Arturo Borrero Gonzalez
From: Arturo Borrero Gonzalez <[email protected]>
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)
Applied, thanks Arturo!