]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
cache: Filter for table when listing sets or maps
authorPhil Sutter <phil@nwl.cc>
Sat, 14 Feb 2026 14:02:04 +0000 (15:02 +0100)
committerPhil Sutter <phil@nwl.cc>
Wed, 18 Mar 2026 16:21:34 +0000 (17:21 +0100)
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 <phil@nwl.cc>
Reviewed-by: Pablo Neira Ayuso <pablo@netfilter.org>
Tested-by: Eric Garver <eric@garver.life>
src/cache.c
tests/shell/testcases/listing/cache_filters

index 13d4cb19eb4f610609dcc4e8a1d6b96752810e36..f86d0006909297f3d5acdd23dc7030f3ff3e538d 100644 (file)
@@ -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;
index 37c8f845dd4c787575a09363a960a31457973aac..7a89330d2b6c0f227c63e4c9ff7b0fce83d915ab 100755 (executable)
@@ -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"