diff options
author | rwatson <rwatson@FreeBSD.org> | 2009-08-23 20:40:19 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2009-08-23 20:40:19 +0000 |
commit | ef8d755d4df716bf13f8a1833f7dd1db0b78c569 (patch) | |
tree | 83b839696bd918acacee8b38993abd3c6857a5fb /sys/netipsec | |
parent | 3d8e6186e2a82569f4f5214f8c8af700e5e36c13 (diff) | |
download | FreeBSD-src-ef8d755d4df716bf13f8a1833f7dd1db0b78c569.zip FreeBSD-src-ef8d755d4df716bf13f8a1833f7dd1db0b78c569.tar.gz |
Rework global locks for interface list and index management, correcting
several critical bugs, including race conditions and lock order issues:
Replace the single rwlock, ifnet_lock, with two locks, an rwlock and an
sxlock. Either can be held to stablize the lists and indexes, but both
are required to write. This allows the list to be held stable in both
network interrupt contexts and sleepable user threads across sleeping
memory allocations or device driver interactions. As before, writes to
the interface list must occur from sleepable contexts.
Reviewed by: bz, julian
MFC after: 3 days
Diffstat (limited to 'sys/netipsec')
-rw-r--r-- | sys/netipsec/xform_ipip.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/netipsec/xform_ipip.c b/sys/netipsec/xform_ipip.c index c9669b1..78ab097 100644 --- a/sys/netipsec/xform_ipip.c +++ b/sys/netipsec/xform_ipip.c @@ -303,7 +303,7 @@ _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp) if ((m->m_pkthdr.rcvif == NULL || !(m->m_pkthdr.rcvif->if_flags & IFF_LOOPBACK)) && V_ipip_allow != 2) { - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); TAILQ_FOREACH(ifp, &V_ifnet, if_link) { TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { #ifdef INET @@ -318,7 +318,7 @@ _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp) ipo->ip_src.s_addr) { V_ipipstat.ipips_spoof++; m_freem(m); - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); return; } } @@ -335,7 +335,7 @@ _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp) if (IN6_ARE_ADDR_EQUAL(&sin6->sin6_addr, &ip6->ip6_src)) { V_ipipstat.ipips_spoof++; m_freem(m); - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); return; } @@ -343,7 +343,7 @@ _ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp) #endif /* INET6 */ } } - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); } /* Statistics */ |