Cover a named map with concatenated key as right-hand and left-hand operand of bitwise operations on the packet mark. Signed-off-by: Jochen Seeber --- tests/py/ip/sets.t | 2 + tests/py/ip/sets.t.json | 91 +++++++++++++++++++++++++++++++ tests/py/ip/sets.t.payload.inet | 23 ++++++++ tests/py/ip/sets.t.payload.ip | 19 +++++++ tests/py/ip/sets.t.payload.netdev | 23 ++++++++ 5 files changed, 158 insertions(+) diff --git a/tests/py/ip/sets.t b/tests/py/ip/sets.t index ad2c8316..8bbbb368 100644 --- a/tests/py/ip/sets.t +++ b/tests/py/ip/sets.t @@ -54,6 +54,8 @@ add @set5 { ip saddr . ip daddr };ok !map1 type ipv4_addr . ipv4_addr : mark;ok add @map1 { ip saddr . ip daddr : meta mark };ok +meta mark set meta mark & 0xffffff80 | (ip saddr . ip daddr map @map1);ok +meta mark set (ip saddr . ip daddr map @map1) ^ meta mark;ok # test nested anonymous sets ip saddr { { 1.1.1.0, 3.3.3.0 }, 2.2.2.0 };ok;ip saddr { 1.1.1.0, 2.2.2.0, 3.3.3.0 } diff --git a/tests/py/ip/sets.t.json b/tests/py/ip/sets.t.json index f2637d93..04ce11b4 100644 --- a/tests/py/ip/sets.t.json +++ b/tests/py/ip/sets.t.json @@ -303,6 +303,97 @@ } ] +# meta mark set meta mark & 0xffffff80 | (ip saddr . ip daddr map @map1) +[ + { + "mangle": { + "key": { + "meta": { + "key": "mark" + } + }, + "value": { + "|": [ + { + "&": [ + { + "meta": { + "key": "mark" + } + }, + 4294967168 + ] + }, + { + "map": { + "data": "@map1", + "key": { + "concat": [ + { + "payload": { + "field": "saddr", + "protocol": "ip" + } + }, + { + "payload": { + "field": "daddr", + "protocol": "ip" + } + } + ] + } + } + } + ] + } + } + } +] + +# meta mark set (ip saddr . ip daddr map @map1) ^ meta mark +[ + { + "mangle": { + "key": { + "meta": { + "key": "mark" + } + }, + "value": { + "^": [ + { + "map": { + "data": "@map1", + "key": { + "concat": [ + { + "payload": { + "field": "saddr", + "protocol": "ip" + } + }, + { + "payload": { + "field": "daddr", + "protocol": "ip" + } + } + ] + } + } + }, + { + "meta": { + "key": "mark" + } + } + ] + } + } + } +] + # add @map2 { ip saddr . ip daddr . th dport : 10.0.0.1 . 80 } [ { diff --git a/tests/py/ip/sets.t.payload.inet b/tests/py/ip/sets.t.payload.inet index de8182e0..ceed8564 100644 --- a/tests/py/ip/sets.t.payload.inet +++ b/tests/py/ip/sets.t.payload.inet @@ -84,6 +84,29 @@ inet test-inet input [ meta load mark => reg 10 ] [ dynset add reg_key 1 set map1 sreg_data 10 ] +# meta mark set meta mark & 0xffffff80 | (ip saddr . ip daddr map @map1) +inet test-inet input + [ meta load nfproto => reg 1 ] + [ cmp eq reg 1 0x02 ] + [ meta load mark => reg 1 ] + [ bitwise reg 1 = ( reg 1 & 0xffffff80 ) ^ 0x00000000 ] + [ payload load 4b @ network header + 12 => reg 2 ] + [ payload load 4b @ network header + 16 => reg 13 ] + [ lookup reg 2 set map1 dreg 2 ] + [ bitwise reg 1 = ( reg 1 | reg 2 ) ] + [ meta set mark with reg 1 ] + +# meta mark set (ip saddr . ip daddr map @map1) ^ meta mark +inet test-inet input + [ meta load nfproto => reg 1 ] + [ cmp eq reg 1 0x02 ] + [ payload load 4b @ network header + 12 => reg 1 ] + [ payload load 4b @ network header + 16 => reg 9 ] + [ lookup reg 1 set map1 dreg 1 ] + [ meta load mark => reg 2 ] + [ bitwise reg 1 = ( reg 1 ^ reg 2 ) ] + [ meta set mark with reg 1 ] + # ip saddr vmap { 1.1.1.1 : drop, * : accept } __map%d test-inet b __map%d test-inet 0 diff --git a/tests/py/ip/sets.t.payload.ip b/tests/py/ip/sets.t.payload.ip index 95713370..38a1c0f6 100644 --- a/tests/py/ip/sets.t.payload.ip +++ b/tests/py/ip/sets.t.payload.ip @@ -81,6 +81,25 @@ ip test-ip4 input [ meta load mark => reg 10 ] [ dynset add reg_key 1 set map1 sreg_data 10 ] +# meta mark set meta mark & 0xffffff80 | (ip saddr . ip daddr map @map1) +ip test-ip4 input + [ meta load mark => reg 1 ] + [ bitwise reg 1 = ( reg 1 & 0xffffff80 ) ^ 0x00000000 ] + [ payload load 4b @ network header + 12 => reg 2 ] + [ payload load 4b @ network header + 16 => reg 13 ] + [ lookup reg 2 set map1 dreg 2 ] + [ bitwise reg 1 = ( reg 1 | reg 2 ) ] + [ meta set mark with reg 1 ] + +# meta mark set (ip saddr . ip daddr map @map1) ^ meta mark +ip test-ip4 input + [ payload load 4b @ network header + 12 => reg 1 ] + [ payload load 4b @ network header + 16 => reg 9 ] + [ lookup reg 1 set map1 dreg 1 ] + [ meta load mark => reg 2 ] + [ bitwise reg 1 = ( reg 1 ^ reg 2 ) ] + [ meta set mark with reg 1 ] + # add @map2 { ip saddr . ip daddr . th dport : 10.0.0.1 . 80 } ip test-ip4 input [ payload load 4b @ network header + 12 => reg 1 ] diff --git a/tests/py/ip/sets.t.payload.netdev b/tests/py/ip/sets.t.payload.netdev index 66e20fa9..cc45b2e5 100644 --- a/tests/py/ip/sets.t.payload.netdev +++ b/tests/py/ip/sets.t.payload.netdev @@ -105,6 +105,29 @@ netdev test-netdev ingress [ meta load mark => reg 10 ] [ dynset add reg_key 1 set map1 sreg_data 10 ] +# meta mark set meta mark & 0xffffff80 | (ip saddr . ip daddr map @map1) +netdev test-netdev ingress + [ meta load protocol => reg 1 ] + [ cmp eq reg 1 0x0800 ] + [ meta load mark => reg 1 ] + [ bitwise reg 1 = ( reg 1 & 0xffffff80 ) ^ 0x00000000 ] + [ payload load 4b @ network header + 12 => reg 2 ] + [ payload load 4b @ network header + 16 => reg 13 ] + [ lookup reg 2 set map1 dreg 2 ] + [ bitwise reg 1 = ( reg 1 | reg 2 ) ] + [ meta set mark with reg 1 ] + +# meta mark set (ip saddr . ip daddr map @map1) ^ meta mark +netdev test-netdev ingress + [ meta load protocol => reg 1 ] + [ cmp eq reg 1 0x0800 ] + [ payload load 4b @ network header + 12 => reg 1 ] + [ payload load 4b @ network header + 16 => reg 9 ] + [ lookup reg 1 set map1 dreg 1 ] + [ meta load mark => reg 2 ] + [ bitwise reg 1 = ( reg 1 ^ reg 2 ) ] + [ meta set mark with reg 1 ] + # add @map2 { ip saddr . ip daddr . th dport : 10.0.0.1 . 80 } netdev test-netdev ingress [ meta load protocol => reg 1 ] -- 2.56.0