net: display hw address of source machine during ipv6 DAD failure
authorVishwanath Pai <vpai@akamai.com>
Mon, 30 Oct 2017 23:38:52 +0000 (19:38 -0400)
committerDavid S. Miller <davem@davemloft.net>
Wed, 1 Nov 2017 11:53:49 +0000 (20:53 +0900)
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 2001:db8:: on eth0!

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

IPv6: eth0: IPv6 duplicate address 2001:db8:: used by 34:ab:cd:56:11:e8
detected!

v2:
    Changed %pI6 to %pI6c in ndisc_recv_na()
    Chaged the v6 address in the commit message to 2001:db8::

Suggested-by: Igor Lubashev <ilubashe@akamai.com>
Signed-off-by: Vishwanath Pai <vpai@akamai.com>
Acked-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/addrconf.h
net/ipv6/addrconf.c
net/ipv6/ndisc.c

index 15b5ffd7253d6088f2444ada5de99e4977e143ff..2a616ea53956058f9d7429965f6ec7fefa8b14f7 100644 (file)
@@ -208,7 +208,7 @@ void ipv6_mc_remap(struct inet6_dev *idev);
 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);
index 5a8a10229a07fe3d3f96b237e744332c192a509f..cfa374c8b54c1f2970a68aee365810bb1fe0ad25 100644 (file)
@@ -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);
 
index 266a530414d7be4f1e7be922e465bbab46f7cbac..f9c3ffe04382977773628a5b7e8111f437c3ae92 100644 (file)
@@ -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 @@ have_ifp:
                                 * 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 %pI6c on %s!\n",
+                                 eth_hdr(skb)->h_source, &ifp->addr, ifp->idev->dev->name);
                in6_ifa_put(ifp);
                return;
        }