--- netinet/in_pcb.c.orig Fri Oct 24 10:57:51 2003 +++ netinet/in_pcb.c Fri Oct 24 15:58:04 2003 @@ -722,6 +727,28 @@ u_int16_t fport = fport_arg, lport = lport_arg; struct in_addr faddr = *(struct in_addr *)faddrp; struct in_addr laddr = *(struct in_addr *)laddrp; +#ifdef INET6 + struct in6_addr *laddr6 = (struct in6_addr *)laddrp; + struct in6_addr *faddr6 = (struct in6_addr *)faddrp; +#endif + /* + * Assertion: if faddr is unspecified then fport must be unspecified + * as well. + */ + if ((flags & INPLOOKUP_WILDCARD) == 0) { + /* + * non-wildcard lookups can be done by in_pcbhashlookup + * a lot faster. + */ +#ifdef INET6 + if (flags & INPLOOKUP_IPV6) + match = in6_pcbhashlookup(table, faddr6, fport, + laddr6, lport); + else +#endif + match = in_pcbhashlookup(table, faddr, fport, laddr, lport); + return (match); + } for (inp = LIST_FIRST(INPCBLHASH(table, lport)); inp; inp = LIST_NEXT(inp, inp_lhash)) { @@ -730,9 +757,6 @@ wildcard = 0; #ifdef INET6 if (flags & INPLOOKUP_IPV6) { - struct in6_addr *laddr6 = (struct in6_addr *)laddrp; - struct in6_addr *faddr6 = (struct in6_addr *)faddrp; - if (!(inp->inp_flags & INP_IPV6)) continue;