From owner-svn-src-head@FreeBSD.ORG Sat Feb 27 07:12:26 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 310571065675; Sat, 27 Feb 2010 07:12:26 +0000 (UTC) (envelope-from qingli@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1FBB38FC1F; Sat, 27 Feb 2010 07:12:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1R7CQ4k088055; Sat, 27 Feb 2010 07:12:26 GMT (envelope-from qingli@svn.freebsd.org) Received: (from qingli@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1R7CQEn088053; Sat, 27 Feb 2010 07:12:26 GMT (envelope-from qingli@svn.freebsd.org) Message-Id: <201002270712.o1R7CQEn088053@svn.freebsd.org> From: Qing Li Date: Sat, 27 Feb 2010 07:12:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204402 - head/sys/netinet6 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Feb 2010 07:12:26 -0000 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); }