From: Arturo Borrero Gonzalez <aborrero@cica.es>
To: netfilter-devel@vger.kernel.org
Cc: pablo@netfilter.org
Subject: [nft PATCH] rule: fix printing of rule comments
Date: Thu, 08 Oct 2015 11:27:24 +0200 [thread overview]
Message-ID: <20151008092724.23737.63936.stgit@r2d2.cica.es> (raw)
From: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
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>
---
src/rule.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/rule.c b/src/rule.c
index 92b83f0..1bf0e03 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");
}
next reply other threads:[~2015-10-08 9:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-08 9:27 Arturo Borrero Gonzalez [this message]
2015-10-08 16:18 ` [nft PATCH] rule: fix printing of rule comments Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151008092724.23737.63936.stgit@r2d2.cica.es \
--to=aborrero@cica.es \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).