This is to inform userland (i.e. slaacd(8)) when duplicate address
detection finishes.

Not a big fan of the lock/unlock dance but I guess it can't be helped
for now.

Comments, OKs?

diff --git net/route.h net/route.h
index 3c89348cb43..3d958719049 100644
--- net/route.h
+++ net/route.h
@@ -241,6 +241,7 @@ struct rt_msghdr {
 #define RTM_INVALIDATE 0x11    /* Invalidate cache of L2 route */
 #define RTM_BFD                0x12    /* bidirectional forwarding detection */
 #define RTM_PROPOSAL   0x13    /* proposal for netconfigd */
+#define RTM_CHGADDR    0x14    /* address flags change */
 
 #define RTV_MTU                0x1     /* init or lock _mtu */
 #define RTV_HOPCOUNT   0x2     /* init or lock _hopcount */
diff --git netinet6/nd6_nbr.c netinet6/nd6_nbr.c
index cb5c04c24ed..1ae431954a2 100644
--- netinet6/nd6_nbr.c
+++ netinet6/nd6_nbr.c
@@ -1102,6 +1102,11 @@ nd6_dad_start(struct ifaddr *ifa)
        KASSERT(ia6->ia6_flags & IN6_IFF_TENTATIVE);
        if ((ia6->ia6_flags & IN6_IFF_ANYCAST) || (!ip6_dad_count)) {
                ia6->ia6_flags &= ~IN6_IFF_TENTATIVE;
+
+               KERNEL_LOCK();
+               rtm_addr(RTM_CHGADDR, ifa);
+               KERNEL_UNLOCK();
+
                return;
        }
 
@@ -1250,6 +1255,10 @@ nd6_dad_timer(void *xifa)
                         */
                        ia6->ia6_flags &= ~IN6_IFF_TENTATIVE;
 
+                       KERNEL_LOCK();
+                       rtm_addr(RTM_CHGADDR, ifa);
+                       KERNEL_UNLOCK();
+
                        nd6log((LOG_DEBUG,
                            "%s: DAD complete for %s - no duplicates found\n",
                            ifa->ifa_ifp->if_xname,
@@ -1293,6 +1302,11 @@ nd6_dad_duplicated(struct dadq *dp)
            ia6->ia_ifp->if_xname);
 
        TAILQ_REMOVE(&dadq, dp, dad_list);
+
+       KERNEL_LOCK();
+        rtm_addr(RTM_CHGADDR, dp->dad_ifa);
+       KERNEL_UNLOCK();
+
        ifafree(dp->dad_ifa);
        free(dp, M_IP6NDP, sizeof(*dp));
        ip6_dad_pending--;

-- 
I'm not entirely sure you are real.

Reply via email to