From owner-freebsd-net@FreeBSD.ORG Thu Oct 21 21:43:18 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 26FD216A4D9; Thu, 21 Oct 2004 21:43:18 +0000 (GMT) Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id C20B043D41; Thu, 21 Oct 2004 21:43:17 +0000 (GMT) (envelope-from robert@fledge.watson.org) Received: from fledge.watson.org (localhost [127.0.0.1]) by fledge.watson.org (8.13.1/8.13.1) with ESMTP id i9LLh2vT033772; Thu, 21 Oct 2004 17:43:02 -0400 (EDT) (envelope-from robert@fledge.watson.org) Received: from localhost (robert@localhost)i9LLh2hM033769; Thu, 21 Oct 2004 17:43:02 -0400 (EDT) (envelope-from robert@fledge.watson.org) Date: Thu, 21 Oct 2004 17:43:01 -0400 (EDT) From: Robert Watson X-Sender: robert@fledge.watson.org To: gnn@freebsd.org In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-net@freebsd.org Subject: Re: Locking fixes to IPv6 scope6.c X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Oct 2004 21:43:18 -0000 On Sat, 16 Oct 2004 gnn@freebsd.org wrote: > @@ -71,12 +71,14 @@ > scope6_ifattach(ifp) > struct ifnet *ifp; > { > - int s = splnet(); > + > struct scope6_id *sid; > > sid = (struct scope6_id *)malloc(sizeof(*sid), M_IFADDR, M_WAITOK); > bzero(sid, sizeof(*sid)); > > + IFNET_WLOCK(); > + > /* > * XXX: IPV6_ADDR_SCOPE_xxx macros are not standard. > * Should we rather hardcode here? I notice that the comments indicate that you acquire the ifnet list lock to prevent the ifnet from going away; however, the caller passes in an ifnet pointer. Shouldn't it be the responsibility of the caller to make sure the ifnet doesn't go away, or it could go away before you could aquire the lock? I.e., either by virtue of the ifnet life cycle, or by virtue of the caller locking the list and these functions asserting it? Robert N M Watson FreeBSD Core Team, TrustedBSD Projects robert@fledge.watson.org Principal Research Scientist, McAfee Research