netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nft] cache: include set elements in "nft set list"
@ 2023-06-18 16:39 Florian Westphal
  2023-06-19  7:59 ` Arturo Borrero Gonzalez
  2023-06-19  8:52 ` Pablo Neira Ayuso
  0 siblings, 2 replies; 5+ messages in thread
From: Florian Westphal @ 2023-06-18 16:39 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Florian Westphal

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>
---
 src/cache.c | 2 ++
 src/rule.c  | 3 +--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/cache.c b/src/cache.c
index 95adee7f8ac1..becfa57fc335 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 &&
diff --git a/src/rule.c b/src/rule.c
index 633a5a12486d..305322ea7cc3 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -1601,8 +1601,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");
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH nft] cache: include set elements in "nft set list"
  2023-06-18 16:39 [PATCH nft] cache: include set elements in "nft set list" Florian Westphal
@ 2023-06-19  7:59 ` Arturo Borrero Gonzalez
  2023-06-19  8:52   ` Pablo Neira Ayuso
  2023-06-19  8:52 ` Pablo Neira Ayuso
  1 sibling, 1 reply; 5+ messages in thread
From: Arturo Borrero Gonzalez @ 2023-06-19  7:59 UTC (permalink / raw)
  To: Florian Westphal, netfilter-devel

On 6/18/23 18:39, Florian Westphal wrote:
> 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.
> 

Hi,

Would you recommend the debian package backports this fix for 1.0.6/1.0.7 ?

let me know, regards

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH nft] cache: include set elements in "nft set list"
  2023-06-18 16:39 [PATCH nft] cache: include set elements in "nft set list" Florian Westphal
  2023-06-19  7:59 ` Arturo Borrero Gonzalez
@ 2023-06-19  8:52 ` Pablo Neira Ayuso
  2023-06-20  0:13   ` Florian Westphal
  1 sibling, 1 reply; 5+ messages in thread
From: Pablo Neira Ayuso @ 2023-06-19  8:52 UTC (permalink / raw)
  To: Florian Westphal; +Cc: netfilter-devel

On Sun, Jun 18, 2023 at 06:39:45PM +0200, Florian Westphal wrote:
> 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.

LGTM.

> 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>
> ---
>  src/cache.c | 2 ++
>  src/rule.c  | 3 +--
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/src/cache.c b/src/cache.c
> index 95adee7f8ac1..becfa57fc335 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 &&
> diff --git a/src/rule.c b/src/rule.c
> index 633a5a12486d..305322ea7cc3 100644
> --- a/src/rule.c
> +++ b/src/rule.c
> @@ -1601,8 +1601,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");
> -- 
> 2.41.0
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH nft] cache: include set elements in "nft set list"
  2023-06-19  7:59 ` Arturo Borrero Gonzalez
@ 2023-06-19  8:52   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 5+ messages in thread
From: Pablo Neira Ayuso @ 2023-06-19  8:52 UTC (permalink / raw)
  To: Arturo Borrero Gonzalez; +Cc: Florian Westphal, netfilter-devel

On Mon, Jun 19, 2023 at 09:59:03AM +0200, Arturo Borrero Gonzalez wrote:
> On 6/18/23 18:39, Florian Westphal wrote:
> > 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.
> > 
> 
> Hi,
> 
> Would you recommend the debian package backports this fix for 1.0.6/1.0.7 ?

fine with me.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH nft] cache: include set elements in "nft set list"
  2023-06-19  8:52 ` Pablo Neira Ayuso
@ 2023-06-20  0:13   ` Florian Westphal
  0 siblings, 0 replies; 5+ messages in thread
From: Florian Westphal @ 2023-06-20  0:13 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: Florian Westphal, netfilter-devel

Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> On Sun, Jun 18, 2023 at 06:39:45PM +0200, Florian Westphal wrote:
> > 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.

I pushed this patch to master, with a minor change (removal of no-longer
needed fmt struct).

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-06-20  0:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-18 16:39 [PATCH nft] cache: include set elements in "nft set list" Florian Westphal
2023-06-19  7:59 ` Arturo Borrero Gonzalez
2023-06-19  8:52   ` Pablo Neira Ayuso
2023-06-19  8:52 ` Pablo Neira Ayuso
2023-06-20  0:13   ` Florian Westphal

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).