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 rcsdiff: /ftp/cvs/cvsroot/src/sys/netinet/udp_usrreq.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.24 retrieving revision 1.26 diff -u -p -r1.24 -r1.26 --- src/sys/netinet/udp_usrreq.c 1995/08/12 23:59:42 1.24 +++ src/sys/netinet/udp_usrreq.c 1996/01/31 03:49:38 1.26 @@ -1,4 +1,4 @@ -/* $NetBSD: udp_usrreq.c,v 1.24 1995/08/12 23:59:42 mycroft Exp $ */ +/* $NetBSD: udp_usrreq.c,v 1.26 1996/01/31 03:49:38 mycroft Exp $ */ /* * Copyright (c) 1982, 1986, 1988, 1990, 1993 @@ -68,17 +68,21 @@ 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); + in_pcbinit(&udbtable, udbhashsize); } void @@ -142,9 +146,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++; @@ -247,13 +250,10 @@ udp_input(m, iphlen) /* * Locate pcb for datagram. */ - 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_pcbhashlookup(&udbtable, ip->ip_src, uh->uh_sport, + ip->ip_dst, uh->uh_dport); + if (inp == 0) { + ++udpstat.udps_pcbhashmiss; inp = in_pcblookup(&udbtable, ip->ip_src, uh->uh_sport, ip->ip_dst, uh->uh_dport, INPLOOKUP_WILDCARD); if (inp == 0) { @@ -267,7 +267,6 @@ 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,8 +621,6 @@ udp_detach(inp) { int s = splsoftnet(); - if (inp == udp_last_inpcb) - udp_last_inpcb = 0; in_pcbdetach(inp); splx(s); }