From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: kaber@trash.net, fw@strlen.de, arturo.borrero.glez@gmail.com
Subject: [PATCH nft 5/7] rule: `list sets' only displays declaration, not definition
Date: Thu, 8 Oct 2015 22:49:28 +0200 [thread overview]
Message-ID: <1444337370-8269-6-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1444337370-8269-1-git-send-email-pablo@netfilter.org>
# nft list sets
table ip nat {
set libssh {
type ipv4_addr
}
}
table inet filter {
set set0 {
type inet_service
flags constant
}
set set1 {
type inet_service
flags constant
}
set set2 {
type icmpv6_type
flags constant
}
}
So in case you want to inspect the definition, you have to use `list set'
and the specific set that you want to inspect:
# nft list set inet filter set0
table inet filter {
set set0 {
type inet_service
flags constant
elements = { 2200, ssh}
}
}
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/rule.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/rule.c b/src/rule.c
index 58bac76..08db38b 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -254,7 +254,8 @@ static const char *set_policy2str(uint32_t policy)
}
}
-static void do_set_print(const struct set *set, struct print_fmt_options *opts)
+static void set_print_declaration(const struct set *set,
+ struct print_fmt_options *opts)
{
const char *delim = "";
const char *type;
@@ -322,6 +323,11 @@ static void do_set_print(const struct set *set, struct print_fmt_options *opts)
time_print(set->gc_int / 1000);
printf("%s", opts->nl);
}
+}
+
+static void do_set_print(const struct set *set, struct print_fmt_options *opts)
+{
+ set_print_declaration(set, opts);
if (set->init != NULL && set->init->size > 0) {
printf("%s%selements = ", opts->tab, opts->tab);
@@ -985,6 +991,11 @@ static int do_list_table(struct netlink_ctx *ctx, struct cmd *cmd,
static int do_list_sets(struct netlink_ctx *ctx, struct cmd *cmd)
{
+ struct print_fmt_options opts = {
+ .tab = "\t",
+ .nl = "\n",
+ .stmt_separator = "\n",
+ };
struct table *table;
struct set *set;
@@ -997,8 +1008,10 @@ static int do_list_sets(struct netlink_ctx *ctx, struct cmd *cmd)
family2str(table->handle.family),
table->handle.table);
- list_for_each_entry(set, &table->sets, list)
- set_print(set);
+ list_for_each_entry(set, &table->sets, list) {
+ set_print_declaration(set, &opts);
+ printf("%s}%s", opts.tab, opts.nl);
+ }
printf("}\n");
}
--
2.1.4
next prev parent reply other threads:[~2015-10-08 20:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-08 20:49 [PATCH nft 0/7] listing command updates Pablo Neira Ayuso
2015-10-08 20:49 ` [PATCH nft 1/7] rule: display table when listing sets Pablo Neira Ayuso
2015-10-08 20:49 ` [PATCH nft 2/7] src: add `list chains' command Pablo Neira Ayuso
2015-10-08 20:49 ` [PATCH nft 3/7] rule: display table when listing one set Pablo Neira Ayuso
2015-10-08 20:49 ` [PATCH nft 4/7] evaluate: check if set exists before listing it Pablo Neira Ayuso
2015-10-08 20:49 ` Pablo Neira Ayuso [this message]
2015-10-08 20:49 ` [PATCH nft 6/7] rule: rework list chain Pablo Neira Ayuso
2015-10-08 20:49 ` [PATCH nft 7/7] parser_bison: show all sets via list sets with no family Pablo Neira Ayuso
2015-10-09 7:09 ` [PATCH nft 0/7] listing command updates Arturo Borrero Gonzalez
2015-10-12 18:33 ` 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=1444337370-8269-6-git-send-email-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=arturo.borrero.glez@gmail.com \
--cc=fw@strlen.de \
--cc=kaber@trash.net \
--cc=netfilter-devel@vger.kernel.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).