Author: rwatson
Date: Thu Jun 25 08:37:38 2009
New Revision: 194943
URL: http://svn.freebsd.org/changeset/base/194943

Log:
  Clean up reference management in in6_update_ifa and in6_unlink_ifa, and
  in particular, add a reference for in6_ifaddrhead since we do remove a
  reference for it when an IPv6 address is removed.  This fixes ifconfig
  delete of an IPv6 alias.
  
  Reported by:  tegge
  MFC after:    6 weeks

Modified:
  head/sys/netinet6/in6.c

Modified: head/sys/netinet6/in6.c
==============================================================================
--- head/sys/netinet6/in6.c     Thu Jun 25 07:25:39 2009        (r194942)
+++ head/sys/netinet6/in6.c     Thu Jun 25 08:37:38 2009        (r194943)
@@ -831,6 +831,7 @@ in6_update_ifa(struct ifnet *ifp, struct
                TAILQ_INSERT_TAIL(&ifp->if_addrhead, &ia->ia_ifa, ifa_link);
                IF_ADDR_UNLOCK(ifp);
 
+               ifa_ref(&ia->ia_ifa);                   /* in6_if_addrhead */
                TAILQ_INSERT_TAIL(&V_in6_ifaddrhead, ia, ia_link);
        }
 
@@ -1147,8 +1148,8 @@ in6_update_ifa(struct ifnet *ifp, struct
         * anyway.
         */
        if (hostIsNew) {
-               ifa_free(&ia->ia_ifa);
                in6_unlink_ifa(ia, ifp);
+               ifa_free(&ia->ia_ifa);
        }
        return (error);
 
@@ -1376,6 +1377,7 @@ in6_unlink_ifa(struct in6_ifaddr *ia, st
        ifa_free(&ia->ia_ifa);                  /* if_addrhead */
 
        TAILQ_REMOVE(&V_in6_ifaddrhead, ia, ia_link);
+       ifa_free(&ia->ia_ifa);                  /* in6_ifaddrhead */
 
        /*
         * Release the reference to the base prefix.  There should be a
@@ -1399,12 +1401,6 @@ in6_unlink_ifa(struct in6_ifaddr *ia, st
                pfxlist_onlink_check();
        }
 
-       /*
-        * release another refcnt for the link from in6_ifaddr.
-        * Note that we should decrement the refcnt at least once for all *BSD.
-        */
-       ifa_free(&ia->ia_ifa);
-
        splx(s);
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to