diff options
author | Pablo M. Bermudo Garay <pablombg@gmail.com> | 2016-05-19 14:46:03 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-05-20 11:40:01 +0200 |
commit | 59c58dbea5764c6154fdd4ea72d36433e2389a62 (patch) | |
tree | 77376a9fa494b6e08a0ea990cc6988613da0687c /src/rule.c | |
parent | d4b86b6bfdf979a13c7cf4231bb4ec1d0c04d6a3 (diff) |
rule: add 'list flow tables' support
This commit adds a new command that lists flow tables:
# nft list flow tables [family]
Only the declaration is displayed. If no family is specified, all flow
tables of all families are listed.
Signed-off-by: Pablo M. Bermudo Garay <pablombg@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/rule.c')
-rw-r--r-- | src/rule.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -258,7 +258,13 @@ static void set_print_declaration(const struct set *set, const char *type; uint32_t flags; - type = set->flags & SET_F_MAP ? "map" : "set"; + if (set->flags & SET_F_MAP) + type = "map"; + else if (set->flags & SET_F_EVAL) + type = "flow table"; + else + type = "set"; + printf("%s%s", opts->tab, type); if (opts->family != NULL) @@ -1067,7 +1073,11 @@ static int do_list_sets(struct netlink_ctx *ctx, struct cmd *cmd) table->handle.table); list_for_each_entry(set, &table->sets, list) { - if (set->flags & SET_F_ANONYMOUS) + if (cmd->obj == CMD_OBJ_SETS && + set->flags & SET_F_ANONYMOUS) + continue; + if (cmd->obj == CMD_OBJ_FLOWTABLES && + !(set->flags & SET_F_EVAL)) continue; set_print_declaration(set, &opts); printf("%s}%s", opts.tab, opts.nl); @@ -1202,6 +1212,8 @@ static int do_command_list(struct netlink_ctx *ctx, struct cmd *cmd) return do_list_set(ctx, cmd, table); case CMD_OBJ_RULESET: return do_list_ruleset(ctx, cmd); + case CMD_OBJ_FLOWTABLES: + return do_list_sets(ctx, cmd); default: BUG("invalid command object type %u\n", cmd->obj); } |