diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2015-09-30 17:17:12 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2015-10-12 20:34:22 +0200 |
commit | 8f297010fc9bd2fd110378538142e5082b438369 (patch) | |
tree | 98272b7109a52a8afb265b13c540cdc25382569f /src | |
parent | c9737a3ace1739ca447bf904c78434f4de0c2890 (diff) |
rule: `list sets' only displays declaration, not definition
# 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>
Acked-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/rule.c | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -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); @@ -986,6 +992,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; @@ -998,8 +1009,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"); } |