Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/netinet/udp_usrreq.c,v retrieving revision 1.24.2.1 retrieving revision 1.25 diff -u -p -r1.24.2.1 -r1.25 --- src/sys/netinet/udp_usrreq.c 1996/02/02 06:13:02 1.24.2.1 +++ src/sys/netinet/udp_usrreq.c 1995/11/21 01:07:46 1.25 @@ -1,4 +1,4 @@ -/* $NetBSD: udp_usrreq.c,v 1.24.2.1 1996/02/02 06:13:02 mycroft Exp $ */ +/* $NetBSD: udp_usrreq.c,v 1.25 1995/11/21 01:07:46 cgd Exp $ */ /* * Copyright (c) 1982, 1986, 1988, 1990, 1993 @@ -68,21 +68,17 @@ int udpcksum = 0; /* XXX */ #endif struct sockaddr_in udp_in = { sizeof(udp_in), AF_INET }; +struct inpcb *udp_last_inpcb = 0; static void udp_detach __P((struct inpcb *)); static void udp_notify __P((struct inpcb *, int)); static struct mbuf *udp_saveopt __P((caddr_t, int, int)); -#ifndef UDBHASHSIZE -#define UDBHASHSIZE 128 -#endif -int udbhashsize = UDBHASHSIZE; - void udp_init() { - in_pcbinit(&udbtable, udbhashsize); + in_pcbinit(&udbtable); } void @@ -146,9 +142,8 @@ udp_input(m, iphlen) * Checksum extended UDP header and data. */ if (udpcksum && uh->uh_sum) { - ((struct ipovly *)ip)->ih_next = 0; - ((struct ipovly *)ip)->ih_prev = 0; - ((struct ipovly *)ip)->ih_x1 = 0; + bzero(((struct ipovly *)ip)->ih_x1, + sizeof ((struct ipovly *)ip)->ih_x1); ((struct ipovly *)ip)->ih_len = uh->uh_ulen; if (uh->uh_sum = in_cksum(m, len + sizeof (struct ip))) { udpstat.udps_badsum++; @@ -251,10 +246,13 @@ udp_input(m, iphlen) /* * Locate pcb for datagram. */ - inp = in_pcbhashlookup(&udbtable, ip->ip_src, uh->uh_sport, - ip->ip_dst, uh->uh_dport); - if (inp == 0) { - ++udpstat.udps_pcbhashmiss; + inp = udp_last_inpcb; + if (inp == 0 || + inp->inp_lport != uh->uh_dport || + inp->inp_fport != uh->uh_sport || + inp->inp_faddr.s_addr != ip->ip_src.s_addr || + inp->inp_laddr.s_addr != ip->ip_dst.s_addr) { + udpstat.udpps_pcbcachemiss++; inp = in_pcblookup(&udbtable, ip->ip_src, uh->uh_sport, ip->ip_dst, uh->uh_dport, INPLOOKUP_WILDCARD); if (inp == 0) { @@ -268,6 +266,7 @@ udp_input(m, iphlen) icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PORT, 0, 0); return; } + udp_last_inpcb = inp; } /* @@ -437,8 +436,7 @@ udp_output(inp, m, addr, control) * and addresses and length put into network format. */ ui = mtod(m, struct udpiphdr *); - ui->ui_next = ui->ui_prev = 0; - ui->ui_x1 = 0; + bzero(ui->ui_x1, sizeof ui->ui_x1); ui->ui_pr = IPPROTO_UDP; ui->ui_len = htons((u_int16_t)len + sizeof (struct udphdr)); ui->ui_src = inp->inp_laddr; @@ -623,6 +621,8 @@ udp_detach(inp) { int s = splsoftnet(); + if (inp == udp_last_inpcb) + udp_last_inpcb = 0; in_pcbdetach(inp); splx(s); }