diff options
author | Florian Westphal <fw@strlen.de> | 2023-06-18 18:39:45 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2023-11-02 11:56:20 +0100 |
commit | 7d61fc96421109228eec6fd2dda04dd50d8af7a4 (patch) | |
tree | 59634c6bf117553d3ef8545ff3fe3b6db2b50210 /src | |
parent | a566d41a3b2eab1ade5daaff13ba6fda339055e2 (diff) |
cache: include set elements in "nft set list"
commit 29bed4fa594c3f6e343a8b5669d61e20c7129cca upstream.
Make "nft list sets" include set elements in listing by default.
In nftables 1.0.0, "nft list sets" did not include the set elements,
but with "--json" they were included.
1.0.1 and newer never include them.
This causes a problem for people updating from 1.0.0 and relying
on the presence of the set elements.
Change nftables to always include the set elements.
The "--terse" option is honored to get the "no elements" behaviour.
Fixes: a1a6b0a5c3c4 ("cache: finer grain cache population for list commands")
Link: https://marc.info/?l=netfilter&m=168704941828372&w=2
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/cache.c | 2 | ||||
-rw-r--r-- | src/rule.c | 8 |
2 files changed, 3 insertions, 7 deletions
diff --git a/src/cache.c b/src/cache.c index 85de970f..8ffce60c 100644 --- a/src/cache.c +++ b/src/cache.c @@ -235,6 +235,8 @@ static unsigned int evaluate_cache_list(struct nft_ctx *nft, struct cmd *cmd, case CMD_OBJ_SETS: case CMD_OBJ_MAPS: flags |= NFT_CACHE_TABLE | NFT_CACHE_SET; + if (!nft_output_terse(&nft->output)) + flags |= NFT_CACHE_SETELEM; break; case CMD_OBJ_FLOWTABLE: if (filter && @@ -1768,11 +1768,6 @@ 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; @@ -1795,8 +1790,7 @@ static int do_list_sets(struct netlink_ctx *ctx, struct cmd *cmd) if (cmd->obj == CMD_OBJ_MAPS && !map_is_literal(set->flags)) continue; - set_print_declaration(set, &opts, &ctx->nft->output); - nft_print(&ctx->nft->output, "%s}%s", opts.tab, opts.nl); + set_print(set, &ctx->nft->output); } nft_print(&ctx->nft->output, "}\n"); |