Netfilter-Devel Archive mirror
 help / color / mirror / Atom feed
* [nft PATCH] cache: Always set NFT_CACHE_TERSE for list cmd with --terse
@ 2024-02-08 13:08 Phil Sutter
  2024-02-13 11:04 ` Phil Sutter
  0 siblings, 1 reply; 2+ messages in thread
From: Phil Sutter @ 2024-02-08 13:08 UTC (permalink / raw
  To: Pablo Neira Ayuso; +Cc: netfilter-devel, anton.khazan

This fixes at least 'nft -t list table ...' and 'nft -t list set ...'.

Note how --terse handling for 'list sets/maps' remains in place since
setting NFT_CACHE_TERSE does not fully undo NFT_CACHE_SETELEM: setting
both enables fetching of anonymous sets which is pointless for that
command.

Reported-by: anton.khazan@gmail.com
Link: https://bugzilla.netfilter.org/show_bug.cgi?id=1735
Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 src/cache.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/cache.c b/src/cache.c
index 97f50ccaf6ba1..c000e32c497fb 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -234,8 +234,6 @@ static unsigned int evaluate_cache_list(struct nft_ctx *nft, struct cmd *cmd,
 		}
 		if (filter->list.table && filter->list.set)
 			flags |= NFT_CACHE_TABLE | NFT_CACHE_SET | NFT_CACHE_SETELEM;
-		else if (nft_output_terse(&nft->output))
-			flags |= NFT_CACHE_FULL | NFT_CACHE_TERSE;
 		else
 			flags |= NFT_CACHE_FULL;
 		break;
@@ -261,17 +259,15 @@ static unsigned int evaluate_cache_list(struct nft_ctx *nft, struct cmd *cmd,
 		flags |= NFT_CACHE_TABLE | NFT_CACHE_FLOWTABLE;
 		break;
 	case CMD_OBJ_RULESET:
-		if (nft_output_terse(&nft->output))
-			flags |= NFT_CACHE_FULL | NFT_CACHE_TERSE;
-		else
-			flags |= NFT_CACHE_FULL;
-		break;
 	default:
 		flags |= NFT_CACHE_FULL;
 		break;
 	}
 	flags |= NFT_CACHE_REFRESH;
 
+	if (nft_output_terse(&nft->output))
+		flags |= NFT_CACHE_TERSE;
+
 	return flags;
 }
 
-- 
2.43.0


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

* Re: [nft PATCH] cache: Always set NFT_CACHE_TERSE for list cmd with --terse
  2024-02-08 13:08 [nft PATCH] cache: Always set NFT_CACHE_TERSE for list cmd with --terse Phil Sutter
@ 2024-02-13 11:04 ` Phil Sutter
  0 siblings, 0 replies; 2+ messages in thread
From: Phil Sutter @ 2024-02-13 11:04 UTC (permalink / raw
  To: Pablo Neira Ayuso; +Cc: netfilter-devel, anton.khazan

On Thu, Feb 08, 2024 at 02:08:59PM +0100, Phil Sutter wrote:
> This fixes at least 'nft -t list table ...' and 'nft -t list set ...'.
> 
> Note how --terse handling for 'list sets/maps' remains in place since
> setting NFT_CACHE_TERSE does not fully undo NFT_CACHE_SETELEM: setting
> both enables fetching of anonymous sets which is pointless for that
> command.
> 
> Reported-by: anton.khazan@gmail.com
> Link: https://bugzilla.netfilter.org/show_bug.cgi?id=1735
> Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
> Signed-off-by: Phil Sutter <phil@nwl.cc>

Patch applied.

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

end of thread, other threads:[~2024-02-13 11:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-08 13:08 [nft PATCH] cache: Always set NFT_CACHE_TERSE for list cmd with --terse Phil Sutter
2024-02-13 11:04 ` Phil Sutter

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 read-only IMAP folder(s) and NNTP newsgroup(s).