From owner-freebsd-net@FreeBSD.ORG Fri Apr 18 15:28:16 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 525051065673 for ; Fri, 18 Apr 2008 15:28:16 +0000 (UTC) (envelope-from brooks@lor.one-eyed-alien.net) Received: from lor.one-eyed-alien.net (cl-162.ewr-01.us.sixxs.net [IPv6:2001:4830:1200:a1::2]) by mx1.freebsd.org (Postfix) with ESMTP id BF73F8FC2B for ; Fri, 18 Apr 2008 15:28:15 +0000 (UTC) (envelope-from brooks@lor.one-eyed-alien.net) Received: from lor.one-eyed-alien.net (localhost [127.0.0.1]) by lor.one-eyed-alien.net (8.14.2/8.14.2) with ESMTP id m3IFSRw0020675; Fri, 18 Apr 2008 10:28:27 -0500 (CDT) (envelope-from brooks@lor.one-eyed-alien.net) Received: (from brooks@localhost) by lor.one-eyed-alien.net (8.14.2/8.14.2/Submit) id m3IFSRGc020674; Fri, 18 Apr 2008 10:28:27 -0500 (CDT) (envelope-from brooks) Date: Fri, 18 Apr 2008 10:28:27 -0500 From: Brooks Davis To: vijay singh Message-ID: <20080418152827.GA20382@lor.one-eyed-alien.net> References: <490341.95478.qm@web33501.mail.mud.yahoo.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="envbJBWh7q8WU6mo" Content-Disposition: inline In-Reply-To: <490341.95478.qm@web33501.mail.mud.yahoo.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (lor.one-eyed-alien.net [127.0.0.1]); Fri, 18 Apr 2008 10:28:27 -0500 (CDT) 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 15:28:16 -0000 --envbJBWh7q8WU6mo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Apr 17, 2008 at 06:35:23PM -0700, 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]? Locking if_index management with ifnet_lock should be ok. Ideally we should probably be using ALLOC_UNR(9) to manage if_indexes instead of this rather expensive loop. Be aware, that if_index generation is least of the issues in this area. The if_grow() call is much riskier since it changes the value of the global ifnet pointer which I'm not sure we can afford to lock. It would be worth experimenting with rmlocks to see what the impact if of locking would be. I'm serious tempted to kill if_grow in favor of some sort of if_index_max tunable. -- Brooks > if_alloc(u_char type) > { > struct ifnet *ifp; >=20 > ifp =3D malloc(sizeof(struct ifnet), M_IFNET, M_WAITOK|M_ZERO); >=20 > /* > * Try to find an empty slot below if_index. If we fail, take > * the next slot. > * > * XXX: should be locked! > */ > for (ifp->if_index =3D 1; ifp->if_index <=3D if_index; ifp->if_index+= +) { > if (ifnet_byindex(ifp->if_index) =3D=3D NULL) > break; > } >=20 >=20 >=20 >=20 >=20 > ___________________________________________________________________= _________________ > Be a better friend, newshound, and=20 > know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_y= lt=3DAhu06i62sR8HDtDypao8Wcj9tAcJ > _______________________________________________ > freebsd-net@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" >=20 --envbJBWh7q8WU6mo Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (FreeBSD) iD8DBQFICL4aXY6L6fI4GtQRArdsAKCPMDjyxiOsKdTuJOpMJD2t1AsQaQCgxk9v 65KCmQDqs7a6H3HNpmdEdEQ= =nkAN -----END PGP SIGNATURE----- --envbJBWh7q8WU6mo--