From owner-svn-src-all@FreeBSD.ORG Thu Dec 18 04:50:45 2008 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 2B1E6106567C; Thu, 18 Dec 2008 04:50:45 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 21BC48FC22; Thu, 18 Dec 2008 04:50:45 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mBI4oiof027515; Thu, 18 Dec 2008 04:50:44 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBI4oiBY027514; Thu, 18 Dec 2008 04:50:44 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812180450.mBI4oiBY027514@svn.freebsd.org> From: Kip Macy Date: Thu, 18 Dec 2008 04:50:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186266 - head/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: Thu, 18 Dec 2008 04:50:45 -0000 Author: kmacy Date: Thu Dec 18 04:50:44 2008 New Revision: 186266 URL: http://svn.freebsd.org/changeset/base/186266 Log: add ifnet_byindex_locked to allow for use of IFNET_RLOCK Modified: head/sys/net/if.c Modified: head/sys/net/if.c ============================================================================== --- head/sys/net/if.c Thu Dec 18 04:38:47 2008 (r186265) +++ head/sys/net/if.c Thu Dec 18 04:50:44 2008 (r186266) @@ -191,15 +191,24 @@ MALLOC_DEFINE(M_IFNET, "ifnet", "interfa MALLOC_DEFINE(M_IFADDR, "ifaddr", "interface address"); MALLOC_DEFINE(M_IFMADDR, "ether_multi", "link-level multicast address"); -struct ifnet * -ifnet_byindex(u_short idx) +static struct ifnet * +ifnet_byindex_locked(u_short idx) { INIT_VNET_NET(curvnet); struct ifnet *ifp; - IFNET_WLOCK(); ifp = V_ifindex_table[idx].ife_ifnet; - IFNET_WUNLOCK(); + return (ifp); +} + +struct ifnet * +ifnet_byindex(u_short idx) +{ + struct ifnet *ifp; + + IFNET_RLOCK(); + ifp = ifnet_byindex_locked(idx); + IFNET_RUNLOCK(); return (ifp); } @@ -218,9 +227,9 @@ ifaddr_byindex(u_short idx) { struct ifaddr *ifa; - IFNET_WLOCK(); - ifa = ifnet_byindex(idx)->if_addr; - IFNET_WUNLOCK(); + IFNET_RLOCK(); + ifa = ifnet_byindex_locked(idx)->if_addr; + IFNET_RUNLOCK(); return (ifa); } @@ -499,7 +508,7 @@ if_free_type(struct ifnet *ifp, u_char t ifnet_setbyindex(ifp->if_index, NULL); /* XXX: should be locked with if_findindex() */ - while (V_if_index > 0 && ifnet_byindex(V_if_index) == NULL) + while (V_if_index > 0 && ifnet_byindex_locked(V_if_index) == NULL) V_if_index--; IFNET_WUNLOCK();