Blame SOURCES/0058-arptables-nft-fix-decoding-of-hlen-on-bigendian-plat.patch

1dc35b
From dc38548e6f745bcfb141324b36307dbfa941eabd Mon Sep 17 00:00:00 2001
1dc35b
From: Florian Westphal <fw@strlen.de>
1dc35b
Date: Fri, 22 Feb 2019 13:26:05 +0100
1dc35b
Subject: [PATCH] arptables-nft: fix decoding of hlen on bigendian platforms
1dc35b
1dc35b
The existing test fail with:
1dc35b
extensions/libarpt_standard.t: ERROR: line 2 (cannot find: arptables -I INPUT -s 192.168.0.1)
1dc35b
1dc35b
... because hlen is 0 instead of expected "6".
1dc35b
The rule is correct, i.e. this is a decode/display bug: arp_hlen is
1dc35b
specified as 'unsigned short' instead of uint8_t.
1dc35b
1dc35b
On LSB systems, this doesn't matter but on MSB the value then is '0x600'
1dc35b
instead of '0x006' which becomes 0 when assignment to the u8 header field.
1dc35b
1dc35b
Signed-off-by: Florian Westphal <fw@strlen.de>
1dc35b
Acked-by: Phil Sutter <phil@nwl.cc>
1dc35b
(cherry picked from commit d68672a641439b72bccfcb39d50f26fe3f915c19)
1dc35b
Signed-off-by: Phil Sutter <psutter@redhat.com>
1dc35b
---
1dc35b
 iptables/nft-arp.c | 5 +++--
1dc35b
 1 file changed, 3 insertions(+), 2 deletions(-)
1dc35b
1dc35b
diff --git a/iptables/nft-arp.c b/iptables/nft-arp.c
1dc35b
index 37b0985377bef..b436570291b7c 100644
1dc35b
--- a/iptables/nft-arp.c
1dc35b
+++ b/iptables/nft-arp.c
1dc35b
@@ -338,7 +338,8 @@ static void nft_arp_parse_payload(struct nft_xt_ctx *ctx,
1dc35b
 	struct iptables_command_state *cs = data;
1dc35b
 	struct arpt_entry *fw = &cs->arp;
1dc35b
 	struct in_addr addr;
1dc35b
-	unsigned short int ar_hrd, ar_pro, ar_op, ar_hln;
1dc35b
+	uint16_t ar_hrd, ar_pro, ar_op;
1dc35b
+	uint8_t ar_hln;
1dc35b
 	bool inv;
1dc35b
 
1dc35b
 	switch (ctx->payload.offset) {
1dc35b
@@ -364,7 +365,7 @@ static void nft_arp_parse_payload(struct nft_xt_ctx *ctx,
1dc35b
 			fw->arp.invflags |= ARPT_INV_ARPOP;
1dc35b
 		break;
1dc35b
 	case offsetof(struct arphdr, ar_hln):
1dc35b
-		get_cmp_data(e, &ar_hln, sizeof(ar_op), &inv;;
1dc35b
+		get_cmp_data(e, &ar_hln, sizeof(ar_hln), &inv;;
1dc35b
 		fw->arp.arhln = ar_hln;
1dc35b
 		fw->arp.arhln_mask = 0xff;
1dc35b
 		if (inv)
1dc35b
-- 
1dc35b
2.21.0
1dc35b