From owner-freebsd-net@FreeBSD.ORG Fri Apr 18 06:30:02 2008 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C74561065673 for ; Fri, 18 Apr 2008 06:30:02 +0000 (UTC) (envelope-from gnn@neville-neil.com) Received: from outbound0.mx.meer.net (outbound0.mx.meer.net [209.157.153.23]) by mx1.freebsd.org (Postfix) with ESMTP id 9FEB88FC18 for ; Fri, 18 Apr 2008 06:30:02 +0000 (UTC) (envelope-from gnn@neville-neil.com) Received: from mail.meer.net (mail.meer.net [209.157.152.14]) by outbound0.mx.meer.net (8.12.10/8.12.6) with ESMTP id m3I6U0hx096033; Thu, 17 Apr 2008 23:30:02 -0700 (PDT) (envelope-from gnn@neville-neil.com) Received: from mail2.meer.net (mail2.meer.net [64.13.141.16]) by mail.meer.net (8.13.3/8.13.3/meer) with ESMTP id m3I6TCM0095315; Thu, 17 Apr 2008 23:29:12 -0700 (PDT) (envelope-from gnn@neville-neil.com) Received: from minion.local.neville-neil.com (61.204.211.246.customerlink.pwd.ne.jp [61.204.211.246]) (authenticated bits=0) by mail2.meer.net (8.14.1/8.14.1) with ESMTP id m3I6TBwh094285; Thu, 17 Apr 2008 23:29:12 -0700 (PDT) (envelope-from gnn@neville-neil.com) Date: Fri, 18 Apr 2008 15:29:10 +0900 Message-ID: From: gnn@freebsd.org To: vijay singh In-Reply-To: <490341.95478.qm@web33501.mail.mud.yahoo.com> References: <490341.95478.qm@web33501.mail.mud.yahoo.com> User-Agent: Wanderlust/2.15.5 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL/10.7 Emacs/22.1.50 (i386-apple-darwin8.11.1) MULE/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: freebsd-net@freebsd.org Subject: Re: Regarding if_alloc() X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Apr 2008 06:30:02 -0000 At Thu, 17 Apr 2008 18:35:23 -0700 (PDT), vijay singh wrote: > > Hi all. How do we avoid a race in populating the ifindex_table? Id > this is a TODO, as it seems from the code below, would it be > acceptable if I wrote a patch and reused the ifnet_lock > [IFNET_WLOCK, IFNET_WUNLOCK]? > It is almost always acceptable to submit a patch :-) > > if_alloc(u_char type) > { > struct ifnet *ifp; > > ifp = malloc(sizeof(struct ifnet), M_IFNET, M_WAITOK|M_ZERO); > > /* > * Try to find an empty slot below if_index. If we fail, take > * the next slot. > * > * XXX: should be locked! > */ > for (ifp->if_index = 1; ifp->if_index <= if_index; ifp->if_index++) { > if (ifnet_byindex(ifp->if_index) == NULL) > break; > } > > There are still parts of the network device infrastructure that need some locking, and it would seem that this is one of them. I know Brooks Davis was also looking at this stuff so he may comment as well. Best, George