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.167 retrieving revision 1.169 diff -u -p -r1.167 -r1.169 --- src/sys/netinet/udp_usrreq.c 2008/04/15 03:57:04 1.167 +++ src/sys/netinet/udp_usrreq.c 2008/04/23 06:09:05 1.169 @@ -1,4 +1,4 @@ -/* $NetBSD: udp_usrreq.c,v 1.167 2008/04/15 03:57:04 thorpej Exp $ */ +/* $NetBSD: udp_usrreq.c,v 1.169 2008/04/23 06:09:05 thorpej Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.167 2008/04/15 03:57:04 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.169 2008/04/23 06:09:05 thorpej Exp $"); #include "opt_inet.h" #include "opt_ipsec.h" @@ -103,6 +103,7 @@ __KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c #include #include #include +#include #include #endif @@ -120,18 +121,20 @@ __KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c #ifdef FAST_IPSEC #include -#include /* XXX ipsecstat namespace */ +#include +#include #include #ifdef INET6 #include #endif -#endif /* FAST_IPSEC*/ +#endif /* FAST_IPSEC */ #ifdef IPSEC #include +#include #include #include -#endif /*IPSEC*/ +#endif /* IPSEC */ #ifdef IPKDB #include @@ -464,7 +467,7 @@ udp6_input_checksum(struct mbuf *m, cons goto good; } if (uh->uh_sum == 0) { - udp6stat.udp6s_nosum++; + UDP6_STATINC(UDP6_STAT_NOSUM); goto bad; } @@ -473,7 +476,7 @@ udp6_input_checksum(struct mbuf *m, cons M_CSUM_TCP_UDP_BAD | M_CSUM_DATA)) { case M_CSUM_UDPv6|M_CSUM_TCP_UDP_BAD: UDP_CSUM_COUNTER_INCR(&udp6_hwcsum_bad); - udp6stat.udp6s_badsum++; + UDP6_STATINC(UDP6_STAT_BADSUM); goto bad; #if 0 /* notyet */ @@ -492,7 +495,7 @@ udp6_input_checksum(struct mbuf *m, cons */ UDP_CSUM_COUNTER_INCR(&udp6_swcsum); if (in6_cksum(m, IPPROTO_UDP, off, len) != 0) { - udp6stat.udp6s_badsum++; + UDP6_STATINC(UDP6_STAT_BADSUM); goto bad; } } @@ -523,7 +526,7 @@ udp6_input(struct mbuf **mp, int *offp, } #endif - udp6stat.udp6s_ipackets++; + UDP6_STATINC(UDP6_STAT_IPACKETS); /* check for jumbogram is done in ip6_input. we can trust pkthdr.len */ plen = m->m_pkthdr.len - off; @@ -542,7 +545,7 @@ udp6_input(struct mbuf **mp, int *offp, ulen = plen; if (plen != ulen) { - udp6stat.udp6s_badlen++; + UDP6_STATINC(UDP6_STAT_BADLEN); goto bad; } @@ -580,10 +583,10 @@ udp6_input(struct mbuf **mp, int *offp, if (udp6_realinput(AF_INET6, &src, &dst, m, off) == 0) { if (m->m_flags & M_MCAST) { - udp6stat.udp6s_noportmcast++; + UDP6_STATINC(UDP6_STAT_NOPORTMCAST); goto bad; } - udp6stat.udp6s_noport++; + UDP6_STATINC(UDP6_STAT_NOPORT); icmp6_error(m, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0); m = NULL; } @@ -621,7 +624,7 @@ udp4_sendup(struct mbuf *m, int off /* o #if defined(IPSEC) || defined(FAST_IPSEC) /* check AH/ESP integrity. */ if (so != NULL && ipsec4_in_reject_so(m, so)) { - ipsecstat.in_polvio++; + IPSEC_STATINC(IPSEC_STAT_IN_POLVIO); if ((n = m_copypacket(m, M_DONTWAIT)) != NULL) icmp_error(n, ICMP_UNREACH, ICMP_UNREACH_ADMIN_PROHIBIT, 0, 0); @@ -668,7 +671,7 @@ udp6_sendup(struct mbuf *m, int off /* o #if defined(IPSEC) || defined(FAST_IPSEC) /* check AH/ESP integrity. */ if (so != NULL && ipsec6_in_reject_so(m, so)) { - ipsec6stat.in_polvio++; + IPSEC6_STATINC(IPSEC_STAT_IN_POLVIO); if ((n = m_copypacket(m, M_DONTWAIT)) != NULL) icmp6_error(n, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADMIN, 0); @@ -689,7 +692,7 @@ udp6_sendup(struct mbuf *m, int off /* o if (opts) m_freem(opts); so->so_rcv.sb_overflowed++; - udp6stat.udp6s_fullsock++; + UDP6_STATINC(UDP6_STAT_FULLSOCK); } else sorwakeup(so); } @@ -1334,36 +1337,16 @@ release: return (error); } -static void -udpstat_convert_to_user_cb(void *v1, void *v2, struct cpu_info *ci) -{ - uint64_t *udpsc = v1; - uint64_t *udps = v2; - u_int i; - - for (i = 0; i < UDP_NSTATS; i++) - udps[i] += udpsc[i]; -} - -static void -udpstat_convert_to_user(uint64_t *udps) -{ - - memset(udps, 0, sizeof(uint64_t) * UDP_NSTATS); - percpu_foreach(udpstat_percpu, udpstat_convert_to_user_cb, udps); -} - static int sysctl_net_inet_udp_stats(SYSCTLFN_ARGS) { - struct sysctlnode node; + netstat_sysctl_context ctx; uint64_t udps[UDP_NSTATS]; - udpstat_convert_to_user(udps); - node = *rnode; - node.sysctl_data = udps; - node.sysctl_size = sizeof(udps); - return (sysctl_lookup(SYSCTLFN_CALL(&node))); + ctx.ctx_stat = udpstat_percpu; + ctx.ctx_counters = udps; + ctx.ctx_ncounters = UDP_NSTATS; + return (NETSTAT_SYSCTL(&ctx)); } /*