aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Manning <mmanning@brocade.com>2016-08-18 09:39:40 -0400
committerDavid S. Miller <davem@davemloft.net>2016-08-22 19:59:37 -0400
commit85b51b12115c79cce7ea1ced6c0bd0339a165d3f (patch)
tree83e26c4a5944f6b7e27f73ba3dedcc3cd50b0a20
parent53dc65d4d33c422d086c9d9ad8c03ab400ffc0a1 (diff)
net: ipv6: Remove addresses for failures with strict DAD
If DAD fails with accept_dad set to 2, global addresses and host routes are incorrectly left in place. Even though disable_ipv6 is set, contrary to documentation, the addresses are not dynamically deleted from the interface. It is only on a subsequent link down/up that these are removed. The fix is not only to set the disable_ipv6 flag, but also to call addrconf_ifdown(), which is the action to carry out when disabling IPv6. This results in the addresses and routes being deleted immediately. The DAD failure for the LL addr is determined as before via netlink, or by the absence of the LL addr (which also previously would have had to be checked for in case of an intervening link down and up). As the call to addrconf_ifdown() requires an rtnl lock, the logic to disable IPv6 when DAD fails is moved to addrconf_dad_work(). Previous behavior: root@vm1:/# sysctl net.ipv6.conf.eth3.accept_dad=2 net.ipv6.conf.eth3.accept_dad = 2 root@vm1:/# ip -6 addr add 2000::10/64 dev eth3 root@vm1:/# ip link set up eth3 root@vm1:/# ip -6 addr show dev eth3 5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000 inet6 2000::10/64 scope global valid_lft forever preferred_lft forever inet6 fe80::5054:ff:fe43:dd5a/64 scope link tentative dadfailed valid_lft forever preferred_lft forever root@vm1:/# ip -6 route show dev eth3 2000::/64 proto kernel metric 256 fe80::/64 proto kernel metric 256 root@vm1:/# ip link set down eth3 root@vm1:/# ip link set up eth3 root@vm1:/# ip -6 addr show dev eth3 root@vm1:/# ip -6 route show dev eth3 root@vm1:/# New behavior: root@vm1:/# sysctl net.ipv6.conf.eth3.accept_dad=2 net.ipv6.conf.eth3.accept_dad = 2 root@vm1:/# ip -6 addr add 2000::10/64 dev eth3 root@vm1:/# ip link set up eth3 root@vm1:/# ip -6 addr show dev eth3 root@vm1:/# ip -6 route show dev eth3 root@vm1:/# Signed-off-by: Mike Manning <mmanning@brocade.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv6/addrconf.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index df8425fcbc2c..f418d2eaeddd 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1872,7 +1872,6 @@ static int addrconf_dad_end(struct inet6_ifaddr *ifp)
1872 1872
1873void addrconf_dad_failure(struct inet6_ifaddr *ifp) 1873void addrconf_dad_failure(struct inet6_ifaddr *ifp)
1874{ 1874{
1875 struct in6_addr addr;
1876 struct inet6_dev *idev = ifp->idev; 1875 struct inet6_dev *idev = ifp->idev;
1877 struct net *net = dev_net(ifp->idev->dev); 1876 struct net *net = dev_net(ifp->idev->dev);
1878 1877
@@ -1934,18 +1933,6 @@ void addrconf_dad_failure(struct inet6_ifaddr *ifp)
1934 in6_ifa_put(ifp2); 1933 in6_ifa_put(ifp2);
1935lock_errdad: 1934lock_errdad:
1936 spin_lock_bh(&ifp->lock); 1935 spin_lock_bh(&ifp->lock);
1937 } else if (idev->cnf.accept_dad > 1 && !idev->cnf.disable_ipv6) {
1938 addr.s6_addr32[0] = htonl(0xfe800000);
1939 addr.s6_addr32[1] = 0;
1940
1941 if (!ipv6_generate_eui64(addr.s6_addr + 8, idev->dev) &&
1942 ipv6_addr_equal(&ifp->addr, &addr)) {
1943 /* DAD failed for link-local based on MAC address */
1944 idev->cnf.disable_ipv6 = 1;
1945
1946 pr_info("%s: IPv6 being disabled!\n",
1947 ifp->idev->dev->name);
1948 }
1949 } 1936 }
1950 1937
1951errdad: 1938errdad:
@@ -3821,6 +3808,7 @@ static void addrconf_dad_work(struct work_struct *w)
3821 dad_work); 3808 dad_work);
3822 struct inet6_dev *idev = ifp->idev; 3809 struct inet6_dev *idev = ifp->idev;
3823 struct in6_addr mcaddr; 3810 struct in6_addr mcaddr;
3811 bool disable_ipv6 = false;
3824 3812
3825 enum { 3813 enum {
3826 DAD_PROCESS, 3814 DAD_PROCESS,
@@ -3837,6 +3825,24 @@ static void addrconf_dad_work(struct work_struct *w)
3837 } else if (ifp->state == INET6_IFADDR_STATE_ERRDAD) { 3825 } else if (ifp->state == INET6_IFADDR_STATE_ERRDAD) {
3838 action = DAD_ABORT; 3826 action = DAD_ABORT;
3839 ifp->state = INET6_IFADDR_STATE_POSTDAD; 3827 ifp->state = INET6_IFADDR_STATE_POSTDAD;
3828
3829 if (idev->cnf.accept_dad > 1 && !idev->cnf.disable_ipv6 &&
3830 !(ifp->flags & IFA_F_STABLE_PRIVACY)) {
3831 struct in6_addr addr;
3832
3833 addr.s6_addr32[0] = htonl(0xfe800000);
3834 addr.s6_addr32[1] = 0;
3835
3836 if (!ipv6_generate_eui64(addr.s6_addr + 8, idev->dev) &&
3837 ipv6_addr_equal(&ifp->addr, &addr)) {
3838 /* DAD failed for link-local based on MAC */
3839 idev->cnf.disable_ipv6 = 1;
3840
3841 pr_info("%s: IPv6 being disabled!\n",
3842 ifp->idev->dev->name);
3843 disable_ipv6 = true;
3844 }
3845 }
3840 } 3846 }
3841 spin_unlock_bh(&ifp->lock); 3847 spin_unlock_bh(&ifp->lock);
3842 3848
@@ -3845,6 +3851,8 @@ static void addrconf_dad_work(struct work_struct *w)
3845 goto out; 3851 goto out;
3846 } else if (action == DAD_ABORT) { 3852 } else if (action == DAD_ABORT) {
3847 addrconf_dad_stop(ifp, 1); 3853 addrconf_dad_stop(ifp, 1);
3854 if (disable_ipv6)
3855 addrconf_ifdown(idev->dev, 0);
3848 goto out; 3856 goto out;
3849 } 3857 }
3850 3858