]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: shell: add test-cases for ct and packet mark payload expressions
authorJeremy Sowden <jeremy@azazel.net>
Fri, 17 Mar 2023 09:16:54 +0000 (10:16 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 28 Mar 2023 08:26:34 +0000 (10:26 +0200)
Add new test-cases to verify that defining a rule that sets the ct or
packet mark to a value derived from a payload works correctly.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
16 files changed:
tests/shell/testcases/bitwise/0040mark_binop_2 [new file with mode: 0755]
tests/shell/testcases/bitwise/0040mark_binop_3 [new file with mode: 0755]
tests/shell/testcases/bitwise/0040mark_binop_4 [new file with mode: 0755]
tests/shell/testcases/bitwise/0040mark_binop_5 [new file with mode: 0755]
tests/shell/testcases/bitwise/0040mark_binop_6 [new file with mode: 0755]
tests/shell/testcases/bitwise/0040mark_binop_7 [new file with mode: 0755]
tests/shell/testcases/bitwise/0040mark_binop_8 [new file with mode: 0755]
tests/shell/testcases/bitwise/0040mark_binop_9 [new file with mode: 0755]
tests/shell/testcases/bitwise/dumps/0040mark_binop_2.nft [new file with mode: 0644]
tests/shell/testcases/bitwise/dumps/0040mark_binop_3.nft [new file with mode: 0644]
tests/shell/testcases/bitwise/dumps/0040mark_binop_4.nft [new file with mode: 0644]
tests/shell/testcases/bitwise/dumps/0040mark_binop_5.nft [new file with mode: 0644]
tests/shell/testcases/bitwise/dumps/0040mark_binop_6.nft [new file with mode: 0644]
tests/shell/testcases/bitwise/dumps/0040mark_binop_7.nft [new file with mode: 0644]
tests/shell/testcases/bitwise/dumps/0040mark_binop_8.nft [new file with mode: 0644]
tests/shell/testcases/bitwise/dumps/0040mark_binop_9.nft [new file with mode: 0644]

diff --git a/tests/shell/testcases/bitwise/0040mark_binop_2 b/tests/shell/testcases/bitwise/0040mark_binop_2
new file mode 100755 (executable)
index 0000000..94ebe97
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+set -e
+
+RULESET="
+  add table t
+  add chain t c { type filter hook output priority filter; }
+  add rule t c ct mark set ip dscp lshift 2 or 0x10
+"
+
+$NFT -f - <<< "$RULESET"
diff --git a/tests/shell/testcases/bitwise/0040mark_binop_3 b/tests/shell/testcases/bitwise/0040mark_binop_3
new file mode 100755 (executable)
index 0000000..b491565
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+set -e
+
+RULESET="
+  add table t
+  add chain t c { type filter hook input priority filter; }
+  add rule t c meta mark set ip dscp lshift 2 or 0x10
+"
+
+$NFT -f - <<< "$RULESET"
diff --git a/tests/shell/testcases/bitwise/0040mark_binop_4 b/tests/shell/testcases/bitwise/0040mark_binop_4
new file mode 100755 (executable)
index 0000000..adc5f25
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+set -e
+
+RULESET="
+  add table t
+  add chain t c { type filter hook output priority filter; }
+  add rule t c ct mark set ip dscp lshift 26 or 0x10
+"
+
+$NFT -f - <<< "$RULESET"
diff --git a/tests/shell/testcases/bitwise/0040mark_binop_5 b/tests/shell/testcases/bitwise/0040mark_binop_5
new file mode 100755 (executable)
index 0000000..286b7b1
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+set -e
+
+RULESET="
+  add table t
+  add chain t c { type filter hook input priority filter; }
+  add rule t c meta mark set ip dscp lshift 26 or 0x10
+"
+
+$NFT -f - <<< "$RULESET"
diff --git a/tests/shell/testcases/bitwise/0040mark_binop_6 b/tests/shell/testcases/bitwise/0040mark_binop_6
new file mode 100755 (executable)
index 0000000..9ea8295
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+set -e
+
+RULESET="
+  add table ip6 t
+  add chain ip6 t c { type filter hook output priority filter; }
+  add rule ip6 t c ct mark set ip6 dscp lshift 2 or 0x10
+"
+
+$NFT -f - <<< "$RULESET"
diff --git a/tests/shell/testcases/bitwise/0040mark_binop_7 b/tests/shell/testcases/bitwise/0040mark_binop_7
new file mode 100755 (executable)
index 0000000..ff9cfb5
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+set -e
+
+RULESET="
+  add table ip6 t
+  add chain ip6 t c { type filter hook input priority filter; }
+  add rule ip6 t c meta mark set ip6 dscp lshift 2 or 0x10
+"
+
+$NFT -f - <<< "$RULESET"
diff --git a/tests/shell/testcases/bitwise/0040mark_binop_8 b/tests/shell/testcases/bitwise/0040mark_binop_8
new file mode 100755 (executable)
index 0000000..b348ee9
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+set -e
+
+RULESET="
+  add table ip6 t
+  add chain ip6 t c { type filter hook output priority filter; }
+  add rule ip6 t c ct mark set ip6 dscp lshift 26 or 0x10
+"
+
+$NFT -f - <<< "$RULESET"
diff --git a/tests/shell/testcases/bitwise/0040mark_binop_9 b/tests/shell/testcases/bitwise/0040mark_binop_9
new file mode 100755 (executable)
index 0000000..d19447d
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+set -e
+
+RULESET="
+  add table ip6 t
+  add chain ip6 t c { type filter hook input priority filter; }
+  add rule ip6 t c meta mark set ip6 dscp lshift 26 or 0x10
+"
+
+$NFT -f - <<< "$RULESET"
diff --git a/tests/shell/testcases/bitwise/dumps/0040mark_binop_2.nft b/tests/shell/testcases/bitwise/dumps/0040mark_binop_2.nft
new file mode 100644 (file)
index 0000000..2b9be36
--- /dev/null
@@ -0,0 +1,6 @@
+table ip t {
+       chain c {
+               type filter hook output priority filter; policy accept;
+               ct mark set ip dscp << 2 | 0x10
+       }
+}
diff --git a/tests/shell/testcases/bitwise/dumps/0040mark_binop_3.nft b/tests/shell/testcases/bitwise/dumps/0040mark_binop_3.nft
new file mode 100644 (file)
index 0000000..8206fec
--- /dev/null
@@ -0,0 +1,6 @@
+table ip t {
+       chain c {
+               type filter hook input priority filter; policy accept;
+               meta mark set ip dscp << 2 | 0x10
+       }
+}
diff --git a/tests/shell/testcases/bitwise/dumps/0040mark_binop_4.nft b/tests/shell/testcases/bitwise/dumps/0040mark_binop_4.nft
new file mode 100644 (file)
index 0000000..91d9f56
--- /dev/null
@@ -0,0 +1,6 @@
+table ip t {
+       chain c {
+               type filter hook output priority filter; policy accept;
+               ct mark set ip dscp << 26 | 0x10
+       }
+}
diff --git a/tests/shell/testcases/bitwise/dumps/0040mark_binop_5.nft b/tests/shell/testcases/bitwise/dumps/0040mark_binop_5.nft
new file mode 100644 (file)
index 0000000..f2b51eb
--- /dev/null
@@ -0,0 +1,6 @@
+table ip t {
+       chain c {
+               type filter hook input priority filter; policy accept;
+               meta mark set ip dscp << 26 | 0x10
+       }
+}
diff --git a/tests/shell/testcases/bitwise/dumps/0040mark_binop_6.nft b/tests/shell/testcases/bitwise/dumps/0040mark_binop_6.nft
new file mode 100644 (file)
index 0000000..cf7be90
--- /dev/null
@@ -0,0 +1,6 @@
+table ip6 t {
+       chain c {
+               type filter hook output priority filter; policy accept;
+               ct mark set ip6 dscp << 2 | 0x10
+       }
+}
diff --git a/tests/shell/testcases/bitwise/dumps/0040mark_binop_7.nft b/tests/shell/testcases/bitwise/dumps/0040mark_binop_7.nft
new file mode 100644 (file)
index 0000000..a9663e6
--- /dev/null
@@ -0,0 +1,6 @@
+table ip6 t {
+       chain c {
+               type filter hook input priority filter; policy accept;
+               meta mark set ip6 dscp << 2 | 0x10
+       }
+}
diff --git a/tests/shell/testcases/bitwise/dumps/0040mark_binop_8.nft b/tests/shell/testcases/bitwise/dumps/0040mark_binop_8.nft
new file mode 100644 (file)
index 0000000..04b866a
--- /dev/null
@@ -0,0 +1,6 @@
+table ip6 t {
+       chain c {
+               type filter hook output priority filter; policy accept;
+               ct mark set ip6 dscp << 26 | 0x10
+       }
+}
diff --git a/tests/shell/testcases/bitwise/dumps/0040mark_binop_9.nft b/tests/shell/testcases/bitwise/dumps/0040mark_binop_9.nft
new file mode 100644 (file)
index 0000000..d4745ea
--- /dev/null
@@ -0,0 +1,6 @@
+table ip6 t {
+       chain c {
+               type filter hook input priority filter; policy accept;
+               meta mark set ip6 dscp << 26 | 0x10
+       }
+}