]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests/py: test port ranges and maps for redirect
authorPablo Neira Ayuso <pablo@netfilter.org>
Sun, 31 Jan 2016 22:17:20 +0000 (23:17 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sun, 31 Jan 2016 22:43:18 +0000 (23:43 +0100)
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
tests/py/ip/redirect.t
tests/py/ip/redirect.t.payload
tests/py/ip6/redirect.t
tests/py/ip6/redirect.t.payload.ip6

index 8161ae6d73ddc649e887ae602afe7570598ac74b..7e205a90ed4b4c53988f03450adb289c5def4549 100644 (file)
@@ -22,6 +22,7 @@ tcp dport 22 redirect to 22;ok
 udp dport 1234 redirect to 4321;ok
 ip daddr 172.16.0.1 udp dport 9998 redirect to 6515;ok
 tcp dport 39128 redirect to 993;ok
+ip protocol tcp redirect to 100-200;ok;ip protocol 6 redirect to 100-200
 redirect to 1234;fail
 redirect to 12341111;fail
 
@@ -44,3 +45,7 @@ ip saddr 10.1.1.1 redirect drop;fail
 tcp dport { 1, 2, 3, 4, 5, 6, 7, 8, 101, 202, 303, 1001, 2002, 3003} redirect;ok
 ip daddr 10.0.0.0-10.2.3.4 udp dport 53 counter packets 0 bytes 0 redirect;ok
 iifname eth0 ct state new,established tcp dport vmap {22 : drop, 222 : drop } redirect;ok
+
+# redirect with maps
+ip protocol 6 redirect to tcp dport map { 22 : 8000, 80 : 8080};ok
+
index ac71804306cd612dc3db98e3e854158235e22f79..da603e73fa8ae404a648275412896aa464058cfe 100644 (file)
@@ -124,6 +124,14 @@ ip test-ip4 output
   [ immediate reg 1 0x0000e103 ]
   [ redir proto_min reg 1 ]
 
+# ip protocol tcp redirect to 100-200
+ip test-ip4 output
+  [ payload load 1b @ network header + 9 => reg 1 ]
+  [ cmp eq reg 1 0x00000006 ]
+  [ immediate reg 1 0x00006400 ]
+  [ immediate reg 2 0x0000c800 ]
+  [ redir proto_min reg 1 proto_max reg 2 ]
+
 # tcp dport 9128 redirect to 993 random
 ip test-ip4 output
   [ payload load 1b @ network header + 9 => reg 1 ]
@@ -199,3 +207,14 @@ ip test-ip4 output
   [ lookup reg 1 set map%d dreg 0 ]
   [ redir ]
 
+# ip protocol 6 redirect to tcp dport map { 22 : 8000, 80 : 8080}
+map%d test-ip4 b
+map%d test-ip4 0
+        element 00001600  : 0000401f 0 [end]    element 00005000  : 0000901f 0 [end]
+ip test-ip4 output
+  [ payload load 1b @ network header + 9 => reg 1 ]
+  [ cmp eq reg 1 0x00000006 ]
+  [ payload load 2b @ transport header + 2 => reg 1 ]
+  [ lookup reg 1 set map%d dreg 1 ]
+  [ redir proto_min reg 1 ]
+
index d5a0a3b23ee426e31d45c54c214fcbd391fe3914..fca84e5bfaf8d523aa69f97d7121fe87a5a39b2d 100644 (file)
@@ -22,6 +22,7 @@ udp dport 53 redirect persistent,fully-random,random;ok;udp dport 53 redirect ra
 # port specification
 udp dport 1234 redirect to 1234;ok
 ip6 daddr fe00::cafe udp dport 9998 redirect to 6515;ok
+ip6 nexthdr tcp redirect to 100-200;ok;ip6 nexthdr 6 redirect to 100-200
 tcp dport 39128 redirect to 993;ok
 redirect to 1234;fail
 redirect to 12341111;fail
@@ -43,3 +44,6 @@ ip6 saddr ::1 redirect drop;fail
 tcp dport { 1, 2, 3, 4, 5, 6, 7, 8, 101, 202, 303, 1001, 2002, 3003} redirect;ok
 ip6 daddr fe00::1-fe00::200 udp dport 53 counter packets 0 bytes 0 redirect;ok
 iifname eth0 ct state new,established tcp dport vmap {22 : drop, 222 : drop } redirect;ok
+
+# redirect with maps
+ip6 nexthdr 6 redirect to tcp dport map { 22 : 8000, 80 : 8080};ok
index 3369a7a39bbd63dbdde46f94d6d3fcd2d9f780a0..4e78a2442928352418d0045b6e7114a87f33c750 100644 (file)
@@ -117,6 +117,14 @@ ip6 test-ip6 output
   [ immediate reg 1 0x00007319 ]
   [ redir proto_min reg 1 ]
 
+# ip6 nexthdr tcp redirect to 100-200
+ip6 test-ip6 output
+  [ payload load 1b @ network header + 6 => reg 1 ]
+  [ cmp eq reg 1 0x00000006 ]
+  [ immediate reg 1 0x00006400 ]
+  [ immediate reg 2 0x0000c800 ]
+  [ redir proto_min reg 1 proto_max reg 2 ]
+
 # tcp dport 39128 redirect to 993
 ip6 test-ip6 output
   [ payload load 1b @ network header + 6 => reg 1 ]
@@ -183,3 +191,14 @@ ip6 test-ip6 output
   [ lookup reg 1 set map%d dreg 0 ]
   [ redir ]
 
+# ip6 nexthdr 6 redirect to tcp dport map { 22 : 8000, 80 : 8080}
+map%d test-ip6 b
+map%d test-ip6 0
+       element 00001600  : 0000401f 0 [end]    element 00005000  : 0000901f 0 [end]
+ip6 test-ip6 output
+  [ payload load 1b @ network header + 6 => reg 1 ]
+  [ cmp eq reg 1 0x00000006 ]
+  [ payload load 2b @ transport header + 2 => reg 1 ]
+  [ lookup reg 1 set map%d dreg 1 ]
+  [ redir proto_min reg 1 ]
+