From ca12e455e98fb4247e0aa4c2d361195038debe65 Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Mon, 17 Jun 2019 11:55:42 +0200 Subject: datatype: fix print of raw numerical symbol values The two rules: arp operation 1-2 accept arp operation 256-512 accept are both shown as 256-512: chain in_public { arp operation 256-512 accept arp operation 256-512 accept meta mark "1" tcp flags 2,4 } This is because range expression enforces numeric output, yet nft_print doesn't respect byte order. Behave as if we had no symbol in the first place and call the base type print function instead. This means we now respect format specifier as well: chain in_public { arp operation 1-2 accept arp operation 256-512 accept meta mark 0x00000001 tcp flags 0x2,0x4 } Without fix, added test case will fail: 'add rule arp test-arp input arp operation 1-2': 'arp operation 1-2' mismatches 'arp operation 256-512' v2: in case of -n, also elide quotation marks, just as if we would not have found a symbolic name. Signed-off-by: Florian Westphal Acked-by: Pablo Neira Ayuso --- tests/py/arp/arp.t | 1 + tests/py/arp/arp.t.payload | 6 ++++++ tests/py/arp/arp.t.payload.netdev | 8 ++++++++ 3 files changed, 15 insertions(+) (limited to 'tests/py/arp') diff --git a/tests/py/arp/arp.t b/tests/py/arp/arp.t index 86bab523..2540c0a7 100644 --- a/tests/py/arp/arp.t +++ b/tests/py/arp/arp.t @@ -38,6 +38,7 @@ arp plen != {33-55};ok arp operation {nak, inreply, inrequest, rreply, rrequest, reply, request};ok arp operation != {nak, inreply, inrequest, rreply, rrequest, reply, request};ok +arp operation 1-2;ok arp operation request;ok arp operation reply;ok arp operation rrequest;ok diff --git a/tests/py/arp/arp.t.payload b/tests/py/arp/arp.t.payload index d36bef18..52c99329 100644 --- a/tests/py/arp/arp.t.payload +++ b/tests/py/arp/arp.t.payload @@ -188,6 +188,12 @@ arp test-arp input [ payload load 2b @ network header + 6 => reg 1 ] [ lookup reg 1 set __set%d 0x1 ] +# arp operation 1-2 +arp test-arp input + [ payload load 2b @ network header + 6 => reg 1 ] + [ cmp gte reg 1 0x00000100 ] + [ cmp lte reg 1 0x00000200 ] + # arp operation request arp test-arp input [ payload load 2b @ network header + 6 => reg 1 ] diff --git a/tests/py/arp/arp.t.payload.netdev b/tests/py/arp/arp.t.payload.netdev index 0146cf50..667691ff 100644 --- a/tests/py/arp/arp.t.payload.netdev +++ b/tests/py/arp/arp.t.payload.netdev @@ -246,6 +246,14 @@ netdev test-netdev ingress [ payload load 2b @ network header + 6 => reg 1 ] [ lookup reg 1 set __set%d 0x1 ] +# arp operation 1-2 +netdev test-netdev ingress + [ meta load protocol => reg 1 ] + [ cmp eq reg 1 0x00000608 ] + [ payload load 2b @ network header + 6 => reg 1 ] + [ cmp gte reg 1 0x00000100 ] + [ cmp lte reg 1 0x00000200 ] + # arp operation request netdev test-netdev ingress [ meta load protocol => reg 1 ] -- cgit v1.2.3