]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
Remove link-local multicast routes remnants from in6_purgeaddr.
authorae <ae@FreeBSD.org>
Mon, 10 Nov 2014 16:01:31 +0000 (16:01 +0000)
committerae <ae@FreeBSD.org>
Mon, 10 Nov 2014 16:01:31 +0000 (16:01 +0000)
Also merge in6_purgeaddr_mc with in6_purgeaddr.

Sponsored by: Yandex LLC

sys/netinet6/in6.c

index d64de425accd1b60654e880668ce97b9eae740d5..e22c0bd69ad9388883b59456a6c0beea29aa15ec 100644 (file)
@@ -1283,50 +1283,17 @@ in6_broadcast_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra,
        return (error);
 }
 
-/*
- * Leave from multicast groups we have joined for the interface.
- */
-static int
-in6_purgeaddr_mc(struct ifnet *ifp, struct in6_ifaddr *ia, struct ifaddr *ifa0)
-{
-       struct in6_multi_mship *imm;
-
-       while ((imm = LIST_FIRST(&ia->ia6_memberships)) != NULL) {
-               LIST_REMOVE(imm, i6mm_chain);
-               in6_leavegroup(imm);
-       }
-       return (0);
-}
-
 void
 in6_purgeaddr(struct ifaddr *ifa)
 {
        struct ifnet *ifp = ifa->ifa_ifp;
        struct in6_ifaddr *ia = (struct in6_ifaddr *) ifa;
+       struct in6_multi_mship *imm;
        int plen, error;
-       struct ifaddr *ifa0;
 
        if (ifa->ifa_carp)
                (*carp_detach_p)(ifa);
 
-       /*
-        * find another IPv6 address as the gateway for the
-        * link-local and node-local all-nodes multicast
-        * address routes
-        */
-       IF_ADDR_RLOCK(ifp);
-       TAILQ_FOREACH(ifa0, &ifp->if_addrhead, ifa_link) {
-               if ((ifa0->ifa_addr->sa_family != AF_INET6) ||
-                   memcmp(&satosin6(ifa0->ifa_addr)->sin6_addr,
-                   &ia->ia_addr.sin6_addr, sizeof(struct in6_addr)) == 0)
-                       continue;
-               else
-                       break;
-       }
-       if (ifa0 != NULL)
-               ifa_ref(ifa0);
-       IF_ADDR_RUNLOCK(ifp);
-
        /*
         * Remove the loopback route to the interface address.
         * The check for the current setting of "nd6_useloopback"
@@ -1346,11 +1313,10 @@ in6_purgeaddr(struct ifaddr *ifa)
        nd6_rem_ifa_lle(ia);
 
        /* Leave multicast groups. */
-       error = in6_purgeaddr_mc(ifp, ia, ifa0);
-
-       if (ifa0 != NULL)
-               ifa_free(ifa0);
-
+       while ((imm = LIST_FIRST(&ia->ia6_memberships)) != NULL) {
+               LIST_REMOVE(imm, i6mm_chain);
+               in6_leavegroup(imm);
+       }
        plen = in6_mask2len(&ia->ia_prefixmask.sin6_addr, NULL); /* XXX */
        if ((ia->ia_flags & IFA_ROUTE) && plen == 128) {
                error = rtinit(&(ia->ia_ifa), RTM_DELETE, ia->ia_flags |