summaryrefslogtreecommitdiffstats
path: root/tests/py/any/ct.t.payload
diff options
context:
space:
mode:
Diffstat (limited to 'tests/py/any/ct.t.payload')
-rw-r--r--tests/py/any/ct.t.payload275
1 files changed, 275 insertions, 0 deletions
diff --git a/tests/py/any/ct.t.payload b/tests/py/any/ct.t.payload
new file mode 100644
index 00000000..2bebaccd
--- /dev/null
+++ b/tests/py/any/ct.t.payload
@@ -0,0 +1,275 @@
+# ct state new,established, related, untracked
+ip test-ip4 output
+ [ ct load state => reg 1 ]
+ [ bitwise reg 1 = (reg=1 & 0x0000004e ) ^ 0x00000000 ]
+ [ cmp neq reg 1 0x00000000 ]
+
+# ct state != related
+ip test-ip4 output
+ [ ct load state => reg 1 ]
+ [ cmp neq reg 1 0x00000004 ]
+
+# ct state {new,established, related, untracked}
+set%d test-ip4 3
+set%d test-ip4 0
+ element 00000008 : 0 [end] element 00000002 : 0 [end] element 00000004 : 0 [end] element 00000040 : 0 [end]
+ip test-ip4 output
+ [ ct load state => reg 1 ]
+ [ lookup reg 1 set set%d ]
+
+# ct state invalid drop
+ip test-ip4 output
+ [ ct load state => reg 1 ]
+ [ bitwise reg 1 = (reg=1 & 0x00000001 ) ^ 0x00000000 ]
+ [ cmp neq reg 1 0x00000000 ]
+ [ immediate reg 0 drop ]
+
+# ct state established accept
+ip test-ip4 output
+ [ ct load state => reg 1 ]
+ [ bitwise reg 1 = (reg=1 & 0x00000002 ) ^ 0x00000000 ]
+ [ cmp neq reg 1 0x00000000 ]
+ [ immediate reg 0 accept ]
+
+# ct state 8
+ip test-ip4 output
+ [ ct load state => reg 1 ]
+ [ bitwise reg 1 = (reg=1 & 0x00000008 ) ^ 0x00000000 ]
+ [ cmp neq reg 1 0x00000000 ]
+
+# ct direction original
+ip test-ip4 output
+ [ ct load direction => reg 1 ]
+ [ cmp eq reg 1 0x00000000 ]
+
+# ct direction != original
+ip test-ip4 output
+ [ ct load direction => reg 1 ]
+ [ cmp neq reg 1 0x00000000 ]
+
+# ct direction reply
+ip test-ip4 output
+ [ ct load direction => reg 1 ]
+ [ cmp eq reg 1 0x00000001 ]
+
+# ct direction != reply
+ip test-ip4 output
+ [ ct load direction => reg 1 ]
+ [ cmp neq reg 1 0x00000001 ]
+
+# ct direction {reply, original}
+set%d test-ip4 3
+set%d test-ip4 0
+ element 00000001 : 0 [end] element 00000000 : 0 [end]
+ip test-ip4 output
+ [ ct load direction => reg 1 ]
+ [ lookup reg 1 set set%d ]
+
+# ct status expected
+ip test-ip4 output
+ [ ct load status => reg 1 ]
+ [ bitwise reg 1 = (reg=1 & 0x00000001 ) ^ 0x00000000 ]
+ [ cmp neq reg 1 0x00000000 ]
+
+# ct status != expected
+ip test-ip4 output
+ [ ct load status => reg 1 ]
+ [ cmp neq reg 1 0x00000001 ]
+
+# ct status seen-reply
+ip test-ip4 output
+ [ ct load status => reg 1 ]
+ [ bitwise reg 1 = (reg=1 & 0x00000002 ) ^ 0x00000000 ]
+ [ cmp neq reg 1 0x00000000 ]
+
+# ct status != seen-reply
+ip test-ip4 output
+ [ ct load status => reg 1 ]
+ [ cmp neq reg 1 0x00000002 ]
+
+# ct status {expected, seen-reply, assured, confirmed, dying}
+set%d test-ip4 3
+set%d test-ip4 0
+ element 00000001 : 0 [end] element 00000002 : 0 [end] element 00000004 : 0 [end] element 00000008 : 0 [end] element 00000200 : 0 [end]
+ip test-ip4 output
+ [ ct load status => reg 1 ]
+ [ lookup reg 1 set set%d ]
+
+# ct mark 0
+ip test-ip4 output
+ [ ct load mark => reg 1 ]
+ [ cmp eq reg 1 0x00000000 ]
+
+# ct mark or 0x23 == 0x11
+ip test-ip4 output
+ [ ct load mark => reg 1 ]
+ [ bitwise reg 1 = (reg=1 & 0xffffffdc ) ^ 0x00000023 ]
+ [ cmp eq reg 1 0x00000011 ]
+
+# ct mark or 0x3 != 0x1
+ip test-ip4 output
+ [ ct load mark => reg 1 ]
+ [ bitwise reg 1 = (reg=1 & 0xfffffffc ) ^ 0x00000003 ]
+ [ cmp neq reg 1 0x00000001 ]
+
+# ct mark and 0x23 == 0x11
+ip test-ip4 output
+ [ ct load mark => reg 1 ]
+ [ bitwise reg 1 = (reg=1 & 0x00000023 ) ^ 0x00000000 ]
+ [ cmp eq reg 1 0x00000011 ]
+
+# ct mark and 0x3 != 0x1
+ip test-ip4 output
+ [ ct load mark => reg 1 ]
+ [ bitwise reg 1 = (reg=1 & 0x00000003 ) ^ 0x00000000 ]
+ [ cmp neq reg 1 0x00000001 ]
+
+# ct mark xor 0x23 == 0x11
+ip test-ip4 output
+ [ ct load mark => reg 1 ]
+ [ cmp eq reg 1 0x00000032 ]
+
+# ct mark xor 0x3 != 0x1
+ip test-ip4 output
+ [ ct load mark => reg 1 ]
+ [ cmp neq reg 1 0x00000002 ]
+
+# ct mark 0x00000032
+ip test-ip4 output
+ [ ct load mark => reg 1 ]
+ [ cmp eq reg 1 0x00000032 ]
+
+# ct mark != 0x00000032
+ip test-ip4 output
+ [ ct load mark => reg 1 ]
+ [ cmp neq reg 1 0x00000032 ]
+
+# ct mark 0x00000032-0x00000045
+ip test-ip4 output
+ [ ct load mark => reg 1 ]
+ [ byteorder reg 1 = hton(reg 1, 4, 4) ]
+ [ cmp gte reg 1 0x32000000 ]
+ [ cmp lte reg 1 0x45000000 ]
+
+# ct mark != 0x00000032-0x00000045
+ip test-ip4 output
+ [ ct load mark => reg 1 ]
+ [ byteorder reg 1 = hton(reg 1, 4, 4) ]
+ [ cmp lt reg 1 0x32000000 ]
+ [ cmp gt reg 1 0x45000000 ]
+
+# ct mark {0x32, 0x2222, 0x42de3}
+set%d test-ip4 3
+set%d test-ip4 0
+ element 00000032 : 0 [end] element 00002222 : 0 [end] element 00042de3 : 0 [end]
+ip test-ip4 output
+ [ ct load mark => reg 1 ]
+ [ lookup reg 1 set set%d ]
+
+# ct mark set 0x11 xor 0x1331
+ip test-ip4 output
+ [ immediate reg 1 0x00001320 ]
+ [ ct set mark with reg 1 ]
+
+# ct mark set 0x11333 and 0x11
+ip test-ip4 output
+ [ immediate reg 1 0x00000011 ]
+ [ ct set mark with reg 1 ]
+
+# ct mark set 0x12 or 0x11
+ip test-ip4 output
+ [ immediate reg 1 0x00000013 ]
+ [ ct set mark with reg 1 ]
+
+# ct mark set 0x11
+ip test-ip4 output
+ [ immediate reg 1 0x00000011 ]
+ [ ct set mark with reg 1 ]
+
+# ct expiration 30
+ip test-ip4 output
+ [ ct load expiration => reg 1 ]
+ [ cmp eq reg 1 0x0000001e ]
+
+# ct expiration 22
+ip test-ip4 output
+ [ ct load expiration => reg 1 ]
+ [ cmp eq reg 1 0x00000016 ]
+
+# ct expiration != 233
+ip test-ip4 output
+ [ ct load expiration => reg 1 ]
+ [ cmp neq reg 1 0x000000e9 ]
+
+# ct expiration 33-45
+ip test-ip4 output
+ [ ct load expiration => reg 1 ]
+ [ byteorder reg 1 = hton(reg 1, 4, 4) ]
+ [ cmp gte reg 1 0x21000000 ]
+ [ cmp lte reg 1 0x2d000000 ]
+
+# ct expiration != 33-45
+ip test-ip4 output
+ [ ct load expiration => reg 1 ]
+ [ byteorder reg 1 = hton(reg 1, 4, 4) ]
+ [ cmp lt reg 1 0x21000000 ]
+ [ cmp gt reg 1 0x2d000000 ]
+
+# ct expiration {33, 55, 67, 88}
+set%d test-ip4 3
+set%d test-ip4 0
+ element 00000021 : 0 [end] element 00000037 : 0 [end] element 00000043 : 0 [end] element 00000058 : 0 [end]
+ip test-ip4 output
+ [ ct load expiration => reg 1 ]
+ [ lookup reg 1 set set%d ]
+
+# ct expiration {33-55}
+set%d test-ip4 7
+set%d test-ip4 0
+ element 00000000 : 1 [end] element 21000000 : 0 [end] element 38000000 : 1 [end]
+ip test-ip4 output
+ [ ct load expiration => reg 1 ]
+ [ byteorder reg 1 = hton(reg 1, 4, 4) ]
+ [ lookup reg 1 set set%d ]
+
+# ct helper "ftp"
+ip test-ip4 output
+ [ ct load helper => reg 1 ]
+ [ cmp eq reg 1 0x00707466 0x00000000 0x00000000 0x00000000 ]
+
+# ct state . ct mark { new . 0x12345678}
+set%d test 3
+set%d test 0
+ element 00000008 12345678 : 0 [end]
+ip test-ip4 output
+ [ ct load state => reg 1 ]
+ [ ct load mark => reg 9 ]
+ [ lookup reg 1 set set%d ]
+
+# ct state . ct mark { new . 0x12345678, new . 0x34127856, established . 0x12785634}
+set%d test-ip4 3
+set%d test-ip4 0
+ element 00000008 12345678 : 0 [end] element 00000008 34127856 : 0 [end] element 00000002 12785634 : 0 [end]
+ip test-ip4 output
+ [ ct load state => reg 1 ]
+ [ ct load mark => reg 9 ]
+ [ lookup reg 1 set set%d ]
+
+# ct direction . ct mark { original . 0x12345678}
+set%d test 3
+set%d test 0
+ element 00000000 12345678 : 0 [end]
+ip test-ip4 output
+ [ ct load direction => reg 1 ]
+ [ ct load mark => reg 9 ]
+ [ lookup reg 1 set set%d ]
+
+# ct state . ct mark vmap { new . 0x12345678 : drop}
+map%d test-ip4 b
+map%d test-ip4 0
+ element 00000008 12345678 : 0 [end]
+ip test-ip4 output
+ [ ct load state => reg 1 ]
+ [ ct load mark => reg 9 ]
+ [ lookup reg 1 set map%d dreg 0 ]
+