From f751753f92ea76f582f7d5d1fef8b4d5677ba589 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Tue, 10 Nov 2020 13:07:49 +0100 Subject: proto: Fix ARP header field ordering In ARP header, destination ether address sits between source IP and destination IP addresses. Enum arp_hdr_fields had this wrong, which in turn caused wrong ordering of entries in proto_arp->templates. When expanding a combined payload expression, code assumes that template entries are ordered by header offset, therefore the destination ether address match was printed as raw if an earlier field was matched as well: | arp saddr ip 192.168.1.1 arp daddr ether 3e:d1:3f:d6:12:0b was printed as: | arp saddr ip 192.168.1.1 @nh,144,48 69068440080907 Note: Although strictly not necessary, reorder fields in proto_arp->templates as well to match their actual ordering, just to avoid confusion. Fixes: 4b0f2a712b579 ("src: support for arp sender and target ethernet and IPv4 addresses") Signed-off-by: Phil Sutter --- tests/py/arp/arp.t.payload | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/py/arp/arp.t.payload') diff --git a/tests/py/arp/arp.t.payload b/tests/py/arp/arp.t.payload index 52c99329..f819853f 100644 --- a/tests/py/arp/arp.t.payload +++ b/tests/py/arp/arp.t.payload @@ -307,3 +307,13 @@ arp test-arp input [ payload load 6b @ network header + 18 => reg 1 ] [ cmp eq reg 1 0xaaccbbaa 0x0000ccbb ] +# arp saddr ip 192.168.1.1 arp daddr ether fe:ed:00:c0:ff:ee +arp + [ payload load 10b @ network header + 14 => reg 1 ] + [ cmp eq reg 1 0x0101a8c0 0xc000edfe 0x0000eeff ] + +# arp daddr ether fe:ed:00:c0:ff:ee arp saddr ip 192.168.1.1 +arp + [ payload load 10b @ network header + 14 => reg 1 ] + [ cmp eq reg 1 0x0101a8c0 0xc000edfe 0x0000eeff ] + -- cgit v1.2.3