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/net/if_llatbl.c | |
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/net/if_llatbl.c')
-rw-r--r-- | sys/net/if_llatbl.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/net/if_llatbl.c b/sys/net/if_llatbl.c index a1b574f..a3617f5 100644 --- a/sys/net/if_llatbl.c +++ b/sys/net/if_llatbl.c @@ -200,14 +200,14 @@ lltable_prefix_free(int af, struct sockaddr *prefix, struct sockaddr *mask) { struct lltable *llt; - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); SLIST_FOREACH(llt, &lltables, llt_link) { if (llt->llt_af != af) continue; llt->llt_prefix_free(llt, prefix, mask); } - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); } @@ -300,13 +300,13 @@ lla_rt_output(struct rt_msghdr *rtm, struct rt_addrinfo *info) } /* XXX linked list may be too expensive */ - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); SLIST_FOREACH(llt, &lltables, llt_link) { if (llt->llt_af == dst->sa_family && llt->llt_ifp == ifp) break; } - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); KASSERT(llt != NULL, ("Yep, ugly hacks are bad\n")); if (flags && LLE_CREATE) |