]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: shell: add bit-shift tests.
authorJeremy Sowden <jeremy@azazel.net>
Mon, 3 Feb 2020 11:20:21 +0000 (11:20 +0000)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 7 Feb 2020 15:57:30 +0000 (16:57 +0100)
Add a couple of shell test-cases for setting the CT mark to a bitwise
expression derived from the packet mark and vice versa.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
tests/shell/testcases/chains/0040mark_shift_0 [new file with mode: 0755]
tests/shell/testcases/chains/0040mark_shift_1 [new file with mode: 0755]
tests/shell/testcases/chains/dumps/0040mark_shift_0.nft [new file with mode: 0644]
tests/shell/testcases/chains/dumps/0040mark_shift_1.nft [new file with mode: 0644]

diff --git a/tests/shell/testcases/chains/0040mark_shift_0 b/tests/shell/testcases/chains/0040mark_shift_0
new file mode 100755 (executable)
index 0000000..55447f0
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+set -e
+
+RULESET="
+  add table t
+  add chain t c { type filter hook output priority mangle; }
+  add rule t c oif lo ct mark set (meta mark | 0x10) << 8
+"
+
+$NFT --debug=eval -f - <<< "$RULESET"
diff --git a/tests/shell/testcases/chains/0040mark_shift_1 b/tests/shell/testcases/chains/0040mark_shift_1
new file mode 100755 (executable)
index 0000000..b609f5e
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+set -e
+
+RULESET="
+  add table t
+  add chain t c { type filter hook input priority mangle; }
+  add rule t c iif lo ct mark & 0xff 0x10 meta mark set ct mark >> 8
+"
+
+$NFT -f - <<< "$RULESET"
diff --git a/tests/shell/testcases/chains/dumps/0040mark_shift_0.nft b/tests/shell/testcases/chains/dumps/0040mark_shift_0.nft
new file mode 100644 (file)
index 0000000..52d59d2
--- /dev/null
@@ -0,0 +1,6 @@
+table ip t {
+       chain c {
+               type filter hook output priority mangle; policy accept;
+               oif "lo" ct mark set (meta mark | 0x00000010) << 8
+       }
+}
diff --git a/tests/shell/testcases/chains/dumps/0040mark_shift_1.nft b/tests/shell/testcases/chains/dumps/0040mark_shift_1.nft
new file mode 100644 (file)
index 0000000..56ec8dc
--- /dev/null
@@ -0,0 +1,6 @@
+table ip t {
+       chain c {
+               type filter hook input priority mangle; policy accept;
+               iif "lo" ct mark & 0x000000ff == 0x00000010 meta mark set ct mark >> 8
+       }
+}