summaryrefslogtreecommitdiff
path: root/sys/netinet/udp_usrreq.c
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2004-08-10 20:11:05 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2004-08-10 20:11:05 +0000
commit6e39ce35a862b30c6fe9b5b6996dd727ba1439ec (patch)
tree0b5323ff13ed3e1a04b9d55d9d380af036e05295 /sys/netinet/udp_usrreq.c
parente95254e027124be48dd67d4460d20b3e36305756 (diff)
replace in_pcbnotify with in_pcbhashlookup and avoid looping over
all connections; ok dhartmei, canacar, mcbride
Diffstat (limited to 'sys/netinet/udp_usrreq.c')
-rw-r--r--sys/netinet/udp_usrreq.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 8fe5a98c5d2..af11cdd1c51 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udp_usrreq.c,v 1.101 2004/06/14 05:24:04 mcbride Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.102 2004/08/10 20:11:04 markus Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
@@ -867,6 +867,8 @@ udp_ctlinput(cmd, sa, v)
{
struct ip *ip = v;
struct udphdr *uhp;
+ struct in_addr faddr;
+ struct inpcb *inp;
extern int inetctlerrmap[];
void (*notify)(struct inpcb *, int) = udp_notify;
int errno;
@@ -876,6 +878,9 @@ udp_ctlinput(cmd, sa, v)
if (sa->sa_family != AF_INET ||
sa->sa_len != sizeof(struct sockaddr_in))
return NULL;
+ faddr = satosin(sa)->sin_addr;
+ if (faddr.s_addr == INADDR_ANY)
+ return NULL;
if ((unsigned)cmd >= PRC_NCMDS)
return NULL;
@@ -888,8 +893,10 @@ udp_ctlinput(cmd, sa, v)
return NULL;
if (ip) {
uhp = (struct udphdr *)((caddr_t)ip + (ip->ip_hl << 2));
- (void) in_pcbnotify(&udbtable, sa, uhp->uh_dport, ip->ip_src,
- uhp->uh_sport, errno, notify);
+ inp = in_pcbhashlookup(&udbtable,
+ ip->ip_dst, uhp->uh_dport, ip->ip_src, uhp->uh_sport);
+ if (inp && inp->inp_socket != NULL)
+ notify(inp, errno);
} else
in_pcbnotifyall(&udbtable, sa, errno, notify);
return NULL;