diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2015-09-30 17:25:43 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2015-10-12 20:34:22 +0200 |
commit | 46950a9f7366a686787306b749f95e16432951b6 (patch) | |
tree | 76c1648e427a930f2e43061d438b09e6e2c8c797 /src | |
parent | 8f297010fc9bd2fd110378538142e5082b438369 (diff) |
rule: rework list chain
After this patch:
# nft list chain inet filter forward
table inet filter {
chain forward {
type filter hook forward priority 0; policy drop;
ct state established,related counter packets 39546074 bytes 11566126287 accept
}
}
Before this patch, this was showing the full table definition, including
all chains, which is not what the user is asking for.
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 | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -1063,6 +1063,26 @@ static void table_print_declaration(struct table *table) table->handle.table); } +static int do_list_chain(struct netlink_ctx *ctx, struct cmd *cmd, + struct table *table) +{ + struct chain *chain; + + table_print_declaration(table); + + list_for_each_entry(chain, &table->chains, list) { + if (chain->handle.family != cmd->handle.family || + strcmp(cmd->handle.chain, chain->handle.chain) != 0) + continue; + + chain_print(chain); + } + + printf("}\n"); + + return 0; +} + static int do_list_chains(struct netlink_ctx *ctx, struct cmd *cmd) { struct table *table; @@ -1114,7 +1134,7 @@ static int do_command_list(struct netlink_ctx *ctx, struct cmd *cmd) return do_list_tables(ctx, cmd); return do_list_table(ctx, cmd, table); case CMD_OBJ_CHAIN: - return do_list_table(ctx, cmd, table); + return do_list_chain(ctx, cmd, table); case CMD_OBJ_CHAINS: return do_list_chains(ctx, cmd); case CMD_OBJ_SETS: |