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.52.2.3 retrieving revision 1.67 diff -u -p -r1.52.2.3 -r1.67 --- src/sys/netinet/udp_usrreq.c 2001/02/11 19:17:19 1.52.2.3 +++ src/sys/netinet/udp_usrreq.c 2000/06/28 03:01:17 1.67 @@ -1,4 +1,4 @@ -/* $NetBSD: udp_usrreq.c,v 1.52.2.3 2001/02/11 19:17:19 bouyer Exp $ */ +/* $NetBSD: udp_usrreq.c,v 1.67 2000/06/28 03:01:17 mrg Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -115,6 +115,7 @@ #ifdef IPSEC #include #include +#include #endif /*IPSEC*/ #ifdef IPKDB @@ -131,12 +132,10 @@ int udpcksum = 1; int udpcksum = 0; /* XXX */ #endif -#ifdef INET static void udp4_sendup __P((struct mbuf *, int, struct sockaddr *, struct socket *)); static int udp4_realinput __P((struct sockaddr_in *, struct sockaddr_in *, struct mbuf *, int)); -#endif #ifdef INET6 static void udp6_sendup __P((struct mbuf *, int, struct sockaddr *, struct socket *)); @@ -145,9 +144,7 @@ static int in6_mcmatch __P((struct in6pc static int udp6_realinput __P((int, struct sockaddr_in6 *, struct sockaddr_in6 *, struct mbuf *, int)); #endif -#ifdef INET static void udp_notify __P((struct inpcb *, int)); -#endif #ifndef UDBHASHSIZE #define UDBHASHSIZE 128 @@ -158,13 +155,10 @@ void udp_init() { -#ifdef INET in_pcbinit(&udbtable, udbhashsize, udbhashsize); -#endif } #ifndef UDP6 -#ifdef INET void #if __STDC__ udp_input(struct mbuf *m, ...) @@ -238,7 +232,7 @@ udp_input(m, va_alist) */ len = ntohs((u_int16_t)uh->uh_ulen); if (ip->ip_len != iphlen + len) { - if (ip->ip_len < iphlen + len || len < sizeof(struct udphdr)) { + if (ip->ip_len < iphlen + len) { udpstat.udps_badlen++; goto bad; } @@ -317,7 +311,6 @@ bad: if (m) m_freem(m); } -#endif #ifdef INET6 int @@ -361,10 +354,6 @@ udp6_input(mp, offp, proto) } #endif ulen = ntohs((u_short)uh->uh_ulen); - /* - * RFC2675 section 4: jumbograms will have 0 in the UDP header field, - * iff payload length > 0xffff. - */ if (ulen == 0 && plen > 0xffff) ulen = plen; @@ -401,14 +390,28 @@ udp6_input(mp, offp, proto) bzero(&src, sizeof(src)); src.sin6_family = AF_INET6; src.sin6_len = sizeof(struct sockaddr_in6); - /* KAME hack: recover scopeid */ - (void)in6_recoverscope(&src, &ip6->ip6_src, m->m_pkthdr.rcvif); + bcopy(&ip6->ip6_src, &src.sin6_addr, sizeof(src.sin6_addr)); + if (IN6_IS_SCOPE_LINKLOCAL(&src.sin6_addr)) + src.sin6_addr.s6_addr16[1] = 0; + if (m->m_pkthdr.rcvif) { + if (IN6_IS_SCOPE_LINKLOCAL(&src.sin6_addr)) + src.sin6_scope_id = m->m_pkthdr.rcvif->if_index; + else + src.sin6_scope_id = 0; + } src.sin6_port = uh->uh_sport; bzero(&dst, sizeof(dst)); dst.sin6_family = AF_INET6; dst.sin6_len = sizeof(struct sockaddr_in6); - /* KAME hack: recover scopeid */ - (void)in6_recoverscope(&dst, &ip6->ip6_dst, m->m_pkthdr.rcvif); + bcopy(&ip6->ip6_dst, &dst.sin6_addr, sizeof(dst.sin6_addr)); + if (IN6_IS_SCOPE_LINKLOCAL(&dst.sin6_addr)) + dst.sin6_addr.s6_addr16[1] = 0; + if (m->m_pkthdr.rcvif) { + if (IN6_IS_SCOPE_LINKLOCAL(&dst.sin6_addr)) + dst.sin6_scope_id = m->m_pkthdr.rcvif->if_index; + else + dst.sin6_scope_id = 0; + } dst.sin6_port = uh->uh_dport; if (udp6_realinput(AF_INET6, &src, &dst, m, off) == 0) { @@ -428,7 +431,6 @@ bad: } #endif -#ifdef INET static void udp4_sendup(m, off, src, so) struct mbuf *m; @@ -483,7 +485,6 @@ udp4_sendup(m, off, src, so) sorwakeup(so); } } -#endif #ifdef INET6 static void @@ -530,7 +531,6 @@ udp6_sendup(m, off, src, so) } #endif -#ifdef INET static int udp4_realinput(src, dst, m, off) struct sockaddr_in *src; @@ -554,7 +554,7 @@ udp4_realinput(src, dst, m, off) dst4 = &dst->sin_addr; dport = &dst->sin_port; - if (IN_MULTICAST(dst4->s_addr) || + if (IN_MULTICAST(src4->s_addr) || in_broadcast(*dst4, m->m_pkthdr.rcvif)) { struct inpcb *last; /* @@ -575,7 +575,7 @@ udp4_realinput(src, dst, m, off) /* * KAME note: usually we drop udpiphdr from mbuf here. - * we need udpiphdr for IPsec processing so we do that later. + * we need udpiphdr for iPsec processing so we do that later. */ /* * Locate pcb(s) for datagram. @@ -667,7 +667,6 @@ udp4_realinput(src, dst, m, off) bad: return rcvcnt; } -#endif #ifdef INET6 static int @@ -704,7 +703,7 @@ udp6_realinput(af, src, dst, m, off) u_int16_t *sport, *dport; int rcvcnt; struct in6_addr *src6, *dst6; - struct in_addr *dst4; + struct in_addr *src4; struct in6pcb *in6p; rcvcnt = 0; @@ -719,10 +718,10 @@ udp6_realinput(af, src, dst, m, off) sport = &src->sin6_port; dst6 = &dst->sin6_addr; dport = &dst->sin6_port; - dst4 = (struct in_addr *)&dst->sin6_addr.s6_addr32[12]; + src4 = (struct in_addr *)&src->sin6_addr.s6_addr32[12]; if (IN6_IS_ADDR_MULTICAST(dst6) - || (af == AF_INET && IN_MULTICAST(dst4->s_addr))) { + || (af == AF_INET && IN_MULTICAST(src4->s_addr))) { struct in6pcb *last; /* * Deliver a multicast or broadcast datagram to *all* sockets @@ -742,7 +741,7 @@ udp6_realinput(af, src, dst, m, off) /* * KAME note: usually we drop udpiphdr from mbuf here. - * we need udpiphdr for IPsec processing so we do that later. + * we need udpiphdr for iPsec processing so we do that later. */ /* * Locate pcb(s) for datagram. @@ -926,7 +925,7 @@ udp_input(m, va_alist) */ len = ntohs((u_int16_t)uh->uh_ulen); if (ip->ip_len != iphlen + len) { - if (ip->ip_len < iphlen + len || len < sizeof(struct udphdr)) { + if (ip->ip_len < iphlen + len) { udpstat.udps_badlen++; goto bad; } @@ -983,7 +982,7 @@ udp_input(m, va_alist) iphlen += sizeof(struct udphdr); /* * KAME note: usually we drop udpiphdr from mbuf here. - * we need udpiphdr for IPsec processing so we do that later. + * we need udpiphdr for iPsec processing so we do that later. */ /* * Locate pcb(s) for datagram. @@ -1139,7 +1138,6 @@ bad: } #endif /*UDP6*/ -#ifdef INET /* * Notify a udp user of an asynchronous error; * just wake up so that he can collect error status. @@ -1256,10 +1254,7 @@ udp_output(m, va_alist) udpstat.udps_opackets++; #ifdef IPSEC - if (ipsec_setsocket(m, inp->inp_socket) != 0) { - error = ENOBUFS; - goto release; - } + ipsec_setsocket(m, inp->inp_socket); #endif /*IPSEC*/ return (ip_output(m, inp->inp_options, &inp->inp_route, @@ -1478,4 +1473,3 @@ udp_sysctl(name, namelen, oldp, oldlenp, } /* NOTREACHED */ } -#endif