summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/py/any/ct.t3
-rw-r--r--tests/py/any/ct.t.json60
-rw-r--r--tests/py/any/ct.t.payload15
-rw-r--r--tests/py/inet/meta.t2
-rw-r--r--tests/py/inet/meta.t.json37
-rw-r--r--tests/py/inet/meta.t.payload9
-rw-r--r--tests/py/ip/ct.t2
-rw-r--r--tests/py/ip/ct.t.json32
-rw-r--r--tests/py/ip/ct.t.payload11
-rw-r--r--tests/py/ip6/ct.t1
-rw-r--r--tests/py/ip6/ct.t.json32
-rw-r--r--tests/py/ip6/ct.t.payload12
-rw-r--r--tests/shell/features/bitwise_multireg.nft5
-rwxr-xr-xtests/shell/testcases/bitwise/0040mark_binop_1013
-rwxr-xr-xtests/shell/testcases/bitwise/0040mark_binop_1113
-rwxr-xr-xtests/shell/testcases/bitwise/0040mark_binop_1213
-rwxr-xr-xtests/shell/testcases/bitwise/0040mark_binop_1313
-rwxr-xr-xtests/shell/testcases/bitwise/0044payload_binop_213
-rwxr-xr-xtests/shell/testcases/bitwise/0044payload_binop_513
-rw-r--r--tests/shell/testcases/bitwise/dumps/0040mark_binop_10.nft6
-rw-r--r--tests/shell/testcases/bitwise/dumps/0040mark_binop_11.nft6
-rw-r--r--tests/shell/testcases/bitwise/dumps/0040mark_binop_12.nft6
-rw-r--r--tests/shell/testcases/bitwise/dumps/0040mark_binop_13.nft6
-rw-r--r--tests/shell/testcases/bitwise/dumps/0044payload_binop_2.nft6
-rw-r--r--tests/shell/testcases/bitwise/dumps/0044payload_binop_5.nft6
25 files changed, 335 insertions, 0 deletions
diff --git a/tests/py/any/ct.t b/tests/py/any/ct.t
index f73fa4e7..0059e49c 100644
--- a/tests/py/any/ct.t
+++ b/tests/py/any/ct.t
@@ -40,7 +40,9 @@ ct mark and 0x23 == 0x11;ok;ct mark & 0x00000023 == 0x00000011
ct mark and 0x3 != 0x1;ok;ct mark & 0x00000003 != 0x00000001
ct mark xor 0x23 == 0x11;ok;ct mark 0x00000032
ct mark xor 0x3 != 0x1;ok;ct mark != 0x00000002
+
ct mark set ct mark or 0x00000001;ok;ct mark set ct mark | 0x00000001
+ct mark set 0x00000001 or ct mark;ok;ct mark set ct mark | 0x00000001
ct mark 0x00000032;ok
ct mark != 0x00000032;ok
@@ -61,6 +63,7 @@ ct mark set 0x11;ok;ct mark set 0x00000011
ct mark set mark;ok;ct mark set meta mark
ct mark set (meta mark | 0x10) << 8;ok;ct mark set (meta mark | 0x00000010) << 8
ct mark set mark map { 1 : 10, 2 : 20, 3 : 30 };ok;ct mark set meta mark map { 0x00000003 : 0x0000001e, 0x00000002 : 0x00000014, 0x00000001 : 0x0000000a}
+ct mark set ct mark and 0xffff0000 or meta mark and 0xffff;ok;ct mark set ct mark & 0xffff0000 | meta mark & 0x0000ffff
ct mark set {0x11333, 0x11};fail
ct zone set {123, 127};fail
diff --git a/tests/py/any/ct.t.json b/tests/py/any/ct.t.json
index a2a06025..ef350000 100644
--- a/tests/py/any/ct.t.json
+++ b/tests/py/any/ct.t.json
@@ -560,6 +560,29 @@
}
]
+# ct mark set 0x00000001 or ct mark
+[
+ {
+ "mangle": {
+ "key": {
+ "ct": {
+ "key": "mark"
+ }
+ },
+ "value": {
+ "|": [
+ {
+ "ct": {
+ "key": "mark"
+ }
+ },
+ 1
+ ]
+ }
+ }
+ }
+]
+
# ct mark 0x00000032
[
{
@@ -817,6 +840,43 @@
}
]
+# ct mark set ct mark and 0xffff0000 or meta mark and 0xffff
+[
+ {
+ "mangle": {
+ "key": {
+ "ct": {
+ "key": "mark"
+ }
+ },
+ "value": {
+ "|": [
+ {
+ "&": [
+ {
+ "ct": {
+ "key": "mark"
+ }
+ },
+ 4294901760
+ ]
+ },
+ {
+ "&": [
+ {
+ "meta": {
+ "key": "mark"
+ }
+ },
+ 65535
+ ]
+ }
+ ]
+ }
+ }
+ }
+]
+
# ct expiration 30s
[
{
diff --git a/tests/py/any/ct.t.payload b/tests/py/any/ct.t.payload
index ed868e53..14385cf7 100644
--- a/tests/py/any/ct.t.payload
+++ b/tests/py/any/ct.t.payload
@@ -336,6 +336,15 @@ ip test-ip4 output
[ lookup reg 1 set __map%d dreg 1 ]
[ ct set mark with reg 1 ]
+# ct mark set ct mark and 0xffff0000 or meta mark and 0xffff
+ip
+ [ ct load mark => reg 1 ]
+ [ bitwise reg 1 = ( reg 1 & 0xffff0000 ) ^ 0x00000000 ]
+ [ meta load mark => reg 2 ]
+ [ bitwise reg 2 = ( reg 2 & 0x0000ffff ) ^ 0x00000000 ]
+ [ bitwise reg 1 = ( reg 1 | reg 2 ) ]
+ [ ct set mark with reg 1 ]
+
# ct original bytes > 100000
ip test-ip4 output
[ ct load bytes => reg 1 , dir original ]
@@ -497,6 +506,12 @@ ip test-ip4 output
[ bitwise reg 1 = ( reg 1 & 0xfffffffe ) ^ 0x00000001 ]
[ ct set mark with reg 1 ]
+# ct mark set 0x00000001 or ct mark
+ip test-ip4 output
+ [ ct load mark => reg 1 ]
+ [ bitwise reg 1 = ( reg 1 & 0xfffffffe ) ^ 0x00000001 ]
+ [ ct set mark with reg 1 ]
+
# ct id 12345
ip test-ip4 output
[ ct load unknown => reg 1 ]
diff --git a/tests/py/inet/meta.t b/tests/py/inet/meta.t
index 7d2515c9..5c5c11d4 100644
--- a/tests/py/inet/meta.t
+++ b/tests/py/inet/meta.t
@@ -31,3 +31,5 @@ meta mark set ip dscp;ok
meta mark set ip dscp | 0x40;ok
meta mark set ip6 dscp;ok
meta mark set ip6 dscp | 0x40;ok
+
+meta mark set ct mark and 0xffff0000 or meta mark and 0xffff;ok;meta mark set ct mark & 0xffff0000 | meta mark & 0x0000ffff
diff --git a/tests/py/inet/meta.t.json b/tests/py/inet/meta.t.json
index 0fee165f..4352b963 100644
--- a/tests/py/inet/meta.t.json
+++ b/tests/py/inet/meta.t.json
@@ -236,6 +236,43 @@
}
]
+# meta mark set ct mark and 0xffff0000 or meta mark and 0xffff
+[
+ {
+ "mangle": {
+ "key": {
+ "meta": {
+ "key": "mark"
+ }
+ },
+ "value": {
+ "|": [
+ {
+ "&": [
+ {
+ "ct": {
+ "key": "mark"
+ }
+ },
+ 4294901760
+ ]
+ },
+ {
+ "&": [
+ {
+ "meta": {
+ "key": "mark"
+ }
+ },
+ 65535
+ ]
+ }
+ ]
+ }
+ }
+ }
+]
+
# meta protocol ip udp dport 67
[
{
diff --git a/tests/py/inet/meta.t.payload b/tests/py/inet/meta.t.payload
index 7184fa0c..04dfbd8f 100644
--- a/tests/py/inet/meta.t.payload
+++ b/tests/py/inet/meta.t.payload
@@ -80,6 +80,15 @@ inet test-inet input
[ bitwise reg 1 = ( reg 1 >> 0x00000008 ) ]
[ meta set mark with reg 1 ]
+# meta mark set ct mark and 0xffff0000 or meta mark and 0xffff
+inet test-inet input
+ [ ct load mark => reg 1 ]
+ [ bitwise reg 1 = ( reg 1 & 0xffff0000 ) ^ 0x00000000 ]
+ [ meta load mark => reg 2 ]
+ [ bitwise reg 2 = ( reg 2 & 0x0000ffff ) ^ 0x00000000 ]
+ [ bitwise reg 1 = ( reg 1 | reg 2 ) ]
+ [ meta set mark with reg 1 ]
+
# meta protocol ip udp dport 67
inet test-inet input
[ meta load protocol => reg 1 ]
diff --git a/tests/py/ip/ct.t b/tests/py/ip/ct.t
index a0a22289..523d0244 100644
--- a/tests/py/ip/ct.t
+++ b/tests/py/ip/ct.t
@@ -28,9 +28,11 @@ meta mark set ct original saddr . meta mark map { 1.1.1.1 . 0x00000014 : 0x00000
meta mark set ct original ip saddr . meta mark map { 1.1.1.1 . 0x00000014 : 0x0000001e };ok
ct original saddr . meta mark { 1.1.1.1 . 0x00000014 };fail
ct original ip saddr . meta mark { 1.1.1.1 . 0x00000014 };ok
+
ct mark set ip dscp << 2 | 0x10;ok
ct mark set ip dscp << 26 | 0x10;ok
ct mark set ip dscp & 0x0f << 1;ok;ct mark set ip dscp & af33
ct mark set ip dscp & 0x0f << 2;ok;ct mark set ip dscp & 0x3c
ct mark set ip dscp | 0x04;ok
ct mark set ip dscp | 1 << 20;ok;ct mark set ip dscp | 0x100000
+ct mark set ct mark | ip dscp | 0x200 counter;ok;ct mark set ct mark | ip dscp | 0x00000200 counter
diff --git a/tests/py/ip/ct.t.json b/tests/py/ip/ct.t.json
index 915632ae..9e60f7e2 100644
--- a/tests/py/ip/ct.t.json
+++ b/tests/py/ip/ct.t.json
@@ -479,3 +479,35 @@
}
}
]
+
+# ct mark set ct mark | ip dscp | 0x200 counter
+[
+ {
+ "mangle": {
+ "key": {
+ "ct": {
+ "key": "mark"
+ }
+ },
+ "value": {
+ "|": [
+ {
+ "ct": {
+ "key": "mark"
+ }
+ },
+ {
+ "payload": {
+ "protocol": "ip",
+ "field": "dscp"
+ }
+ },
+ 512
+ ]
+ }
+ }
+ },
+ {
+ "counter": null
+ }
+]
diff --git a/tests/py/ip/ct.t.payload b/tests/py/ip/ct.t.payload
index 692011d0..823de597 100644
--- a/tests/py/ip/ct.t.payload
+++ b/tests/py/ip/ct.t.payload
@@ -134,3 +134,14 @@ ip test-ip4 output
[ bitwise reg 1 = ( reg 1 >> 0x00000002 ) ]
[ bitwise reg 1 = ( reg 1 & 0xffefffff ) ^ 0x00100000 ]
[ ct set mark with reg 1 ]
+
+# ct mark set ct mark | ip dscp | 0x200 counter
+ip test-ip4 output
+ [ ct load mark => reg 1 ]
+ [ payload load 1b @ network header + 1 => reg 2 ]
+ [ bitwise reg 2 = ( reg 2 & 0x000000fc ) ^ 0x00000000 ]
+ [ bitwise reg 2 = ( reg 2 >> 0x00000002 ) ]
+ [ bitwise reg 1 = ( reg 1 | reg 2 ) ]
+ [ bitwise reg 1 = ( reg 1 & 0xfffffdff ) ^ 0x00000200 ]
+ [ ct set mark with reg 1 ]
+ [ counter pkts 0 bytes 0 ]
diff --git a/tests/py/ip6/ct.t b/tests/py/ip6/ct.t
index c06fd6a0..1617c68b 100644
--- a/tests/py/ip6/ct.t
+++ b/tests/py/ip6/ct.t
@@ -7,3 +7,4 @@ ct mark set ip6 dscp << 26 | 0x10;ok
ct mark set ip6 dscp | 0x04;ok
ct mark set ip6 dscp | 0xff000000;ok
ct mark set ip6 dscp & 0x0f << 2;ok;ct mark set ip6 dscp & 0x3c
+ct mark set ct mark | ip6 dscp | 0x200 counter;ok;ct mark set ct mark | ip6 dscp | 0x00000200 counter
diff --git a/tests/py/ip6/ct.t.json b/tests/py/ip6/ct.t.json
index 7d8c88bb..2633c2b9 100644
--- a/tests/py/ip6/ct.t.json
+++ b/tests/py/ip6/ct.t.json
@@ -291,3 +291,35 @@
}
}
]
+
+# ct mark set ct mark | ip6 dscp | 0x200 counter
+[
+ {
+ "mangle": {
+ "key": {
+ "ct": {
+ "key": "mark"
+ }
+ },
+ "value": {
+ "|": [
+ {
+ "ct": {
+ "key": "mark"
+ }
+ },
+ {
+ "payload": {
+ "protocol": "ip6",
+ "field": "dscp"
+ }
+ },
+ 512
+ ]
+ }
+ }
+ },
+ {
+ "counter": null
+ }
+]
diff --git a/tests/py/ip6/ct.t.payload b/tests/py/ip6/ct.t.payload
index 944208f2..a7a56d4b 100644
--- a/tests/py/ip6/ct.t.payload
+++ b/tests/py/ip6/ct.t.payload
@@ -44,3 +44,15 @@ ip6 test-ip6 output
[ bitwise reg 1 = ( reg 1 >> 0x00000006 ) ]
[ bitwise reg 1 = ( reg 1 & 0x0000003c ) ^ 0x00000000 ]
[ ct set mark with reg 1 ]
+
+# ct mark set ct mark | ip6 dscp | 0x200 counter
+ip6 test-ip6 output
+ [ ct load mark => reg 1 ]
+ [ payload load 2b @ network header + 0 => reg 2 ]
+ [ bitwise reg 2 = ( reg 2 & 0x0000c00f ) ^ 0x00000000 ]
+ [ byteorder reg 2 = ntoh(reg 2, 2, 2) ]
+ [ bitwise reg 2 = ( reg 2 >> 0x00000006 ) ]
+ [ bitwise reg 1 = ( reg 1 | reg 2 ) ]
+ [ bitwise reg 1 = ( reg 1 & 0xfffffdff ) ^ 0x00000200 ]
+ [ ct set mark with reg 1 ]
+ [ counter pkts 0 bytes 0 ]
diff --git a/tests/shell/features/bitwise_multireg.nft b/tests/shell/features/bitwise_multireg.nft
new file mode 100644
index 00000000..cfce5a39
--- /dev/null
+++ b/tests/shell/features/bitwise_multireg.nft
@@ -0,0 +1,5 @@
+table inet test {
+ chain y {
+ ct mark set ct mark | meta mark
+ }
+}
diff --git a/tests/shell/testcases/bitwise/0040mark_binop_10 b/tests/shell/testcases/bitwise/0040mark_binop_10
new file mode 100755
index 00000000..f523bd73
--- /dev/null
+++ b/tests/shell/testcases/bitwise/0040mark_binop_10
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# NFT_TEST_REQUIRES(NFT_TEST_HAVE_bitwise_multireg)
+
+set -e
+
+RULESET="
+ add table t
+ add chain t c { type filter hook output priority filter; }
+ add rule t c ct mark set ct mark and 0xffff0000 or meta mark and 0xffff
+"
+
+$NFT -f - <<< "$RULESET"
diff --git a/tests/shell/testcases/bitwise/0040mark_binop_11 b/tests/shell/testcases/bitwise/0040mark_binop_11
new file mode 100755
index 00000000..d6dfb3b8
--- /dev/null
+++ b/tests/shell/testcases/bitwise/0040mark_binop_11
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# NFT_TEST_REQUIRES(NFT_TEST_HAVE_bitwise_multireg)
+
+set -e
+
+RULESET="
+ add table t
+ add chain t c { type filter hook input priority filter; }
+ add rule t c meta mark set ct mark and 0xffff0000 or meta mark and 0xffff
+"
+
+$NFT -f - <<< "$RULESET"
diff --git a/tests/shell/testcases/bitwise/0040mark_binop_12 b/tests/shell/testcases/bitwise/0040mark_binop_12
new file mode 100755
index 00000000..bbddb55b
--- /dev/null
+++ b/tests/shell/testcases/bitwise/0040mark_binop_12
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# NFT_TEST_REQUIRES(NFT_TEST_HAVE_bitwise_multireg)
+
+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 ct mark and 0xffff0000 or meta mark and 0xffff
+"
+
+$NFT -f - <<< "$RULESET"
diff --git a/tests/shell/testcases/bitwise/0040mark_binop_13 b/tests/shell/testcases/bitwise/0040mark_binop_13
new file mode 100755
index 00000000..769acb63
--- /dev/null
+++ b/tests/shell/testcases/bitwise/0040mark_binop_13
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# NFT_TEST_REQUIRES(NFT_TEST_HAVE_bitwise_multireg)
+
+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 ct mark and 0xffff0000 or meta mark and 0xffff
+"
+
+$NFT -f - <<< "$RULESET"
diff --git a/tests/shell/testcases/bitwise/0044payload_binop_2 b/tests/shell/testcases/bitwise/0044payload_binop_2
new file mode 100755
index 00000000..13c4acef
--- /dev/null
+++ b/tests/shell/testcases/bitwise/0044payload_binop_2
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# NFT_TEST_REQUIRES(NFT_TEST_HAVE_bitwise_multireg)
+
+set -e
+
+RULESET="
+ add table t
+ add chain t c { type filter hook output priority filter; }
+ add rule t c ct mark set ct mark | ip dscp | 0x200 counter
+"
+
+$NFT -f - <<< "$RULESET"
diff --git a/tests/shell/testcases/bitwise/0044payload_binop_5 b/tests/shell/testcases/bitwise/0044payload_binop_5
new file mode 100755
index 00000000..7e8095c8
--- /dev/null
+++ b/tests/shell/testcases/bitwise/0044payload_binop_5
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# NFT_TEST_REQUIRES(NFT_TEST_HAVE_bitwise_multireg)
+
+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 ct mark | ip6 dscp | 0x200 counter
+"
+
+$NFT -f - <<< "$RULESET"
diff --git a/tests/shell/testcases/bitwise/dumps/0040mark_binop_10.nft b/tests/shell/testcases/bitwise/dumps/0040mark_binop_10.nft
new file mode 100644
index 00000000..5566f729
--- /dev/null
+++ b/tests/shell/testcases/bitwise/dumps/0040mark_binop_10.nft
@@ -0,0 +1,6 @@
+table ip t {
+ chain c {
+ type filter hook output priority filter; policy accept;
+ ct mark set ct mark & 0xffff0000 | meta mark & 0x0000ffff
+ }
+}
diff --git a/tests/shell/testcases/bitwise/dumps/0040mark_binop_11.nft b/tests/shell/testcases/bitwise/dumps/0040mark_binop_11.nft
new file mode 100644
index 00000000..719980d5
--- /dev/null
+++ b/tests/shell/testcases/bitwise/dumps/0040mark_binop_11.nft
@@ -0,0 +1,6 @@
+table ip t {
+ chain c {
+ type filter hook input priority filter; policy accept;
+ meta mark set ct mark & 0xffff0000 | meta mark & 0x0000ffff
+ }
+}
diff --git a/tests/shell/testcases/bitwise/dumps/0040mark_binop_12.nft b/tests/shell/testcases/bitwise/dumps/0040mark_binop_12.nft
new file mode 100644
index 00000000..bd589fe5
--- /dev/null
+++ b/tests/shell/testcases/bitwise/dumps/0040mark_binop_12.nft
@@ -0,0 +1,6 @@
+table ip6 t {
+ chain c {
+ type filter hook output priority filter; policy accept;
+ ct mark set ct mark & 0xffff0000 | meta mark & 0x0000ffff
+ }
+}
diff --git a/tests/shell/testcases/bitwise/dumps/0040mark_binop_13.nft b/tests/shell/testcases/bitwise/dumps/0040mark_binop_13.nft
new file mode 100644
index 00000000..2b046b12
--- /dev/null
+++ b/tests/shell/testcases/bitwise/dumps/0040mark_binop_13.nft
@@ -0,0 +1,6 @@
+table ip6 t {
+ chain c {
+ type filter hook input priority filter; policy accept;
+ meta mark set ct mark & 0xffff0000 | meta mark & 0x0000ffff
+ }
+}
diff --git a/tests/shell/testcases/bitwise/dumps/0044payload_binop_2.nft b/tests/shell/testcases/bitwise/dumps/0044payload_binop_2.nft
new file mode 100644
index 00000000..ed347bb2
--- /dev/null
+++ b/tests/shell/testcases/bitwise/dumps/0044payload_binop_2.nft
@@ -0,0 +1,6 @@
+table ip t {
+ chain c {
+ type filter hook output priority filter; policy accept;
+ ct mark set ct mark | ip dscp | 0x00000200 counter packets 0 bytes 0
+ }
+}
diff --git a/tests/shell/testcases/bitwise/dumps/0044payload_binop_5.nft b/tests/shell/testcases/bitwise/dumps/0044payload_binop_5.nft
new file mode 100644
index 00000000..ccdb93d7
--- /dev/null
+++ b/tests/shell/testcases/bitwise/dumps/0044payload_binop_5.nft
@@ -0,0 +1,6 @@
+table ip6 t {
+ chain c {
+ type filter hook output priority filter; policy accept;
+ ct mark set ct mark | ip6 dscp | 0x00000200 counter packets 0 bytes 0
+ }
+}