Skip to content

Commit da13c59

Browse files
vpai-akamaidavem330
authored andcommitted
net: display hw address of source machine during ipv6 DAD failure
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>
1 parent cdb583c commit da13c59

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

‎include/net/addrconf.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ void ipv6_mc_remap(struct inet6_dev *idev);
208208
void ipv6_mc_init_dev(struct inet6_dev *idev);
209209
void ipv6_mc_destroy_dev(struct inet6_dev *idev);
210210
int ipv6_mc_check_mld(struct sk_buff *skb, struct sk_buff **skb_trimmed);
211-
void addrconf_dad_failure(struct inet6_ifaddr *ifp);
211+
void addrconf_dad_failure(struct sk_buff *skb, struct inet6_ifaddr *ifp);
212212

213213
bool ipv6_chk_mcast_addr(struct net_device *dev, const struct in6_addr *group,
214214
const struct in6_addr *src_addr);

‎net/ipv6/addrconf.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,7 +1987,7 @@ static int addrconf_dad_end(struct inet6_ifaddr *ifp)
19871987
return err;
19881988
}
19891989

1990-
void addrconf_dad_failure(struct inet6_ifaddr *ifp)
1990+
void addrconf_dad_failure(struct sk_buff *skb, struct inet6_ifaddr *ifp)
19911991
{
19921992
struct inet6_dev *idev = ifp->idev;
19931993
struct net *net = dev_net(ifp->idev->dev);
@@ -1997,8 +1997,8 @@ void addrconf_dad_failure(struct inet6_ifaddr *ifp)
19971997
return;
19981998
}
19991999

2000-
net_info_ratelimited("%s: IPv6 duplicate address %pI6c detected!\n",
2001-
ifp->idev->dev->name, &ifp->addr);
2000+
net_info_ratelimited("%s: IPv6 duplicate address %pI6c used by %pM detected!\n",
2001+
ifp->idev->dev->name, &ifp->addr, eth_hdr(skb)->h_source);
20022002

20032003
spin_lock_bh(&ifp->lock);
20042004

‎net/ipv6/ndisc.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#endif
4747

4848
#include <linux/if_addr.h>
49+
#include <linux/if_ether.h>
4950
#include <linux/if_arp.h>
5051
#include <linux/ipv6.h>
5152
#include <linux/icmpv6.h>
@@ -822,7 +823,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
822823
* who is doing DAD
823824
* so fail our DAD process
824825
*/
825-
addrconf_dad_failure(ifp);
826+
addrconf_dad_failure(skb, ifp);
826827
return;
827828
} else {
828829
/*
@@ -975,7 +976,7 @@ static void ndisc_recv_na(struct sk_buff *skb)
975976
if (ifp) {
976977
if (skb->pkt_type != PACKET_LOOPBACK
977978
&& (ifp->flags & IFA_F_TENTATIVE)) {
978-
addrconf_dad_failure(ifp);
979+
addrconf_dad_failure(skb, ifp);
979980
return;
980981
}
981982
/* What should we make now? The advertisement
@@ -989,8 +990,8 @@ static void ndisc_recv_na(struct sk_buff *skb)
989990
*/
990991
if (skb->pkt_type != PACKET_LOOPBACK)
991992
ND_PRINTK(1, warn,
992-
"NA: someone advertises our address %pI6 on %s!\n",
993-
&ifp->addr, ifp->idev->dev->name);
993+
"NA: %pM advertised our address %pI6c on %s!\n",
994+
eth_hdr(skb)->h_source, &ifp->addr, ifp->idev->dev->name);
994995
in6_ifa_put(ifp);
995996
return;
996997
}

0 commit comments

Comments
 (0)