]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: shell: add regression test for catchall double-delete
authorFlorian Westphal <fw@strlen.de>
Sun, 18 Feb 2024 11:12:46 +0000 (12:12 +0100)
committerFlorian Westphal <fw@strlen.de>
Sun, 18 Feb 2024 12:48:52 +0000 (13:48 +0100)
Test case for:
 b1db244ffd04 ("netfilter: nf_tables: check if catch-all set element is active in next generation")

Reported-by: lonial con <kongln9170@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
tests/shell/testcases/maps/dumps/map_catchall_double_free_2.nft [new file with mode: 0644]
tests/shell/testcases/maps/map_catchall_double_free_2 [new file with mode: 0755]

diff --git a/tests/shell/testcases/maps/dumps/map_catchall_double_free_2.nft b/tests/shell/testcases/maps/dumps/map_catchall_double_free_2.nft
new file mode 100644 (file)
index 0000000..68958c4
--- /dev/null
@@ -0,0 +1,9 @@
+table ip test {
+       map testmap {
+               type ipv4_addr : verdict
+               elements = { * : jump testchain }
+       }
+
+       chain testchain {
+       }
+}
diff --git a/tests/shell/testcases/maps/map_catchall_double_free_2 b/tests/shell/testcases/maps/map_catchall_double_free_2
new file mode 100755 (executable)
index 0000000..5842fcb
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+# NFT_TEST_REQUIRES(NFT_TEST_HAVE_catchall_element)
+
+$NFT -f /dev/stdin <<EOF
+table ip test {
+       map testmap {
+               type ipv4_addr : verdict
+               elements = { * : jump testchain }
+       }
+
+       chain testchain { }
+}
+EOF
+
+# second attempt to delete the catchall element
+# musts trigger transaction abort
+$NFT -f /dev/stdin <<EOF
+delete element ip test testmap { * }
+delete element ip test testmap { * }
+EOF
+
+if [ $? -eq 1 ]; then
+       exit 0
+fi
+
+exit 1