From owner-freebsd-net@FreeBSD.ORG Fri Apr 18 02:02:03 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 F0A6B106564A for ; Fri, 18 Apr 2008 02:02:03 +0000 (UTC) (envelope-from vijjus@rocketmail.com) Received: from web33501.mail.mud.yahoo.com (web33501.mail.mud.yahoo.com [68.142.206.150]) by mx1.freebsd.org (Postfix) with SMTP id 927588FC0C for ; Fri, 18 Apr 2008 02:02:03 +0000 (UTC) (envelope-from vijjus@rocketmail.com) Received: (qmail 95666 invoked by uid 60001); 18 Apr 2008 01:35:23 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=rocketmail.com; h=X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Message-ID; b=VuAeeKRn4oX5bI5YqF6VEqx4kELbqNzOu1T7vzbYZhXhxUGdqD+dJTAqiiZnUbjZ3O/Xn0ieCgld1x5it4scPGDYftkOq1IL4SBLpfWKhAI05ml1Q1OVFYZw985Dy1cZTpPIoMoUpkL1Q/ho0yjDrZuZ9esbKbdy50A/BdXFKG0=; X-YMail-OSG: ItPtIScVM1kmCnNw5oxw363XlOOPPZGcRHqzHe.MUJHmU8cYkmbxiBVFrswPG.YRQGaH8V4BSMXa2MT2_ssaD2ZXMzoOV18Gq3zxA7KFFJy4Zt2Ob4MDDdfwCQ-- Received: from [198.95.226.230] by web33501.mail.mud.yahoo.com via HTTP; Thu, 17 Apr 2008 18:35:23 PDT X-Mailer: YahooMailRC/902.40 YahooMailWebService/0.7.185 Date: Thu, 17 Apr 2008 18:35:23 -0700 (PDT) From: vijay singh To: freebsd-net@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Message-ID: <490341.95478.qm@web33501.mail.mud.yahoo.com> Subject: 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 02:02:04 -0000 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]? 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; } ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ