aboutsummaryrefslogtreecommitdiff
path: root/sys/net/if_stf.c
diff options
context:
space:
mode:
authorRobert Watson <rwatson@FreeBSD.org>2009-06-25 11:52:33 +0000
committerRobert Watson <rwatson@FreeBSD.org>2009-06-25 11:52:33 +0000
commit2d9cfabad4b7d8d7589a825030ac7165b29a6e00 (patch)
treef7bd2b06a93cabd18d4d4396239234b49517bc87 /sys/net/if_stf.c
parent51500a4872e675ba5a0642a04272551dfc84bb18 (diff)
downloadsrc-2d9cfabad4b7d8d7589a825030ac7165b29a6e00.tar.gz
src-2d9cfabad4b7d8d7589a825030ac7165b29a6e00.zip
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
Notes
Notes: svn path=/head/; revision=194951
Diffstat (limited to 'sys/net/if_stf.c')
-rw-r--r--sys/net/if_stf.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c
index d463ff63485b..12ce174f09d8 100644
--- a/sys/net/if_stf.c
+++ b/sys/net/if_stf.c
@@ -620,15 +620,19 @@ stf_checkaddr4(sc, in, inifp)
/*
* reject packets with broadcast
*/
+ IN_IFADDR_RLOCK();
for (ia4 = TAILQ_FIRST(&V_in_ifaddrhead);
ia4;
ia4 = TAILQ_NEXT(ia4, ia_link))
{
if ((ia4->ia_ifa.ifa_ifp->if_flags & IFF_BROADCAST) == 0)
continue;
- if (in->s_addr == ia4->ia_broadaddr.sin_addr.s_addr)
+ if (in->s_addr == ia4->ia_broadaddr.sin_addr.s_addr) {
+ IN_IFADDR_RUNLOCK();
return -1;
+ }
}
+ IN_IFADDR_RUNLOCK();
/*
* perform ingress filter