From: Phil Sutter Date: Sat, 14 Feb 2026 14:02:04 +0000 (+0100) Subject: cache: Filter for table when listing sets or maps X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=b7225cda2a4388f38293fba281fc001dff70a16e;p=thirdparty%2Fnftables.git cache: Filter for table when listing sets or maps Respect an optionally specified table name to filter listed sets or maps to by populating the filter accordingly. Fixes: a1a6b0a5c3c4 ("cache: finer grain cache population for list commands") Signed-off-by: Phil Sutter Reviewed-by: Pablo Neira Ayuso Tested-by: Eric Garver --- diff --git a/src/cache.c b/src/cache.c index 13d4cb19..f86d0006 100644 --- a/src/cache.c +++ b/src/cache.c @@ -252,6 +252,7 @@ static unsigned int evaluate_cache_list(struct nft_ctx *nft, struct cmd *cmd, case CMD_OBJ_SETS: case CMD_OBJ_MAPS: filter->list.family = cmd->handle.family; + filter->list.table = cmd->handle.table.name; flags |= NFT_CACHE_TABLE | NFT_CACHE_SET; if (!nft_output_terse(&nft->output)) flags |= NFT_CACHE_SETELEM; diff --git a/tests/shell/testcases/listing/cache_filters b/tests/shell/testcases/listing/cache_filters index 37c8f845..7a89330d 100755 --- a/tests/shell/testcases/listing/cache_filters +++ b/tests/shell/testcases/listing/cache_filters @@ -22,6 +22,8 @@ table ip ip_t { chain ip_t_c2 { } } +table ip ip_t2 { +} EOF $NFT --debug=netlink list ruleset | \ @@ -38,6 +40,8 @@ $NFT --debug=netlink list sets | \ grep -q 'family 2 ip_t_s ip_t' || fail "broken list sets" $NFT --debug=netlink list sets ip6 | \ grep -q 'family 2 ip_t_s ip_t' && fail "broken list sets family filter" +$NFT --debug=netlink list sets ip ip_t2 | \ + grep -q 'family 2 ip_t_s ip_t' && fail "broken list sets table filter" $NFT --debug=netlink list flowtables | \ grep -q 'flow table ip_t ip_t_ft' || fail "broken list flowtables"