]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: shell: cover rule insertion by index
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 23 Feb 2023 19:36:43 +0000 (20:36 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 23 Feb 2023 21:59:44 +0000 (22:59 +0100)
Original patch including this feature did not include a test, add it.

Fixes: 816d8c7659c1 ("Support 'add/insert rule index <IDX>'")
Reported-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
tests/shell/testcases/cache/0011_index_0 [new file with mode: 0755]
tests/shell/testcases/cache/dumps/0011_index_0.nft [new file with mode: 0644]

diff --git a/tests/shell/testcases/cache/0011_index_0 b/tests/shell/testcases/cache/0011_index_0
new file mode 100755 (executable)
index 0000000..c9eb868
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+set -e
+
+RULESET="flush ruleset
+add table inet t
+add chain inet t c { type filter hook input priority 0 ; }
+add rule inet t c tcp dport 1234 accept
+add rule inet t c accept
+insert rule inet t c index 1 udp dport 4321 accept"
+
+$NFT -f - <<< "$RULESET"
diff --git a/tests/shell/testcases/cache/dumps/0011_index_0.nft b/tests/shell/testcases/cache/dumps/0011_index_0.nft
new file mode 100644 (file)
index 0000000..7e855eb
--- /dev/null
@@ -0,0 +1,8 @@
+table inet t {
+       chain c {
+               type filter hook input priority filter; policy accept;
+               tcp dport 1234 accept
+               udp dport 4321 accept
+               accept
+       }
+}