]> git.ipfire.org Git - thirdparty/nftables.git/commit
proto: Fix ARP header field ordering
authorPhil Sutter <phil@nwl.cc>
Tue, 10 Nov 2020 12:07:49 +0000 (13:07 +0100)
committerPhil Sutter <phil@nwl.cc>
Tue, 10 Nov 2020 13:26:19 +0000 (14:26 +0100)
commitf751753f92ea76f582f7d5d1fef8b4d5677ba589
treebf0e39109ec9e30c92534040ad41680cb60a8bd2
parent0f0e5b412804aa18fd18434fb0db360b98a76bf8
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 <phil@nwl.cc>
include/proto.h
src/proto.c
tests/py/arp/arp.t
tests/py/arp/arp.t.json
tests/py/arp/arp.t.json.output
tests/py/arp/arp.t.payload
tests/py/arp/arp.t.payload.netdev