summaryrefslogtreecommitdiff
path: root/sys/net/if.c
diff options
context:
space:
mode:
authorKip Macy <kmacy@FreeBSD.org>2008-12-18 04:50:44 +0000
committerKip Macy <kmacy@FreeBSD.org>2008-12-18 04:50:44 +0000
commitd24c444ca0f3b6e3034b80ffcd78c9c64ead8c7a (patch)
tree8be908be1768b5fcd6dc57f2ce95b9e24bce942a /sys/net/if.c
parent2db461e4894a99d293904376d39986514dfe5659 (diff)
downloadsrc-test2-d24c444ca0f3b6e3034b80ffcd78c9c64ead8c7a.tar.gz
src-test2-d24c444ca0f3b6e3034b80ffcd78c9c64ead8c7a.zip
Notes
Diffstat (limited to 'sys/net/if.c')
-rw-r--r--sys/net/if.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 6e71f67db37a..a170d01f1247 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -191,15 +191,24 @@ MALLOC_DEFINE(M_IFNET, "ifnet", "interface internals");
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 type)
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();