]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
cache: incorrect flush flag for table/chain
authorLaura Garcia Liebana <nevola@gmail.com>
Wed, 31 Jul 2019 11:27:46 +0000 (13:27 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 31 Jul 2019 12:44:46 +0000 (14:44 +0200)
After the new cache system, nft raises a table error flushing a chain in
a transaction.

 # nft "flush chain ip nftlb filter-newfarm ; \
    add rule ip nftlb filter-newfarm update \
    @persist-newfarm {  ip saddr : ct mark } ; \
    flush chain ip nftlb nat-newfarm"
 Error: No such file or directory
 flush chain ip nftlb filter-newfarm ; add rule ip nftlb (...)
                                                   ^^^^^

This patch sets the cache flag properly to save this case.

Fixes: 01e5c6f0ed031 ("src: add cache level flags")
Signed-off-by: Laura Garcia Liebana <nevola@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/cache.c
tests/shell/testcases/cache/0005_cache_chain_flush [new file with mode: 0755]
tests/shell/testcases/cache/0006_cache_table_flush [new file with mode: 0755]

index 0d38034e853f78b49107e86834a4e9709fef3a0d..cffcbb623ced027e030ab49cc810966fcb971ed7 100644 (file)
@@ -75,7 +75,6 @@ static unsigned int evaluate_cache_flush(struct cmd *cmd, unsigned int flags)
                flags |= NFT_CACHE_FLUSHED;
                break;
        default:
-               flags = NFT_CACHE_EMPTY;
                break;
        }
 
diff --git a/tests/shell/testcases/cache/0005_cache_chain_flush b/tests/shell/testcases/cache/0005_cache_chain_flush
new file mode 100755 (executable)
index 0000000..7dfe5c1
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+set -e
+
+RULESET="add table ip x
+add chain x y
+add chain x z
+add map ip x mapping { type ipv4_addr : inet_service; flags dynamic,timeout; }
+add rule x y counter
+add rule x z counter"
+
+$NFT -f - <<< "$RULESET" 2>&1
+
+RULESET="flush chain x y; add rule x y update @mapping { ip saddr : tcp sport }; flush chain x z"
+
+$NFT "$RULESET" 2>&1
diff --git a/tests/shell/testcases/cache/0006_cache_table_flush b/tests/shell/testcases/cache/0006_cache_table_flush
new file mode 100755 (executable)
index 0000000..fa4da97
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+set -e
+
+RULESET="add table ip x
+add chain x y
+add chain x z
+add map ip x mapping { type ipv4_addr : inet_service; flags dynamic,timeout; }
+add rule x y counter
+add rule x z counter"
+
+$NFT -f - <<< "$RULESET" 2>&1
+
+RULESET="flush table x; add rule x y update @mapping { ip saddr : tcp sport }; flush chain x z"
+
+$NFT "$RULESET" 2>&1