97 lines
3.0 KiB
Diff
97 lines
3.0 KiB
Diff
From 4646703f6d8eb46355752ec033945405ca482d4e Mon Sep 17 00:00:00 2001
|
|
From: Ralf Baechle <ralf@linux-mips.org>
|
|
Date: Tue, 7 Feb 2017 22:10:51 +0100
|
|
Subject: [PATCH] arping: Fix ARP protocol field for AX.25 and NETROM
|
|
|
|
Conflict:NA
|
|
Reference:https://github.com/iputils/iputils/commit/4646703f6d8eb46355752ec033945405ca482d4e.patch
|
|
|
|
AX.25 and NETROM differ from other, more ethernet-like protocols in that
|
|
they are not using a DIX protocol number but the AX.25 PID. The arping code
|
|
doesn't handle this special case resulting in invalid ARP packets being sent.
|
|
|
|
The interface bpq0 is an AX.25-over-ethernet interface. Without this
|
|
fix:
|
|
|
|
# arping -c 1 -I bpq0 172.20.1.3
|
|
ARPING 172.20.1.3 from 172.20.1.2 bpq0
|
|
Sent 1 probes (1 broadcast(s))
|
|
Received 0 response(s)
|
|
|
|
With this fix:
|
|
|
|
# arping -c 1 -I bpq0 172.20.1.3
|
|
ARPING 172.20.1.3 from 172.20.1.2 bpq0
|
|
Unicast reply from 172.20.1.3 [88:98:60:A0:92:40:02] 1.402ms
|
|
Sent 1 probes (1 broadcast(s))
|
|
Received 1 response(s)
|
|
|
|
Closes: https://github.com/iputils/iputils/pull/360
|
|
|
|
Reviewed-by: Petr Vorel <pvorel@suse.cz>
|
|
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
|
|
[ pvorel: add new lines for readability ]
|
|
Signed-off-by: Petr Vorel <pvorel@suse.cz>
|
|
---
|
|
arping.c | 32 +++++++++++++++++++++++++++++---
|
|
1 file changed, 29 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/arping.c b/arping.c
|
|
index 53fdbb48..5df6d9f0 100644
|
|
--- a/arping.c
|
|
+++ b/arping.c
|
|
@@ -37,6 +37,14 @@
|
|
|
|
#include "iputils_common.h"
|
|
|
|
+/*
|
|
+ * As of July 2021 AX.25 PID values are not currently defined in any
|
|
+ * userspace headers.
|
|
+ */
|
|
+#ifndef AX25_P_IP
|
|
+# define AX25_P_IP 0xcc /* ARPA Internet Protocol */
|
|
+#endif
|
|
+
|
|
#ifdef DEFAULT_DEVICE
|
|
# define DEFAULT_DEVICE_STR DEFAULT_DEVICE
|
|
#else
|
|
@@ -248,7 +256,17 @@ static int send_pack(struct run_state *ctl)
|
|
ah->ar_hrd = htons(ME->sll_hatype);
|
|
if (ah->ar_hrd == htons(ARPHRD_FDDI))
|
|
ah->ar_hrd = htons(ARPHRD_ETHER);
|
|
- ah->ar_pro = htons(ETH_P_IP);
|
|
+
|
|
+ /*
|
|
+ * Exceptions everywhere. AX.25 uses the AX.25 PID value not the
|
|
+ * DIX code for the protocol. Make these device structure fields.
|
|
+ */
|
|
+ if (ah->ar_hrd == htons(ARPHRD_AX25) ||
|
|
+ ah->ar_hrd == htons(ARPHRD_NETROM))
|
|
+ ah->ar_pro = htons(AX25_P_IP);
|
|
+ else
|
|
+ ah->ar_pro = htons(ETH_P_IP);
|
|
+
|
|
ah->ar_hln = ME->sll_halen;
|
|
ah->ar_pln = 4;
|
|
ah->ar_op = ctl->advert ? htons(ARPOP_REPLY) : htons(ARPOP_REQUEST);
|
|
@@ -341,9 +359,17 @@ static int recv_pack(struct run_state *ctl, unsigned char *buf, ssize_t len,
|
|
(FROM->sll_hatype != ARPHRD_FDDI || ah->ar_hrd != htons(ARPHRD_ETHER)))
|
|
return 0;
|
|
|
|
- /* Protocol must be IP. */
|
|
- if (ah->ar_pro != htons(ETH_P_IP))
|
|
+ /*
|
|
+ * Protocol must be IP - but exceptions everywhere. AX.25 and NETROM
|
|
+ * use the AX.25 PID value not the DIX code for the protocol.
|
|
+ */
|
|
+ if (ah->ar_hrd == htons(ARPHRD_AX25) ||
|
|
+ ah->ar_hrd == htons(ARPHRD_NETROM)) {
|
|
+ if (ah->ar_pro != htons(AX25_P_IP))
|
|
+ return 0;
|
|
+ } else if (ah->ar_pro != htons(ETH_P_IP))
|
|
return 0;
|
|
+
|
|
if (ah->ar_pln != 4)
|
|
return 0;
|
|
if (ah->ar_hln != ((struct sockaddr_ll *)&ctl->me)->sll_halen)
|