diff options
author | rwatson <rwatson@FreeBSD.org> | 2009-06-25 11:52:33 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2009-06-25 11:52:33 +0000 |
commit | ea70a3542dc7bf7a2e16d5d9c4639fd211a395b6 (patch) | |
tree | f7bd2b06a93cabd18d4d4396239234b49517bc87 /sys/netinet/ip_input.c | |
parent | 078b9535f0627f5c60944246a4c3df0402604c44 (diff) | |
download | FreeBSD-src-ea70a3542dc7bf7a2e16d5d9c4639fd211a395b6.zip FreeBSD-src-ea70a3542dc7bf7a2e16d5d9c4639fd211a395b6.tar.gz |
Add a new global rwlock, in_ifaddr_lock, which will synchronize use of the
in_ifaddrhead and INADDR_HASH address lists.
Previously, these lists were used unsynchronized as they were effectively
never changed in steady state, but we've seen increasing reports of
writer-writer races on very busy VPN servers as core count has gone up
(and similar configurations where address lists change frequently and
concurrently).
For the time being, use rwlocks rather than rmlocks in order to take
advantage of their better lock debugging support. As a result, we don't
enable ip_input()'s read-locking of INADDR_HASH until an rmlock conversion
is complete and a performance analysis has been done. This means that one
class of reader-writer races still exists.
MFC after: 6 weeks
Reviewed by: bz
Diffstat (limited to 'sys/netinet/ip_input.c')
-rw-r--r-- | sys/netinet/ip_input.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 81b8f8f3..53c07fc 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -117,6 +117,7 @@ static int maxfragsperpacket; int ipstealth; static int nipq; /* Total # of reass queues */ #endif +struct rwlock in_ifaddr_lock; SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, IPCTL_FORWARDING, forwarding, CTLFLAG_RW, ipforwarding, 0, @@ -325,6 +326,7 @@ ip_init(void) TAILQ_INIT(&V_in_ifaddrhead); V_in_ifaddrhashtbl = hashinit(INADDR_NHASH, M_IFADDR, &V_in_ifaddrhmask); + IN_IFADDR_LOCK_INIT(); /* Initialize IP reassembly queue. */ for (i = 0; i < IPREASS_NHASH; i++) @@ -615,6 +617,7 @@ passin: /* * Check for exact addresses in the hash bucket. */ + /* IN_IFADDR_RLOCK(); */ LIST_FOREACH(ia, INADDR_HASH(ip->ip_dst.s_addr), ia_hash) { /* * If the address matches, verify that the packet @@ -624,9 +627,12 @@ passin: if (IA_SIN(ia)->sin_addr.s_addr == ip->ip_dst.s_addr && (!checkif || ia->ia_ifp == ifp)) { ifa_ref(&ia->ia_ifa); + /* IN_IFADDR_RUNLOCK(); */ goto ours; } } + /* IN_IFADDR_RUNLOCK(); */ + /* * Check for broadcast addresses. * |