summaryrefslogtreecommitdiffstats
path: root/sys/netinet/udp_usrreq.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2004-08-06 02:08:31 +0000
committerrwatson <rwatson@FreeBSD.org>2004-08-06 02:08:31 +0000
commit2ce46f099e305079439e5da87d339ccdc1bf0006 (patch)
tree29bfa2cbace46cc915032519c98724eea2bee7ee /sys/netinet/udp_usrreq.c
parent9b4d7989dc75d938565d34f07026d0ce2ee59f59 (diff)
downloadFreeBSD-src-2ce46f099e305079439e5da87d339ccdc1bf0006.zip
FreeBSD-src-2ce46f099e305079439e5da87d339ccdc1bf0006.tar.gz
When iterating the UDP inpcb list processing an inbound broadcast
or multicast packet, we don't need to acquire the inpcb mutex unless we are actually using inpcb fields other than the bound port and address. Since we hold the pcbinfo lock already, these can't change. Defer acquiring the inpcb mutex until we have a high chance of a match. This avoids about 120 mutex operations per UDP broadcast packet received on one of my work systems. Reviewed by: sam
Diffstat (limited to 'sys/netinet/udp_usrreq.c')
-rw-r--r--sys/netinet/udp_usrreq.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index fc146d4..dc95f4bd2 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -287,26 +287,23 @@ udp_input(m, off)
*/
last = NULL;
LIST_FOREACH(inp, &udb, inp_list) {
- INP_LOCK(inp);
- if (inp->inp_lport != uh->uh_dport) {
- docontinue:
- INP_UNLOCK(inp);
+ if (inp->inp_lport != uh->uh_dport)
continue;
- }
#ifdef INET6
if ((inp->inp_vflag & INP_IPV4) == 0)
- goto docontinue;
+ continue;
#endif
if (inp->inp_laddr.s_addr != INADDR_ANY) {
if (inp->inp_laddr.s_addr != ip->ip_dst.s_addr)
- goto docontinue;
+ continue;
}
if (inp->inp_faddr.s_addr != INADDR_ANY) {
if (inp->inp_faddr.s_addr !=
ip->ip_src.s_addr ||
inp->inp_fport != uh->uh_sport)
- goto docontinue;
+ continue;
}
+ INP_LOCK(inp);
/*
* Check multicast packets to make sure they are only
@@ -327,8 +324,10 @@ udp_input(m, off)
break;
}
}
- if (foundmship == 0)
- goto docontinue;
+ if (foundmship == 0) {
+ INP_UNLOCK(inp);
+ continue;
+ }
}
#undef NMSHIPS
#undef MSHIP
OpenPOWER on IntegriCloud