]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
net: ipv6: send unsolicited NA after DAD
authorDavid Ahern <dsahern@gmail.com>
Fri, 26 Jan 2018 04:16:29 +0000 (20:16 -0800)
committerSeth Forshee <seth.forshee@canonical.com>
Tue, 13 Feb 2018 13:30:21 +0000 (07:30 -0600)
BugLink: http://bugs.launchpad.net/bugs/1749191
[ Upstream commit c76fe2d98c726224a975a0d0198c3fb50406d325 ]

Unsolicited IPv6 neighbor advertisements should be sent after DAD
completes. Update ndisc_send_unsol_na to skip tentative, non-optimistic
addresses and have those sent by addrconf_dad_completed after DAD.

Fixes: 4a6e3c5def13c ("net: ipv6: send unsolicited NA on admin up")
Reported-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
net/ipv6/addrconf.c
net/ipv6/ndisc.c

index 10facd174210974ac82b2304211061b90714aac8..2547222589fe5ce6c72bb90b513de8d1d4bc8fd0 100644 (file)
@@ -186,7 +186,8 @@ static struct rt6_info *addrconf_get_prefix_route(const struct in6_addr *pfx,
 
 static void addrconf_dad_start(struct inet6_ifaddr *ifp);
 static void addrconf_dad_work(struct work_struct *w);
-static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id);
+static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id,
+                                  bool send_na);
 static void addrconf_dad_run(struct inet6_dev *idev);
 static void addrconf_rs_timer(struct timer_list *t);
 static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifa);
@@ -3833,12 +3834,17 @@ static void addrconf_dad_begin(struct inet6_ifaddr *ifp)
             idev->cnf.accept_dad < 1) ||
            !(ifp->flags&IFA_F_TENTATIVE) ||
            ifp->flags & IFA_F_NODAD) {
+               bool send_na = false;
+
+               if (ifp->flags & IFA_F_TENTATIVE &&
+                   !(ifp->flags & IFA_F_OPTIMISTIC))
+                       send_na = true;
                bump_id = ifp->flags & IFA_F_TENTATIVE;
                ifp->flags &= ~(IFA_F_TENTATIVE|IFA_F_OPTIMISTIC|IFA_F_DADFAILED);
                spin_unlock(&ifp->lock);
                read_unlock_bh(&idev->lock);
 
-               addrconf_dad_completed(ifp, bump_id);
+               addrconf_dad_completed(ifp, bump_id, send_na);
                return;
        }
 
@@ -3967,16 +3973,21 @@ static void addrconf_dad_work(struct work_struct *w)
        }
 
        if (ifp->dad_probes == 0) {
+               bool send_na = false;
+
                /*
                 * DAD was successful
                 */
 
+               if (ifp->flags & IFA_F_TENTATIVE &&
+                   !(ifp->flags & IFA_F_OPTIMISTIC))
+                       send_na = true;
                bump_id = ifp->flags & IFA_F_TENTATIVE;
                ifp->flags &= ~(IFA_F_TENTATIVE|IFA_F_OPTIMISTIC|IFA_F_DADFAILED);
                spin_unlock(&ifp->lock);
                write_unlock_bh(&idev->lock);
 
-               addrconf_dad_completed(ifp, bump_id);
+               addrconf_dad_completed(ifp, bump_id, send_na);
 
                goto out;
        }
@@ -4014,7 +4025,8 @@ static bool ipv6_lonely_lladdr(struct inet6_ifaddr *ifp)
        return true;
 }
 
-static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id)
+static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id,
+                                  bool send_na)
 {
        struct net_device *dev = ifp->idev->dev;
        struct in6_addr lladdr;
@@ -4046,6 +4058,16 @@ static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id)
        if (send_mld)
                ipv6_mc_dad_complete(ifp->idev);
 
+       /* send unsolicited NA if enabled */
+       if (send_na &&
+           (ifp->idev->cnf.ndisc_notify ||
+            dev_net(dev)->ipv6.devconf_all->ndisc_notify)) {
+               ndisc_send_na(dev, &in6addr_linklocal_allnodes, &ifp->addr,
+                             /*router=*/ !!ifp->idev->cnf.forwarding,
+                             /*solicited=*/ false, /*override=*/ true,
+                             /*inc_opt=*/ true);
+       }
+
        if (send_rs) {
                /*
                 *      If a host as already performed a random delay
index b3cea200c85e232829b8b64f38e000ef896462b8..f61a5b613b52b065d8754af8adb9948f17eafc48 100644 (file)
@@ -566,6 +566,11 @@ static void ndisc_send_unsol_na(struct net_device *dev)
 
        read_lock_bh(&idev->lock);
        list_for_each_entry(ifa, &idev->addr_list, if_list) {
+               /* skip tentative addresses until dad completes */
+               if (ifa->flags & IFA_F_TENTATIVE &&
+                   !(ifa->flags & IFA_F_OPTIMISTIC))
+                       continue;
+
                ndisc_send_na(dev, &in6addr_linklocal_allnodes, &ifa->addr,
                              /*router=*/ !!idev->cnf.forwarding,
                              /*solicited=*/ false, /*override=*/ true,