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/netinet6/in6.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/netinet6/in6.c')
-rw-r--r-- | sys/netinet6/in6.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index c4333ed..7d9f7e7 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -2234,7 +2234,7 @@ in6_setmaxmtu(void) unsigned long maxmtu = 0; struct ifnet *ifp; - IFNET_RLOCK(); + IFNET_RLOCK_NOSLEEP(); for (ifp = TAILQ_FIRST(&V_ifnet); ifp; ifp = TAILQ_NEXT(ifp, if_list)) { /* this function can be called during ifnet initialization */ @@ -2244,7 +2244,7 @@ in6_setmaxmtu(void) IN6_LINKMTU(ifp) > maxmtu) maxmtu = IN6_LINKMTU(ifp); } - IFNET_RUNLOCK(); + IFNET_RUNLOCK_NOSLEEP(); if (maxmtu) /* update only when maxmtu is positive */ V_in6_maxmtu = maxmtu; } @@ -2495,12 +2495,7 @@ in6_lltable_dump(struct lltable *llt, struct sysctl_req *wr) } ndpc; int i, error; - /* XXXXX - * current IFNET_RLOCK() is mapped to IFNET_WLOCK() - * so it is okay to use this ASSERT, change it when - * IFNET lock is finalized - */ - IFNET_WLOCK_ASSERT(); + IFNET_RLOCK_ASSERT(); error = 0; for (i = 0; i < LLTBL_HASHTBL_SIZE; i++) { |