]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
cache: set on cache flags for nested notation
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 29 Sep 2021 08:55:19 +0000 (10:55 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 29 Sep 2021 16:59:44 +0000 (18:59 +0200)
Set on the cache flags for the nested notation too, this is fixing nft -f
with two files, one that contains the set declaration and another that
adds a rule that refers to such set.

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1474
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/cache.c
tests/shell/testcases/nft-f/0029split_file_0 [new file with mode: 0755]

index 42e6b65c6d9e23d33517faeac84f3feb7d428f9a..544f64a20396593e06d6ac9169a21d731cb746db 100644 (file)
 static unsigned int evaluate_cache_add(struct cmd *cmd, unsigned int flags)
 {
        switch (cmd->obj) {
+       case CMD_OBJ_TABLE:
+               if (!cmd->table)
+                       break;
+
+               flags |= NFT_CACHE_TABLE |
+                        NFT_CACHE_CHAIN |
+                        NFT_CACHE_SET |
+                        NFT_CACHE_OBJECT |
+                        NFT_CACHE_FLOWTABLE;
+               break;
        case CMD_OBJ_CHAIN:
        case CMD_OBJ_SET:
        case CMD_OBJ_COUNTER:
diff --git a/tests/shell/testcases/nft-f/0029split_file_0 b/tests/shell/testcases/nft-f/0029split_file_0
new file mode 100755 (executable)
index 0000000..0cc547a
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+set -e
+
+RULESET="table inet filter {
+       set whitelist_v4 {
+               type ipv4_addr;
+       }
+
+       chain prerouting {
+               type filter hook prerouting priority filter;
+       }
+}
+"
+
+$NFT -f - <<< "$RULESET"
+
+RULESET="table inet filter {
+       chain prerouting {
+               ip daddr @whitelist_v4
+       }
+}
+"
+
+$NFT -f - <<< "$RULESET"