From owner-svn-src-all@FreeBSD.ORG Wed Apr 21 19:48:41 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 22BDB106564A; Wed, 21 Apr 2010 19:48:41 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 11AF48FC0C; Wed, 21 Apr 2010 19:48:41 +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 o3LJmevN050771; Wed, 21 Apr 2010 19:48:40 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o3LJmeox050769; Wed, 21 Apr 2010 19:48:40 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201004211948.o3LJmeox050769@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Wed, 21 Apr 2010 19:48:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r207012 - stable/8/sys/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Apr 2010 19:48:41 -0000 Author: bz Date: Wed Apr 21 19:48:40 2010 New Revision: 207012 URL: http://svn.freebsd.org/changeset/base/207012 Log: MFC r206470: In if_detach_internal() we cannot hold the af_data lock over the dom_ifdetach() calls as they might sleep for callout_drain(). Do as we do in if_attachdomain1() [r121470] and handle if_afdata_initialized earlier and call dom_ifdetach() unlocked. Discussed with: rwatson Modified: stable/8/sys/net/if.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/geom/sched/ (props changed) Modified: stable/8/sys/net/if.c ============================================================================== --- stable/8/sys/net/if.c Wed Apr 21 19:47:19 2010 (r207011) +++ stable/8/sys/net/if.c Wed Apr 21 19:48:40 2010 (r207012) @@ -930,14 +930,20 @@ if_detach_internal(struct ifnet *ifp, in devctl_notify("IFNET", ifp->if_xname, "DETACH", NULL); if_delgroups(ifp); + /* + * We cannot hold the lock over dom_ifdetach calls as they might + * sleep, for example trying to drain a callout, thus open up the + * theoretical race with re-attaching. + */ IF_AFDATA_LOCK(ifp); - for (dp = domains; ifp->if_afdata_initialized > 0 && dp; dp = dp->dom_next) { + i = ifp->if_afdata_initialized; + ifp->if_afdata_initialized = 0; + IF_AFDATA_UNLOCK(ifp); + for (dp = domains; i > 0 && dp; dp = dp->dom_next) { if (dp->dom_ifdetach && ifp->if_afdata[dp->dom_family]) (*dp->dom_ifdetach)(ifp, ifp->if_afdata[dp->dom_family]); } - ifp->if_afdata_initialized = 0; - IF_AFDATA_UNLOCK(ifp); } #ifdef VIMAGE