2019-08-20 15:20:50

by Dongxu Liu

[permalink] [raw]
Subject: [PATCH] net: Fix detection for IPv4 duplicate address.

The network sends an ARP REQUEST packet to determine
whether there is a host with the same IP.
The source IP address of the packet is 0.
However, Windows may also send the source IP address
to determine, then the source IP address is equal to
the destination IP address.

Signed-off-by: Dongxu Liu <[email protected]>
---
net/ipv4/arp.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 05eb42f..944f8e8 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -800,8 +800,11 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
iptunnel_metadata_reply(skb_metadata_dst(skb),
GFP_ATOMIC);

- /* Special case: IPv4 duplicate address detection packet (RFC2131) */
- if (sip == 0) {
+/* Special case: IPv4 duplicate address detection packet (RFC2131).
+ * Linux usually sends zero to detect duplication, and windows may
+ * send a same ip (not zero, sip equal to tip) to do this detection.
+ */
+ if (sip == 0 || sip == tip) {
if (arp->ar_op == htons(ARPOP_REQUEST) &&
inet_addr_type_dev_table(net, dev, tip) == RTN_LOCAL &&
!arp_ignore(in_dev, sip, tip))
--
2.12.3



2019-08-20 20:59:08

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] net: Fix detection for IPv4 duplicate address.

From: Dongxu Liu <[email protected]>
Date: Tue, 20 Aug 2019 23:19:05 +0800

> @@ -800,8 +800,11 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
> iptunnel_metadata_reply(skb_metadata_dst(skb),
> GFP_ATOMIC);
>
> - /* Special case: IPv4 duplicate address detection packet (RFC2131) */
> - if (sip == 0) {
> +/* Special case: IPv4 duplicate address detection packet (RFC2131).
> + * Linux usually sends zero to detect duplication, and windows may
> + * send a same ip (not zero, sip equal to tip) to do this detection.
> + */
> + if (sip == 0 || sip == tip) {

Regardless of whether this is a valid change or not, you've unindented the
comment which is completely inappropriate.