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.171.2.4 retrieving revision 1.172 diff -u -p -r1.171.2.4 -r1.172 --- src/sys/netinet/udp_usrreq.c 2010/03/11 15:04:29 1.171.2.4 +++ src/sys/netinet/udp_usrreq.c 2008/05/04 07:22:14 1.172 @@ -1,4 +1,4 @@ -/* $NetBSD: udp_usrreq.c,v 1.171.2.4 2010/03/11 15:04:29 yamt Exp $ */ +/* $NetBSD: udp_usrreq.c,v 1.172 2008/05/04 07:22:14 thorpej Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -61,10 +61,9 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.171.2.4 2010/03/11 15:04:29 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.172 2008/05/04 07:22:14 thorpej Exp $"); #include "opt_inet.h" -#include "opt_compat_netbsd.h" #include "opt_ipsec.h" #include "opt_inet_csum.h" #include "opt_ipkdb.h" @@ -137,10 +136,6 @@ __KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c #include #endif /* IPSEC */ -#ifdef COMPAT_50 -#include -#endif - #ifdef IPKDB #include #endif @@ -232,14 +227,10 @@ EVCNT_ATTACH_STATIC(udp6_swcsum); #endif /* UDP_CSUM_COUNTERS */ -static void sysctl_net_inet_udp_setup(struct sysctllog **); - void udp_init(void) { - sysctl_net_inet_udp_setup(NULL); - in_pcbinit(&udbtable, udbhashsize, udbhashsize); MOWNER_ATTACH(&udp_tx_mowner); @@ -417,18 +408,18 @@ udp_input(struct mbuf *m, ...) if (IN_MULTICAST(ip->ip_dst.s_addr) || n == 0) { struct sockaddr_in6 src6, dst6; - memset(&src6, 0, sizeof(src6)); + bzero(&src6, sizeof(src6)); src6.sin6_family = AF_INET6; src6.sin6_len = sizeof(struct sockaddr_in6); src6.sin6_addr.s6_addr[10] = src6.sin6_addr.s6_addr[11] = 0xff; - memcpy(&src6.sin6_addr.s6_addr[12], &ip->ip_src, + bcopy(&ip->ip_src, &src6.sin6_addr.s6_addr[12], sizeof(ip->ip_src)); src6.sin6_port = uh->uh_sport; - memset(&dst6, 0, sizeof(dst6)); + bzero(&dst6, sizeof(dst6)); dst6.sin6_family = AF_INET6; dst6.sin6_len = sizeof(struct sockaddr_in6); dst6.sin6_addr.s6_addr[10] = dst6.sin6_addr.s6_addr[11] = 0xff; - memcpy(&dst6.sin6_addr.s6_addr[12], &ip->ip_dst, + bcopy(&ip->ip_dst, &dst6.sin6_addr.s6_addr[12], sizeof(ip->ip_dst)); dst6.sin6_port = uh->uh_dport; @@ -584,12 +575,12 @@ udp6_input(struct mbuf **mp, int *offp, /* * Construct source and dst sockaddrs. */ - memset(&src, 0, sizeof(src)); + bzero(&src, sizeof(src)); src.sin6_family = AF_INET6; src.sin6_len = sizeof(struct sockaddr_in6); src.sin6_addr = ip6->ip6_src; src.sin6_port = uh->uh_sport; - memset(&dst, 0, sizeof(dst)); + bzero(&dst, sizeof(dst)); dst.sin6_family = AF_INET6; dst.sin6_len = sizeof(struct sockaddr_in6); dst.sin6_addr = ip6->ip6_dst; @@ -648,9 +639,6 @@ udp4_sendup(struct mbuf *m, int off /* o if ((n = m_copypacket(m, M_DONTWAIT)) != NULL) { if (inp && (inp->inp_flags & INP_CONTROLOPTS -#ifdef SO_OTIMESTAMP - || so->so_options & SO_OTIMESTAMP -#endif || so->so_options & SO_TIMESTAMP)) { struct ip *ip = mtod(n, struct ip *); ip_savecontrol(inp, &opts, ip, n); @@ -698,10 +686,7 @@ udp6_sendup(struct mbuf *m, int off /* o if ((n = m_copypacket(m, M_DONTWAIT)) != NULL) { if (in6p && (in6p->in6p_flags & IN6P_CONTROLOPTS -#ifdef SO_OTIMESTAMP - || in6p->in6p_socket->so_options & SO_OTIMESTAMP -#endif - || in6p->in6p_socket->so_options & SO_TIMESTAMP)) { + || in6p->in6p_socket->so_options & SO_TIMESTAMP)) { struct ip6_hdr *ip6 = mtod(n, struct ip6_hdr *); ip6_savecontrol(in6p, &opts, ip6, n); } @@ -840,12 +825,6 @@ udp4_realinput(struct sockaddr_in *src, } #endif - /* - * Check the minimum TTL for socket. - */ - if (mtod(m, struct ip *)->ip_ttl < inp->inp_ip_minttl) - goto bad; - udp4_sendup(m, off, (struct sockaddr *)src, inp->inp_socket); rcvcnt++; } @@ -1021,13 +1000,14 @@ udp_ctlinput(int cmd, const struct socka } int -udp_ctloutput(int op, struct socket *so, struct sockopt *sopt) +udp_ctloutput(int op, struct socket *so, int level, int optname, + struct mbuf **mp) { int s; int error = 0; + struct mbuf *m; struct inpcb *inp; int family; - int optval; family = so->so_proto->pr_domain->dom_family; @@ -1035,16 +1015,16 @@ udp_ctloutput(int op, struct socket *so, switch (family) { #ifdef INET case PF_INET: - if (sopt->sopt_level != IPPROTO_UDP) { - error = ip_ctloutput(op, so, sopt); + if (level != IPPROTO_UDP) { + error = ip_ctloutput(op, so, level, optname, mp); goto end; } break; #endif #ifdef INET6 case PF_INET6: - if (sopt->sopt_level != IPPROTO_UDP) { - error = ip6_ctloutput(op, so, sopt); + if (level != IPPROTO_UDP) { + error = ip6_ctloutput(op, so, level, optname, mp); goto end; } break; @@ -1057,15 +1037,17 @@ udp_ctloutput(int op, struct socket *so, switch (op) { case PRCO_SETOPT: + m = *mp; inp = sotoinpcb(so); - switch (sopt->sopt_name) { + switch (optname) { case UDP_ENCAP: - error = sockopt_getint(sopt, &optval); - if (error) + if (m == NULL || m->m_len != sizeof(int)) { + error = EINVAL; break; + } - switch(optval) { + switch(*mtod(m, int *)) { #ifdef IPSEC_NAT_T case 0: inp->inp_flags &= ~INP_ESPINUDP_ALL; @@ -1091,6 +1073,9 @@ udp_ctloutput(int op, struct socket *so, error = ENOPROTOOPT; break; } + if (m != NULL) { + m_free(m); + } break; default: @@ -1371,8 +1356,7 @@ sysctl_net_inet_udp_stats(SYSCTLFN_ARGS) /* * Sysctl for udp variables. */ -static void -sysctl_net_inet_udp_setup(struct sysctllog **clog) +SYSCTL_SETUP(sysctl_net_inet_udp_setup, "sysctl net.inet.udp subtree setup") { sysctl_createv(clog, 0, NULL, NULL,