All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: display hw address of source machine during ipv6 DAD failure
@ 2017-10-30 20:29 Vishwanath Pai
  2017-10-30 20:43 ` David Ahern
  0 siblings, 1 reply; 4+ messages in thread
From: Vishwanath Pai @ 2017-10-30 20:29 UTC (permalink / raw)
  To: yoshfuji, kuznet, davem; +Cc: netdev, ilubashe, pai.vishwain

This patch updates the error messages displayed in kernel log to include
hwaddress of the source machine that caused ipv6 duplicate address
detection failures.

Examples:

a) When we receive a NA packet from another machine advertising our
address:

ICMPv6: NA: 34:ab:cd:56:11:e8 advertised our address 2601::2bb4 on eth0!

b) When we detect DAD failure during address assignment to an interface:

IPv6: eth0: IPv6 duplicate address 2601::2b78 used by 34:ab:cd:56:11:e8
detected!

Suggested-by: Igor Lubashev <ilubashe@akamai.com>
Signed-off-by: Vishwanath Pai <vpai@akamai.com>
---
 include/net/addrconf.h | 2 +-
 net/ipv6/addrconf.c    | 6 +++---
 net/ipv6/ndisc.c       | 9 +++++----
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index 15b5ffd..2a616ea 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -208,7 +208,7 @@ bool inet6_mc_check(struct sock *sk, const struct in6_addr *mc_addr,
 void ipv6_mc_init_dev(struct inet6_dev *idev);
 void ipv6_mc_destroy_dev(struct inet6_dev *idev);
 int ipv6_mc_check_mld(struct sk_buff *skb, struct sk_buff **skb_trimmed);
-void addrconf_dad_failure(struct inet6_ifaddr *ifp);
+void addrconf_dad_failure(struct sk_buff *skb, struct inet6_ifaddr *ifp);
 
 bool ipv6_chk_mcast_addr(struct net_device *dev, const struct in6_addr *group,
 			 const struct in6_addr *src_addr);
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 5a8a102..cfa374c 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1987,7 +1987,7 @@ static int addrconf_dad_end(struct inet6_ifaddr *ifp)
 	return err;
 }
 
-void addrconf_dad_failure(struct inet6_ifaddr *ifp)
+void addrconf_dad_failure(struct sk_buff *skb, struct inet6_ifaddr *ifp)
 {
 	struct inet6_dev *idev = ifp->idev;
 	struct net *net = dev_net(ifp->idev->dev);
@@ -1997,8 +1997,8 @@ void addrconf_dad_failure(struct inet6_ifaddr *ifp)
 		return;
 	}
 
-	net_info_ratelimited("%s: IPv6 duplicate address %pI6c detected!\n",
-			     ifp->idev->dev->name, &ifp->addr);
+	net_info_ratelimited("%s: IPv6 duplicate address %pI6c used by %pM detected!\n",
+			     ifp->idev->dev->name, &ifp->addr, eth_hdr(skb)->h_source);
 
 	spin_lock_bh(&ifp->lock);
 
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 266a530..9d6ea9d 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -46,6 +46,7 @@
 #endif
 
 #include <linux/if_addr.h>
+#include <linux/if_ether.h>
 #include <linux/if_arp.h>
 #include <linux/ipv6.h>
 #include <linux/icmpv6.h>
@@ -822,7 +823,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
 				 * who is doing DAD
 				 * so fail our DAD process
 				 */
-				addrconf_dad_failure(ifp);
+				addrconf_dad_failure(skb, ifp);
 				return;
 			} else {
 				/*
@@ -975,7 +976,7 @@ static void ndisc_recv_na(struct sk_buff *skb)
 	if (ifp) {
 		if (skb->pkt_type != PACKET_LOOPBACK
 		    && (ifp->flags & IFA_F_TENTATIVE)) {
-				addrconf_dad_failure(ifp);
+				addrconf_dad_failure(skb, ifp);
 				return;
 		}
 		/* What should we make now? The advertisement
@@ -989,8 +990,8 @@ static void ndisc_recv_na(struct sk_buff *skb)
 		 */
 		if (skb->pkt_type != PACKET_LOOPBACK)
 			ND_PRINTK(1, warn,
-				  "NA: someone advertises our address %pI6 on %s!\n",
-				  &ifp->addr, ifp->idev->dev->name);
+				  "NA: %pM advertised our address %pI6 on %s!\n",
+				  eth_hdr(skb)->h_source, &ifp->addr, ifp->idev->dev->name);
 		in6_ifa_put(ifp);
 		return;
 	}
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: display hw address of source machine during ipv6 DAD failure
  2017-10-30 20:29 [PATCH net-next] net: display hw address of source machine during ipv6 DAD failure Vishwanath Pai
@ 2017-10-30 20:43 ` David Ahern
  2017-10-30 20:50   ` Vishwanath Pai
  0 siblings, 1 reply; 4+ messages in thread
From: David Ahern @ 2017-10-30 20:43 UTC (permalink / raw)
  To: Vishwanath Pai, yoshfuji, kuznet, davem; +Cc: netdev, ilubashe, pai.vishwain

On 10/30/17 2:29 PM, Vishwanath Pai wrote:
> This patch updates the error messages displayed in kernel log to include
> hwaddress of the source machine that caused ipv6 duplicate address
> detection failures.
> 
> Examples:
> 
> a) When we receive a NA packet from another machine advertising our
> address:
> 
> ICMPv6: NA: 34:ab:cd:56:11:e8 advertised our address 2601::2bb4 on eth0!

your example above does not agree with the format below. You have the
compressed IPv6 address, yet the format ...

> 
> b) When we detect DAD failure during address assignment to an interface:
> 
> IPv6: eth0: IPv6 duplicate address 2601::2b78 used by 34:ab:cd:56:11:e8
> detected!
> 
> Suggested-by: Igor Lubashev <ilubashe@akamai.com>
> Signed-off-by: Vishwanath Pai <vpai@akamai.com>
> ---


> @@ -989,8 +990,8 @@ static void ndisc_recv_na(struct sk_buff *skb)
>  		 */
>  		if (skb->pkt_type != PACKET_LOOPBACK)
>  			ND_PRINTK(1, warn,
> -				  "NA: someone advertises our address %pI6 on %s!\n",
> -				  &ifp->addr, ifp->idev->dev->name);
> +				  "NA: %pM advertised our address %pI6 on %s!\n",

... is uncompressed. Please make that '%pI6c' instead of pI6 in the line
above


> +				  eth_hdr(skb)->h_source, &ifp->addr, ifp->idev->dev->name);
>  		in6_ifa_put(ifp);
>  		return;
>  	}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: display hw address of source machine during ipv6 DAD failure
  2017-10-30 20:43 ` David Ahern
@ 2017-10-30 20:50   ` Vishwanath Pai
  2017-10-30 20:53     ` David Ahern
  0 siblings, 1 reply; 4+ messages in thread
From: Vishwanath Pai @ 2017-10-30 20:50 UTC (permalink / raw)
  To: David Ahern, yoshfuji, kuznet, davem; +Cc: netdev, ilubashe, pai.vishwain

On 10/30/2017 04:43 PM, David Ahern wrote:
> On 10/30/17 2:29 PM, Vishwanath Pai wrote:
>> This patch updates the error messages displayed in kernel log to include
>> hwaddress of the source machine that caused ipv6 duplicate address
>> detection failures.
>>
>> Examples:
>>
>> a) When we receive a NA packet from another machine advertising our
>> address:
>>
>> ICMPv6: NA: 34:ab:cd:56:11:e8 advertised our address 2601::2bb4 on eth0!
> 
> your example above does not agree with the format below. You have the
> compressed IPv6 address, yet the format ...
> 
>>
>> b) When we detect DAD failure during address assignment to an interface:
>>
>> IPv6: eth0: IPv6 duplicate address 2601::2b78 used by 34:ab:cd:56:11:e8
>> detected!
>>
>> Suggested-by: Igor Lubashev <ilubashe@akamai.com>
>> Signed-off-by: Vishwanath Pai <vpai@akamai.com>
>> ---
> 
> 
>> @@ -989,8 +990,8 @@ static void ndisc_recv_na(struct sk_buff *skb)
>>  		 */
>>  		if (skb->pkt_type != PACKET_LOOPBACK)
>>  			ND_PRINTK(1, warn,
>> -				  "NA: someone advertises our address %pI6 on %s!\n",
>> -				  &ifp->addr, ifp->idev->dev->name);
>> +				  "NA: %pM advertised our address %pI6 on %s!\n",
> 
> ... is uncompressed. Please make that '%pI6c' instead of pI6 in the line
> above
> 
> 
>> +				  eth_hdr(skb)->h_source, &ifp->addr, ifp->idev->dev->name);
>>  		in6_ifa_put(ifp);
>>  		return;
>>  	}
> 
> 
> 

It does print out the full uncompressed IPv6 address. I modified the
message manually by hand while copying it out to the commit message in
order to hide the real IP address of my machines, but did not realize
that it was different from what the kernel would actually print out.

-Vishwanath

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: display hw address of source machine during ipv6 DAD failure
  2017-10-30 20:50   ` Vishwanath Pai
@ 2017-10-30 20:53     ` David Ahern
  0 siblings, 0 replies; 4+ messages in thread
From: David Ahern @ 2017-10-30 20:53 UTC (permalink / raw)
  To: Vishwanath Pai, yoshfuji, kuznet, davem; +Cc: netdev, ilubashe, pai.vishwain

On 10/30/17 2:50 PM, Vishwanath Pai wrote:
> It does print out the full uncompressed IPv6 address. I modified the
> message manually by hand while copying it out to the commit message in
> order to hide the real IP address of my machines, but did not realize
> that it was different from what the kernel would actually print out.

use 2001:db8::/32 (https://tools.ietf.org/html/rfc3849)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-10-30 20:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-30 20:29 [PATCH net-next] net: display hw address of source machine during ipv6 DAD failure Vishwanath Pai
2017-10-30 20:43 ` David Ahern
2017-10-30 20:50   ` Vishwanath Pai
2017-10-30 20:53     ` David Ahern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.