svn commit: r204402 - head/sys/netinet6

Qing Li qingli at FreeBSD.org
Sat Feb 27 07:12:26 UTC 2010


Author: qingli
Date: Sat Feb 27 07:12:25 2010
New Revision: 204402
URL: http://svn.freebsd.org/changeset/base/204402

Log:
  Use reference counting instead of locking to secure an address while
  that address is being used to generate temporary IPv6 address. This
  approach is sufficient and avoids recursive locking.
  
  MFC after:	3 days

Modified:
  head/sys/netinet6/nd6.c

Modified: head/sys/netinet6/nd6.c
==============================================================================
--- head/sys/netinet6/nd6.c	Sat Feb 27 06:28:22 2010	(r204401)
+++ head/sys/netinet6/nd6.c	Sat Feb 27 07:12:25 2010	(r204402)
@@ -764,22 +764,25 @@ regen_tmpaddr(struct in6_ifaddr *ia6)
 		 */
 		if (!IFA6_IS_DEPRECATED(it6))
 		    public_ifa6 = it6;
+
+		if (public_ifa6 != NULL)
+			ifa_ref(&public_ifa6->ia_ifa);
 	}
+	IF_ADDR_UNLOCK(ifp);
 
 	if (public_ifa6 != NULL) {
 		int e;
 
 		if ((e = in6_tmpifadd(public_ifa6, 0, 0)) != 0) {
-			IF_ADDR_UNLOCK(ifp);
+			ifa_free(&public_ifa6->ia_ifa);
 			log(LOG_NOTICE, "regen_tmpaddr: failed to create a new"
 			    " tmp addr,errno=%d\n", e);
 			return (-1);
 		}
-		IF_ADDR_UNLOCK(ifp);
+		ifa_free(&public_ifa6->ia_ifa);
 		return (0);
 	}
 
-	IF_ADDR_UNLOCK(ifp);
 	return (-1);
 }
 


More information about the svn-src-all mailing list