Changed in_pcblookuphash() to not automatically call in_pcblookup() if

the lookup fails. Updated callers to deal with this. Call in_pcblookuphash
instead of in_pcblookup() in in_pcbconnect; this improves performance of
UDP output by about 17% in the standard case.
This commit is contained in:
dg 1995-05-03 07:16:53 +00:00
parent f7797d2a5e
commit dea37698fd
4 changed files with 42 additions and 23 deletions

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)in_pcb.c 8.2 (Berkeley) 1/4/94 * @(#)in_pcb.c 8.2 (Berkeley) 1/4/94
* $Id: in_pcb.c,v 1.9 1995/04/09 01:29:18 davidg Exp $ * $Id: in_pcb.c,v 1.10 1995/04/10 08:52:45 davidg Exp $
*/ */
#include <sys/param.h> #include <sys/param.h>
@ -303,12 +303,9 @@ in_pcbconnect(inp, nam)
if (error = in_pcbladdr(inp, nam, &ifaddr)) if (error = in_pcbladdr(inp, nam, &ifaddr))
return(error); return(error);
if (in_pcblookup(inp->inp_pcbinfo->listhead, if (in_pcblookuphash(inp->inp_pcbinfo, sin->sin_addr, sin->sin_port,
sin->sin_addr,
sin->sin_port,
inp->inp_laddr.s_addr ? inp->inp_laddr : ifaddr->sin_addr, inp->inp_laddr.s_addr ? inp->inp_laddr : ifaddr->sin_addr,
inp->inp_lport, inp->inp_lport) != NULL)
0))
return (EADDRINUSE); return (EADDRINUSE);
if (inp->inp_laddr.s_addr == INADDR_ANY) { if (inp->inp_laddr.s_addr == INADDR_ANY) {
if (inp->inp_lport == 0) if (inp->inp_lport == 0)
@ -588,17 +585,10 @@ in_pcblookuphash(pcbinfo, faddr, fport_arg, laddr, lport_arg)
LIST_REMOVE(inp, inp_hash); LIST_REMOVE(inp, inp_hash);
LIST_INSERT_HEAD(head, inp, inp_hash); LIST_INSERT_HEAD(head, inp, inp_hash);
} }
splx(s); break;
return (inp);
} }
splx(s); splx(s);
return (inp);
/*
* Didn't find an exact match, so try again looking for a matching
* wildcard PCB.
*/
return (in_pcblookup(pcbinfo->listhead, faddr, fport_arg, laddr,
lport_arg, INPLOOKUP_WILDCARD));
} }
/* /*

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* From: @(#)tcp_input.c 8.5 (Berkeley) 4/10/94 * From: @(#)tcp_input.c 8.5 (Berkeley) 4/10/94
* $Id: tcp_input.c,v 1.20 1995/04/10 17:16:10 davidg Exp $ * $Id: tcp_input.c,v 1.21 1995/04/10 17:37:46 davidg Exp $
*/ */
#ifndef TUBA_INCLUDE #ifndef TUBA_INCLUDE
@ -337,7 +337,18 @@ tcp_input(m, iphlen)
* Locate pcb for segment. * Locate pcb for segment.
*/ */
findpcb: findpcb:
inp = in_pcblookuphash(&tcbinfo, ti->ti_src, ti->ti_sport, ti->ti_dst, ti->ti_dport); /*
* First look for an exact match.
*/
inp = in_pcblookuphash(&tcbinfo, ti->ti_src, ti->ti_sport,
ti->ti_dst, ti->ti_dport);
/*
* ...and if that fails, do a wildcard search.
*/
if (inp == NULL) {
inp = in_pcblookup(&tcb, ti->ti_src, ti->ti_sport,
ti->ti_dst, ti->ti_dport, INPLOOKUP_WILDCARD);
}
/* /*
* If the state is CLOSED (i.e., TCB does not exist) then * If the state is CLOSED (i.e., TCB does not exist) then
@ -345,7 +356,7 @@ tcp_input(m, iphlen)
* If the TCB exists but is in CLOSED state, it is embryonic, * If the TCB exists but is in CLOSED state, it is embryonic,
* but should either do a listen or a connect soon. * but should either do a listen or a connect soon.
*/ */
if (inp == 0) if (inp == NULL)
goto dropwithreset; goto dropwithreset;
tp = intotcpcb(inp); tp = intotcpcb(inp);
if (tp == 0) if (tp == 0)

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* From: @(#)tcp_input.c 8.5 (Berkeley) 4/10/94 * From: @(#)tcp_input.c 8.5 (Berkeley) 4/10/94
* $Id: tcp_input.c,v 1.20 1995/04/10 17:16:10 davidg Exp $ * $Id: tcp_input.c,v 1.21 1995/04/10 17:37:46 davidg Exp $
*/ */
#ifndef TUBA_INCLUDE #ifndef TUBA_INCLUDE
@ -337,7 +337,18 @@ tcp_input(m, iphlen)
* Locate pcb for segment. * Locate pcb for segment.
*/ */
findpcb: findpcb:
inp = in_pcblookuphash(&tcbinfo, ti->ti_src, ti->ti_sport, ti->ti_dst, ti->ti_dport); /*
* First look for an exact match.
*/
inp = in_pcblookuphash(&tcbinfo, ti->ti_src, ti->ti_sport,
ti->ti_dst, ti->ti_dport);
/*
* ...and if that fails, do a wildcard search.
*/
if (inp == NULL) {
inp = in_pcblookup(&tcb, ti->ti_src, ti->ti_sport,
ti->ti_dst, ti->ti_dport, INPLOOKUP_WILDCARD);
}
/* /*
* If the state is CLOSED (i.e., TCB does not exist) then * If the state is CLOSED (i.e., TCB does not exist) then
@ -345,7 +356,7 @@ tcp_input(m, iphlen)
* If the TCB exists but is in CLOSED state, it is embryonic, * If the TCB exists but is in CLOSED state, it is embryonic,
* but should either do a listen or a connect soon. * but should either do a listen or a connect soon.
*/ */
if (inp == 0) if (inp == NULL)
goto dropwithreset; goto dropwithreset;
tp = intotcpcb(inp); tp = intotcpcb(inp);
if (tp == 0) if (tp == 0)

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)udp_usrreq.c 8.4 (Berkeley) 1/21/94 * @(#)udp_usrreq.c 8.4 (Berkeley) 1/21/94
* $Id: udp_usrreq.c,v 1.8 1995/03/16 18:15:09 bde Exp $ * $Id: udp_usrreq.c,v 1.9 1995/04/09 01:29:30 davidg Exp $
*/ */
#include <sys/param.h> #include <sys/param.h>
@ -256,10 +256,17 @@ udp_input(m, iphlen)
return; return;
} }
/* /*
* Locate pcb for datagram. * Locate pcb for datagram. First look for an exact match.
*/ */
inp = in_pcblookuphash(&udbinfo, ip->ip_src, uh->uh_sport, inp = in_pcblookuphash(&udbinfo, ip->ip_src, uh->uh_sport,
ip->ip_dst, uh->uh_dport); ip->ip_dst, uh->uh_dport);
/*
* ...and if that fails, do a wildcard search.
*/
if (inp == NULL) {
inp = in_pcblookup(&udb, ip->ip_src, uh->uh_sport, ip->ip_dst,
uh->uh_dport, INPLOOKUP_WILDCARD);
}
if (inp == NULL) { if (inp == NULL) {
udpstat.udps_noport++; udpstat.udps_noport++;
if (m->m_flags & (M_BCAST | M_MCAST)) { if (m->m_flags & (M_BCAST | M_MCAST)) {