]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: add two test cases using binop w. payload
authorFlorian Westphal <fw@strlen.de>
Fri, 7 Aug 2015 18:52:04 +0000 (20:52 +0200)
committerFlorian Westphal <fw@strlen.de>
Fri, 7 Aug 2015 19:21:47 +0000 (21:21 +0200)
[ payload load 4b @ network header + 12 => reg 1 ]
[ bitwise reg 1 = (reg=1 & 0xff000000 ) ^ 0x00000000 ]
[ cmp eq reg 1 ...

.. to make sure that later support to match header elements that have odd
(non-byte aligned) lengths/offsets doesn't erronously eliminate explicitly
added binops while searching expressions for implicit binops.

Signed-off-by: Florian Westphal <fw@strlen.de>
tests/regression/ip/ip.t
tests/regression/ip/ip.t.payload
tests/regression/ip/ip.t.payload.inet

index fa864dfd783e375735b698ff9f3dab082d409bbd..11a959817f1059f290aa6ecda71cf704451f5828 100644 (file)
@@ -105,3 +105,6 @@ ip saddr != 192.168.1.3-192.168.33.55;ok
 ip daddr 192.168.0.1;ok
 ip daddr 192.168.0.1 drop;ok
 ip daddr 192.168.0.2 log;ok
+
+ip saddr \& 0xff == 1;ok;ip saddr & 0.0.0.255 == 0.0.0.1
+ip saddr \& 0.0.0.255 \< 0.0.0.127;ok;ip saddr & 0.0.0.255 < 0.0.0.127
index 18db172a336cafc37f2c578ad38dbd7aff716904..ec4897e801c3e697fe488bafc017c60b7bc8b445 100644 (file)
@@ -335,3 +335,15 @@ ip test-ip4 input
   [ cmp eq reg 1 0x0200a8c0 ]
   [ log prefix (null) ]
 
+# ip saddr \& 0xff == 1
+ip test-ip4 input
+  [ payload load 4b @ network header + 12 => reg 1 ]
+  [ bitwise reg 1 = (reg=1 & 0xff000000 ) ^ 0x00000000 ]
+  [ cmp eq reg 1 0x01000000 ]
+
+# ip saddr \& 0.0.0.255 \< 0.0.0.127
+ip test-ip4 input
+  [ payload load 4b @ network header + 12 => reg 1 ]
+  [ bitwise reg 1 = (reg=1 & 0xff000000 ) ^ 0x00000000 ]
+  [ cmp lt reg 1 0x7f000000 ]
+
index be635cdb1c2cf3451038b2129c71ab711c66100c..1a2b1b5cc726cdcbb9e212014f1e25f8c177954b 100644 (file)
@@ -441,3 +441,19 @@ inet test-inet input
   [ cmp eq reg 1 0x0200a8c0 ]
   [ log prefix (null) ]
 
+# ip saddr \& 0xff == 1
+inet test-inet input
+  [ meta load nfproto => reg 1 ]
+  [ cmp eq reg 1 0x00000002 ]
+  [ payload load 4b @ network header + 12 => reg 1 ]
+  [ bitwise reg 1 = (reg=1 & 0xff000000 ) ^ 0x00000000 ]
+  [ cmp eq reg 1 0x01000000 ]
+
+# ip saddr \& 0.0.0.255 \< 0.0.0.127
+inet test-inet input
+  [ meta load nfproto => reg 1 ]
+  [ cmp eq reg 1 0x00000002 ]
+  [ payload load 4b @ network header + 12 => reg 1 ]
+  [ bitwise reg 1 = (reg=1 & 0xff000000 ) ^ 0x00000000 ]
+  [ cmp lt reg 1 0x7f000000 ]
+