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.170 retrieving revision 1.172.2.1 diff -u -p -r1.170 -r1.172.2.1 --- src/sys/netinet/udp_usrreq.c 2008/04/24 11:38:38 1.170 +++ src/sys/netinet/udp_usrreq.c 2008/09/18 04:37:01 1.172.2.1 @@ -1,4 +1,4 @@ -/* $NetBSD: udp_usrreq.c,v 1.170 2008/04/24 11:38:38 ad Exp $ */ +/* $NetBSD: udp_usrreq.c,v 1.172.2.1 2008/09/18 04:37:01 wrstuden Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.170 2008/04/24 11:38:38 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.172.2.1 2008/09/18 04:37:01 wrstuden Exp $"); #include "opt_inet.h" #include "opt_ipsec.h" @@ -237,7 +237,12 @@ udp_init(void) MOWNER_ATTACH(&udp_rx_mowner); MOWNER_ATTACH(&udp_mowner); +#ifdef INET udpstat_percpu = percpu_alloc(sizeof(uint64_t) * UDP_NSTATS); +#endif +#ifdef INET6 + udp6stat_percpu = percpu_alloc(sizeof(uint64_t) * UDP6_NSTATS); +#endif } /* @@ -995,14 +1000,13 @@ udp_ctlinput(int cmd, const struct socka } int -udp_ctloutput(int op, struct socket *so, int level, int optname, - struct mbuf **mp) +udp_ctloutput(int op, struct socket *so, struct sockopt *sopt) { int s; int error = 0; - struct mbuf *m; struct inpcb *inp; int family; + int optval; family = so->so_proto->pr_domain->dom_family; @@ -1010,16 +1014,16 @@ udp_ctloutput(int op, struct socket *so, switch (family) { #ifdef INET case PF_INET: - if (level != IPPROTO_UDP) { - error = ip_ctloutput(op, so, level, optname, mp); + if (sopt->sopt_level != IPPROTO_UDP) { + error = ip_ctloutput(op, so, sopt); goto end; } break; #endif #ifdef INET6 case PF_INET6: - if (level != IPPROTO_UDP) { - error = ip6_ctloutput(op, so, level, optname, mp); + if (sopt->sopt_level != IPPROTO_UDP) { + error = ip6_ctloutput(op, so, sopt); goto end; } break; @@ -1032,17 +1036,15 @@ udp_ctloutput(int op, struct socket *so, switch (op) { case PRCO_SETOPT: - m = *mp; inp = sotoinpcb(so); - switch (optname) { + switch (sopt->sopt_name) { case UDP_ENCAP: - if (m == NULL || m->m_len != sizeof(int)) { - error = EINVAL; + error = sockopt_getint(sopt, &optval); + if (error) break; - } - switch(*mtod(m, int *)) { + switch(optval) { #ifdef IPSEC_NAT_T case 0: inp->inp_flags &= ~INP_ESPINUDP_ALL; @@ -1068,9 +1070,6 @@ udp_ctloutput(int op, struct socket *so, error = ENOPROTOOPT; break; } - if (m != NULL) { - m_free(m); - } break; default: @@ -1344,13 +1343,8 @@ release: static int sysctl_net_inet_udp_stats(SYSCTLFN_ARGS) { - netstat_sysctl_context ctx; - uint64_t udps[UDP_NSTATS]; - ctx.ctx_stat = udpstat_percpu; - ctx.ctx_counters = udps; - ctx.ctx_ncounters = UDP_NSTATS; - return (NETSTAT_SYSCTL(&ctx)); + return (NETSTAT_SYSCTL(udpstat_percpu, UDP_NSTATS)); } /*