]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: add basic payload tests
authorFlorian Westphal <fw@strlen.de>
Thu, 21 Jul 2016 13:57:15 +0000 (15:57 +0200)
committerFlorian Westphal <fw@strlen.de>
Thu, 21 Jul 2016 15:22:05 +0000 (17:22 +0200)
payload set operations should work at least for byte-sized
quantities >= 2 byte.

Before adding support for odd-sized writes (ecn, dscp, ip6 flowlabel
...) add a bunch of tests to cover current state.

Signed-off-by: Florian Westphal <fw@strlen.de>
12 files changed:
tests/py/inet/udp.t
tests/py/inet/udp.t.payload.inet
tests/py/inet/udp.t.payload.ip
tests/py/inet/udp.t.payload.ip6
tests/py/inet/udp.t.payload.netdev
tests/py/ip/ip.t
tests/py/ip/ip.t.payload
tests/py/ip/ip.t.payload.inet
tests/py/ip/ip.t.payload.netdev
tests/py/ip6/ip6.t
tests/py/ip6/ip6.t.payload.inet
tests/py/ip6/ip6.t.payload.ip6

index 8cff2c694209896faae5a022035466b68a89247b..ea9c87b4a58a1c5b67faa3f18709f20d4464890a 100644 (file)
@@ -50,3 +50,7 @@ udp checksum { 33, 55, 67, 88};ok
 - udp checksum != { 33, 55, 67, 88};ok
 udp checksum { 33-55};ok
 - udp checksum != { 33-55};ok
+
+# limit impact to lo
+iif lo udp checksum set 0;ok
+iif lo udp dport set 65535;ok
index 4ca9904bc794f483652418347dfa57299cc3b4f5..1f49438df8fe30c070629dc498bb918748b80d78 100644 (file)
@@ -220,3 +220,20 @@ inet test-inet input
   [ payload load 2b @ transport header + 6 => reg 1 ]
   [ lookup reg 1 set __set%d ]
 
+# iif lo udp checksum set 0
+inet test-inet input
+  [ meta load iif => reg 1 ]
+  [ cmp eq reg 1 0x00000001 ]
+  [ meta load l4proto => reg 1 ]
+  [ cmp eq reg 1 0x00000011 ]
+  [ immediate reg 1 0x00000000 ]
+  [ payload write reg 1 => 2b @ transport header + 6 csum_type 1 csum_off 6 ]
+
+# iif lo udp dport set 65535
+inet test-inet input
+  [ meta load iif => reg 1 ]
+  [ cmp eq reg 1 0x00000001 ]
+  [ meta load l4proto => reg 1 ]
+  [ cmp eq reg 1 0x00000011 ]
+  [ immediate reg 1 0x0000ffff ]
+  [ payload write reg 1 => 2b @ transport header + 2 csum_type 1 csum_off 6 ]
index 56b6051d38d196827dc1d6e0b0ed495677228417..8b4550dcab84ec8cb0f3d53cda9ead90eac13dfa 100644 (file)
@@ -220,3 +220,20 @@ ip test-ip4 input
   [ payload load 2b @ transport header + 6 => reg 1 ]
   [ lookup reg 1 set __set%d ]
 
+# iif lo udp checksum set 0
+ip test-ip4 input
+  [ meta load iif => reg 1 ]
+  [ cmp eq reg 1 0x00000001 ]
+  [ payload load 1b @ network header + 9 => reg 1 ]
+  [ cmp eq reg 1 0x00000011 ]
+  [ immediate reg 1 0x00000000 ]
+  [ payload write reg 1 => 2b @ transport header + 6 csum_type 1 csum_off 6 ]
+
+# iif lo udp dport set 65535
+ip test-ip4 input
+  [ meta load iif => reg 1 ]
+  [ cmp eq reg 1 0x00000001 ]
+  [ payload load 1b @ network header + 9 => reg 1 ]
+  [ cmp eq reg 1 0x00000011 ]
+  [ immediate reg 1 0x0000ffff ]
+  [ payload write reg 1 => 2b @ transport header + 2 csum_type 1 csum_off 6 ]
index 1f1df66881f074cf70a824789b39d5a8b73de674..86204f6c8b1312cacdeb64c2316d25bd63d8bc6e 100644 (file)
@@ -220,3 +220,20 @@ ip6 test-ip6 input
   [ payload load 2b @ transport header + 6 => reg 1 ]
   [ lookup reg 1 set __set%d ]
 
+# iif lo udp checksum set 0
+ip6 test-ip6 input
+  [ meta load iif => reg 1 ]
+  [ cmp eq reg 1 0x00000001 ]
+  [ payload load 1b @ network header + 6 => reg 1 ]
+  [ cmp eq reg 1 0x00000011 ]
+  [ immediate reg 1 0x00000000 ]
+  [ payload write reg 1 => 2b @ transport header + 6 csum_type 1 csum_off 6 ]
+
+# iif lo udp dport set 65535
+ip test-ip4 input
+  [ meta load iif => reg 1 ]
+  [ cmp eq reg 1 0x00000001 ]
+  [ payload load 1b @ network header + 6 => reg 1 ]
+  [ cmp eq reg 1 0x00000011 ]
+  [ immediate reg 1 0x0000ffff ]
+  [ payload write reg 1 => 2b @ transport header + 2 csum_type 1 csum_off 6 ]
index 4ca9904bc794f483652418347dfa57299cc3b4f5..2eb2a76d3b56041d620dcdfffc7534c004ec0eaa 100644 (file)
@@ -220,3 +220,21 @@ inet test-inet input
   [ payload load 2b @ transport header + 6 => reg 1 ]
   [ lookup reg 1 set __set%d ]
 
+# iif lo udp checksum set 0
+netdev test-netdev ingress
+  [ meta load iif => reg 1 ]
+  [ cmp eq reg 1 0x00000001 ]
+  [ meta load l4proto => reg 1 ]
+  [ cmp eq reg 1 0x00000011 ]
+  [ immediate reg 1 0x00000000 ]
+  [ payload write reg 1 => 2b @ transport header + 6 csum_type 1 csum_off 6 ]
+
+# iif lo udp dport set 65535
+netdev test-netdev ingress
+  [ meta load iif => reg 1 ]
+  [ cmp eq reg 1 0x00000001 ]
+  [ meta load l4proto => reg 1 ]
+  [ cmp eq reg 1 0x00000011 ]
+  [ immediate reg 1 0x0000ffff ]
+  [ payload write reg 1 => 2b @ transport header + 2 csum_type 1 csum_off 6 ]
+
index a265b757cceccbf7bc4e102d6052649d73ea9678..90e117ae0de2db21b43c0de1491c0ca71924c668 100644 (file)
@@ -121,3 +121,8 @@ ip version 4 ip hdrlength 5;ok
 ip hdrlength 0;ok
 ip hdrlength 15;ok
 ip hdrlength 16;fail
+
+# limit impact to lo
+iif lo ip daddr set 127.0.0.1;ok
+iif lo ip checksum set 0;ok
+iif lo ip id set 0;ok
index 15cc59042af8ca31ab84bd6bce23f3aa9d164de4..d6ef540b4381a50b27eba2eaeeefe8b16c6b4b5d 100644 (file)
@@ -416,3 +416,24 @@ ip test-ip4 input
   [ bitwise reg 1 = (reg=1 & 0x0000000f ) ^ 0x00000000 ]
   [ cmp eq reg 1 0x0000000f ]
 
+# iif lo ip daddr set 127.0.0.1
+ip test-ip4 input
+  [ meta load iif => reg 1 ]
+  [ cmp eq reg 1 0x00000001 ]
+  [ immediate reg 1 0x0100007f ]
+  [ payload write reg 1 => 4b @ network header + 16 csum_type 1 csum_off 10 ]
+
+# iif lo ip checksum set 0
+ip test-ip4 input
+  [ meta load iif => reg 1 ]
+  [ cmp eq reg 1 0x00000001 ]
+  [ immediate reg 1 0x00000000 ]
+  [ payload write reg 1 => 2b @ network header + 10 csum_type 1 csum_off 10 ]
+
+# iif lo ip id set 0
+ip test-ip4 input
+  [ meta load iif => reg 1 ]
+  [ cmp eq reg 1 0x00000001 ]
+  [ immediate reg 1 0x00000000 ]
+  [ payload write reg 1 => 2b @ network header + 4 csum_type 1 csum_off 10 ]
+
index e495246e3011d082cc39029fd943eb7b3e1e9066..6c78536ca74334a2be0c0e7c721bbb5479374702 100644 (file)
@@ -548,3 +548,28 @@ inet test-inet input
   [ bitwise reg 1 = (reg=1 & 0x0000000f ) ^ 0x00000000 ]
   [ cmp eq reg 1 0x0000000f ]
 
+# iif lo ip daddr set 127.0.0.1
+inet test-inet input
+  [ meta load iif => reg 1 ]
+  [ cmp eq reg 1 0x00000001 ]
+  [ meta load nfproto => reg 1 ]
+  [ cmp eq reg 1 0x00000002 ]
+  [ immediate reg 1 0x0100007f ]
+  [ payload write reg 1 => 4b @ network header + 16 csum_type 1 csum_off 10 ]
+
+# iif lo ip checksum set 0
+inet test-inet input
+  [ meta load iif => reg 1 ]
+  [ cmp eq reg 1 0x00000001 ]
+  [ meta load nfproto => reg 1 ]
+  [ cmp eq reg 1 0x00000002 ]
+  [ immediate reg 1 0x00000000 ]
+  [ payload write reg 1 => 2b @ network header + 10 csum_type 1 csum_off 10 ]
+
+# iif lo ip id set 0
+inet test-inet input
+  [ meta load iif => reg 1 ]
+  [ cmp eq reg 1 0x00000001 ]
+  [ meta load nfproto => reg 1 ]
+  [ cmp eq reg 1 0x00000002 ]
+  [ immediate reg 1 0x00000000 ]
index 8eaee4cfd00a450c1e00e285abbf7d5183255751..714b0d24e821f949cd9fdd177920b244c62573bc 100644 (file)
@@ -648,3 +648,26 @@ netdev test-netdev ingress
   [ bitwise reg 1 = (reg=1 & 0x000000fc ) ^ 0x00000000 ]
   [ lookup reg 1 set __set%d ]
 
+# iif lo ip daddr set 127.0.0.1
+netdev test-netdev ingress
+  [ meta load iif => reg 1 ]
+  [ cmp eq reg 1 0x00000001 ]
+  [ meta load protocol => reg 1 ]
+  [ cmp eq reg 1 0x00000008 ]
+  [ immediate reg 1 0x0100007f ]
+  [ payload write reg 1 => 4b @ network header + 16 csum_type 1 csum_off 10 ]
+
+# iif lo ip checksum set 0
+netdev test-netdev ingress
+  [ meta load iif => reg 1 ]
+  [ cmp eq reg 1 0x00000001 ]
+  [ meta load protocol => reg 1 ]
+  [ cmp eq reg 1 0x00000008 ]
+  [ immediate reg 1 0x00000000 ]
+  [ payload write reg 1 => 2b @ network header + 10 csum_type 1 csum_off 10 ]
+
+# iif lo ip id set 0
+netdev test-netdev ingress
+  [ meta load iif => reg 1 ]
+  [ cmp eq reg 1 0x00000001 ]
+  [ meta load protocol => reg 1 ]
index 2278618fcae791b403796338c2f30c8056c53884..0a58fa8d27cc9b2c15fc2521bac7074a10ae49c8 100644 (file)
@@ -141,3 +141,7 @@ ip6 saddr ::1 ip6 daddr ::2;ok
 
 - ip6 daddr != {::1234:1234:1234:1234:1234:1234:1234, 1234:1234::1234:1234:1234:1234:1234 };ok
 ip6 daddr != ::1234:1234:1234:1234:1234:1234:1234-1234:1234::1234:1234:1234:1234:1234;ok;ip6 daddr != 0:1234:1234:1234:1234:1234:1234:1234-1234:1234:0:1234:1234:1234:1234:1234
+
+# limit impact to lo
+iif lo ip6 daddr set ::1;ok
+iif lo ip6 hoplimit set 1;ok
index c29c5a3f52ad5d904a1788b619c2d0eae5b7591f..45bdd09a6d263530bdb71211dd581baddeeba310 100644 (file)
@@ -513,3 +513,20 @@ inet test-inet input
   [ cmp lt reg 1 0x34120000 0x34123412 0x34123412 0x34123412 ]
   [ cmp gt reg 1 0x34123412 0x34120000 0x34123412 0x34123412 ]
 
+# iif lo ip6 daddr set ::1
+inet test-inet input
+  [ meta load iif => reg 1 ]
+  [ cmp eq reg 1 0x00000001 ]
+  [ meta load nfproto => reg 1 ]
+  [ cmp eq reg 1 0x0000000a ]
+  [ immediate reg 1 0x00000000 0x00000000 0x00000000 0x01000000 ]
+  [ payload write reg 1 => 16b @ network header + 24 csum_type 0 csum_off 0 ]
+
+# iif lo ip6 hoplimit set 1
+inet test-inet input
+  [ meta load iif => reg 1 ]
+  [ cmp eq reg 1 0x00000001 ]
+  [ meta load nfproto => reg 1 ]
+  [ cmp eq reg 1 0x0000000a ]
+  [ immediate reg 1 0x00000001 ]
+  [ payload write reg 1 => 1b @ network header + 7 csum_type 0 csum_off 0 ]
index c24992379d3d50594f2df25d8f97f2c885dd6bbb..e3549890561187fa6bed92a308ffb82299d0db7d 100644 (file)
@@ -379,3 +379,15 @@ ip6 test-ip6 input
   [ cmp lt reg 1 0x34120000 0x34123412 0x34123412 0x34123412 ]
   [ cmp gt reg 1 0x34123412 0x34120000 0x34123412 0x34123412 ]
 
+# iif lo ip6 daddr set ::1
+ip6 test-ip6 input
+  [ meta load iif => reg 1 ]
+  [ cmp eq reg 1 0x00000001 ]
+  [ immediate reg 1 0x00000000 0x00000000 0x00000000 0x01000000 ]
+  [ payload write reg 1 => 16b @ network header + 24 csum_type 0 csum_off 0 ]
+
+# iif lo ip6 hoplimit set 1
+ip6 test-ip6 input
+  [ meta load iif => reg 1 ]
+  [ cmp eq reg 1 0x00000001 ]
+  [ immediate reg 1 0x00000001 ]