]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: py: add ct timeout tests
authorHarsha Sharma <harshasharmaiitr@gmail.com>
Mon, 13 Aug 2018 19:37:55 +0000 (01:07 +0530)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 31 Aug 2018 16:40:13 +0000 (18:40 +0200)
Add test for adding ct timeout objects and assigning it via rule.

Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
tests/py/ip/objects.t
tests/py/ip/objects.t.payload
tests/py/nft-test.py

index 5e8c763136ff70256dd88954c673127f51ceff3e..fc2ee26607925ae03f4592891a4c14839355b249 100644 (file)
@@ -32,3 +32,12 @@ ct helper set tcp dport map {21 : "cthelp1", 2121 : "cthelp1" };ok
 ip saddr 192.168.1.3 limit name "lim1";ok
 ip saddr 192.168.1.3 limit name "lim3";fail
 limit name tcp dport map {443 : "lim1", 80 : "lim2", 22 : "lim1"};ok
+
+# ct timeout
+%cttime1 type ct timeout { protocol tcp; policy = { established:122 } ;};ok
+%cttime2 type ct timeout { protocol udp; policy = { syn_sent:122 } ;};fail
+%cttime3 type ct timeout { protocol tcp; policy = { established:132, close:16, close_wait:16 } ; l3proto ip ;};ok
+%cttime4 type ct timeout { protocol udp; policy = { replied:14, unreplied:19 } ;};ok
+%cttime5 type ct timeout {protocol tcp; policy = { estalbished:100 } ;};fail
+
+ct timeout set "cttime1";ok
index 193d7972d3e62a3d7ced3fe20e7d7114931707e3..719b6c3781b52510a113b4f1c71dfaf5be3f0899 100644 (file)
@@ -59,3 +59,7 @@ ip test-ip4 output
   [ cmp eq reg 1 0x00000006 ]
   [ payload load 2b @ transport header + 2 => reg 1 ]
   [ objref sreg 1 set __objmap%d ]
+
+# ct timeout set "cttime1"
+ip test-ip4 output
+  [ objref type 7 name cttime1 ]
index 3b89ec3514bde0bb1c232e0f03a14fd2dd0bcf4e..23f73d50563e468440f9900e62bc283edfebfd3f 100755 (executable)
@@ -1081,6 +1081,10 @@ def obj_process(obj_line, filename, lineno):
        obj_type = "ct helper"
        tokens[3] = ""
 
+    if obj_type == "ct" and tokens[3] == "timeout":
+       obj_type = "ct timeout"
+       tokens[3] = ""
+
     if len(tokens) > 3:
         obj_spcf = " ".join(tokens[3:])