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.103 retrieving revision 1.109 diff -u -p -r1.103 -r1.109 --- src/sys/netinet/udp_usrreq.c 2003/06/29 22:32:01 1.103 +++ src/sys/netinet/udp_usrreq.c 2003/09/04 09:17:03 1.109 @@ -1,4 +1,4 @@ -/* $NetBSD: udp_usrreq.c,v 1.103 2003/06/29 22:32:01 fvdl Exp $ */ +/* $NetBSD: udp_usrreq.c,v 1.109 2003/09/04 09:17:03 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -41,11 +41,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -65,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.103 2003/06/29 22:32:01 fvdl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.109 2003/09/04 09:17:03 itojun Exp $"); #include "opt_inet.h" #include "opt_ipsec.h" @@ -119,6 +115,13 @@ __KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c #include +#ifdef FAST_IPSEC +#include +#ifdef INET6 +#include +#endif +#endif /* FAST_IPSEC*/ + #ifdef IPSEC #include #include @@ -192,9 +195,7 @@ void udp_init() { -#ifdef INET in_pcbinit(&udbtable, udbhashsize, udbhashsize); -#endif #ifdef UDP_CSUM_COUNTERS evcnt_attach_static(&udp_hwcsum_bad); @@ -275,11 +276,16 @@ udp_input(m, va_alist) UDP_CSUM_COUNTER_INCR(&udp_hwcsum_bad); goto badcsum; - case M_CSUM_UDPv4|M_CSUM_DATA: + case M_CSUM_UDPv4|M_CSUM_DATA: { + u_int32_t hw_csum = m->m_pkthdr.csum_data; UDP_CSUM_COUNTER_INCR(&udp_hwcsum_data); - if ((m->m_pkthdr.csum_data ^ 0xffff) != 0) + if (m->m_pkthdr.csum_flags & M_CSUM_NO_PSEUDOHDR) + hw_csum = in_cksum_phdr(ip->ip_src.s_addr, ip->ip_dst.s_addr, + htonl(hw_csum + ntohs(ip->ip_len) + IPPROTO_UDP)); + if ((hw_csum ^ 0xffff) != 0) goto badcsum; break; + } case M_CSUM_UDPv4: /* Checksum was okay. */ @@ -490,7 +496,7 @@ udp4_sendup(m, off, src, so) return; } -#ifdef IPSEC +#if defined(IPSEC) || defined(FAST_IPSEC) /* check AH/ESP integrity. */ if (so != NULL && ipsec4_in_reject_so(m, so)) { ipsecstat.in_polvio++; @@ -536,7 +542,7 @@ udp6_sendup(m, off, src, so) return; in6p = sotoin6pcb(so); -#ifdef IPSEC +#if defined(IPSEC) || defined(FAST_IPSEC) /* check AH/ESP integrity. */ if (so != NULL && ipsec6_in_reject_so(m, so)) { ipsec6stat.in_polvio++; @@ -574,6 +580,7 @@ udp4_realinput(src, dst, m, off) u_int16_t *sport, *dport; int rcvcnt; struct in_addr *src4, *dst4; + struct inpcb_hdr *inph; struct inpcb *inp; rcvcnt = 0; @@ -612,7 +619,11 @@ udp4_realinput(src, dst, m, off) /* * Locate pcb(s) for datagram. */ - CIRCLEQ_FOREACH(inp, &udbtable.inpt_queue, inp_queue) { + CIRCLEQ_FOREACH(inph, &udbtable.inpt_queue, inph_queue) { + inp = (struct inpcb *)inph; + if (inp->inp_af != AF_INET) + continue; + if (inp->inp_lport != *dport) continue; if (!in_nullhost(inp->inp_laddr)) { @@ -675,6 +686,7 @@ udp6_realinput(af, src, dst, m, off) int rcvcnt; struct in6_addr src6, dst6; const struct in_addr *dst4; + struct inpcb_hdr *inph; struct in6pcb *in6p; rcvcnt = 0; @@ -716,8 +728,11 @@ udp6_realinput(af, src, dst, m, off) /* * Locate pcb(s) for datagram. */ - for (in6p = udb6.in6p_next; in6p != &udb6; - in6p = in6p->in6p_next) { + CIRCLEQ_FOREACH(inph, &udbtable.inpt_queue, inph_queue) { + in6p = (struct in6pcb *)inph; + if (in6p->in6p_af != AF_INET6) + continue; + if (in6p->in6p_lport != dport) continue; if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr)) { @@ -758,11 +773,11 @@ udp6_realinput(af, src, dst, m, off) /* * Locate pcb for datagram. */ - in6p = in6_pcblookup_connect(&udb6, &src6, sport, + in6p = in6_pcblookup_connect(&udbtable, &src6, sport, &dst6, dport, 0); if (in6p == 0) { ++udpstat.udps_pcbhashmiss; - in6p = in6_pcblookup_bind(&udb6, &dst6, dport, 0); + in6p = in6_pcblookup_bind(&udbtable, &dst6, dport, 0); if (in6p == 0) return rcvcnt; } @@ -898,16 +913,9 @@ udp_output(m, va_alist) ((struct ip *)ui)->ip_tos = inp->inp_ip.ip_tos; /* XXX */ udpstat.udps_opackets++; -#ifdef IPSEC - if (ipsec_setsocket(m, inp->inp_socket) != 0) { - error = ENOBUFS; - goto release; - } -#endif /*IPSEC*/ - return (ip_output(m, inp->inp_options, &inp->inp_route, inp->inp_socket->so_options & (SO_DONTROUTE | SO_BROADCAST), - inp->inp_moptions)); + inp->inp_moptions, inp->inp_socket)); release: m_freem(m);