Add a couple of Python test-cases for setting the CT mark to a bitwise expression derived from the packet mark and vice versa. Signed-off-by: Jeremy Sowden <jeremy@xxxxxxxxxx> --- tests/py/any/ct.t | 1 + tests/py/any/ct.t.json | 28 ++++++++++++++++++++++++++++ tests/py/any/ct.t.payload | 21 +++++++++++++++++++++ tests/py/inet/meta.t | 1 + tests/py/inet/meta.t.json | 22 ++++++++++++++++++++++ tests/py/inet/meta.t.payload | 6 ++++++ 6 files changed, 79 insertions(+) diff --git a/tests/py/any/ct.t b/tests/py/any/ct.t index ebc086445567..f65d275987cd 100644 --- a/tests/py/any/ct.t +++ b/tests/py/any/ct.t @@ -57,6 +57,7 @@ ct mark set 0x11333 and 0x11;ok;ct mark set 0x00000011 ct mark set 0x12 or 0x11;ok;ct mark set 0x00000013 ct mark set 0x11;ok;ct mark set 0x00000011 ct mark set mark;ok;ct mark set meta mark +ct mark set (meta mark | 0x10) << 8;ok;ct mark set (meta mark | 0x00000010) << 8 ct mark set mark map { 1 : 10, 2 : 20, 3 : 30 };ok;ct mark set meta mark map { 0x00000003 : 0x0000001e, 0x00000002 : 0x00000014, 0x00000001 : 0x0000000a} ct mark set {0x11333, 0x11};fail diff --git a/tests/py/any/ct.t.json b/tests/py/any/ct.t.json index 8d56db2aaedb..59ac27c3055c 100644 --- a/tests/py/any/ct.t.json +++ b/tests/py/any/ct.t.json @@ -724,6 +724,34 @@ } ] +# ct mark set (meta mark | 0x10) << 8 +[ + { + "mangle": { + "key": { + "ct": { + "key": "mark" + } + }, + "value": { + "<<": [ + { + "|": [ + { + "meta": { + "key": "mark" + } + }, + 16 + ] + }, + 8 + ] + } + } + } +] + # ct mark set mark map { 1 : 10, 2 : 20, 3 : 30 } [ { diff --git a/tests/py/any/ct.t.payload b/tests/py/any/ct.t.payload index bdc6a70e3672..661591257804 100644 --- a/tests/py/any/ct.t.payload +++ b/tests/py/any/ct.t.payload @@ -329,6 +329,27 @@ ip test-ip4 output [ meta load mark => reg 1 ] [ ct set mark with reg 1 ] +# ct mark set (meta mark | 0x10) << 8 +ip test-ip4 output + [ meta load mark => reg 1 ] + [ bitwise reg 1 = (reg=1 & 0xffffffef ) ^ 0x00000010 ] + [ bitwise reg 1 = ( reg 1 << 0x00000008 ) ] + [ ct set mark with reg 1 ] + +# ct mark set (meta mark | 0x10) << 8 +ip6 test-ip6 output + [ meta load mark => reg 1 ] + [ bitwise reg 1 = (reg=1 & 0xffffffef ) ^ 0x00000010 ] + [ bitwise reg 1 = ( reg 1 << 0x00000008 ) ] + [ ct set mark with reg 1 ] + +# ct mark set (meta mark | 0x10) << 8 +inet test-inet output + [ meta load mark => reg 1 ] + [ bitwise reg 1 = (reg=1 & 0xffffffef ) ^ 0x00000010 ] + [ bitwise reg 1 = ( reg 1 << 0x00000008 ) ] + [ ct set mark with reg 1 ] + # ct mark set mark map { 1 : 10, 2 : 20, 3 : 30 } __map%d test-ip4 b __map%d test-ip4 0 diff --git a/tests/py/inet/meta.t b/tests/py/inet/meta.t index df32332f0621..3638898b5dbb 100644 --- a/tests/py/inet/meta.t +++ b/tests/py/inet/meta.t @@ -16,3 +16,4 @@ meta ipsec exists;ok meta secpath missing;ok;meta ipsec missing meta ibrname "br0";fail meta obrname "br0";fail +meta mark set ct mark >> 8;ok diff --git a/tests/py/inet/meta.t.json b/tests/py/inet/meta.t.json index 5501f0bec6ed..5c0e7d2e0e42 100644 --- a/tests/py/inet/meta.t.json +++ b/tests/py/inet/meta.t.json @@ -213,3 +213,25 @@ } ] +# meta mark set ct mark >> 8 +[ + { + "mangle": { + "key": { + "meta": { + "key": "mark" + } + }, + "value": { + ">>": [ + { + "ct": { + "key": "mark" + } + }, + 8 + ] + } + } + } +] diff --git a/tests/py/inet/meta.t.payload b/tests/py/inet/meta.t.payload index d7ff7e2d41fa..6ccf6d24210a 100644 --- a/tests/py/inet/meta.t.payload +++ b/tests/py/inet/meta.t.payload @@ -73,3 +73,9 @@ inet test-inet input inet test-inet input [ meta load secpath => reg 1 ] [ cmp eq reg 1 0x00000000 ] + +# meta mark set ct mark >> 8 +inet test-inet input + [ ct load mark => reg 1 ] + [ bitwise reg 1 = ( reg 1 >> 0x00000008 ) ] + [ meta set mark with reg 1 ] -- 2.24.1