Change IPv6 stats from a structure to an array of uint64_t's.

Note: This is ABI-compatible with the old ip6stat structure; old netstat
binaries will continue to work properly.
This commit is contained in:
thorpej 2008-04-08 23:37:43 +00:00
parent 1ef783cb7b
commit 3f466bce48
20 changed files with 324 additions and 349 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_bridge.c,v 1.57 2008/04/07 06:31:27 thorpej Exp $ */
/* $NetBSD: if_bridge.c,v 1.58 2008/04/08 23:37:43 thorpej Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@ -80,7 +80,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.57 2008/04/07 06:31:27 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.58 2008/04/08 23:37:43 thorpej Exp $");
#include "opt_bridge_ipf.h"
#include "opt_inet.h"
@ -2181,14 +2181,14 @@ bridge_ip6_checkbasic(struct mbuf **mp)
if ((m = m_copyup(m, sizeof(struct ip6_hdr),
(max_linkhdr + 3) & ~3)) == NULL) {
/* XXXJRT new stat, please */
ip6stat.ip6s_toosmall++;
ip6stat[IP6_STAT_TOOSMALL]++;
in6_ifstat_inc(inifp, ifs6_in_hdrerr);
goto bad;
}
} else if (__predict_false(m->m_len < sizeof(struct ip6_hdr))) {
struct ifnet *inifp = m->m_pkthdr.rcvif;
if ((m = m_pullup(m, sizeof(struct ip6_hdr))) == NULL) {
ip6stat.ip6s_toosmall++;
ip6stat[IP6_STAT_TOOSMALL]++;
in6_ifstat_inc(inifp, ifs6_in_hdrerr);
goto bad;
}
@ -2197,7 +2197,7 @@ bridge_ip6_checkbasic(struct mbuf **mp)
ip6 = mtod(m, struct ip6_hdr *);
if ((ip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) {
ip6stat.ip6s_badvers++;
ip6stat[IP6_STAT_BADVERS]++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_hdrerr);
goto bad;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: udp_usrreq.c,v 1.164 2008/04/06 20:17:27 thorpej Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.165 2008/04/08 23:37:43 thorpej Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.164 2008/04/06 20:17:27 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.165 2008/04/08 23:37:43 thorpej Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@ -525,7 +525,7 @@ udp6_input(struct mbuf **mp, int *offp, int proto)
plen = m->m_pkthdr.len - off;
IP6_EXTHDR_GET(uh, struct udphdr *, m, off, sizeof(struct udphdr));
if (uh == NULL) {
ip6stat.ip6s_tooshort++;
ip6stat[IP6_STAT_TOOSHORT]++;
return IPPROTO_DONE;
}
KASSERT(UDP_HDR_ALIGNED_P(uh));

View File

@ -1,4 +1,4 @@
/* $NetBSD: dest6.c,v 1.15 2006/11/16 01:33:45 christos Exp $ */
/* $NetBSD: dest6.c,v 1.16 2008/04/08 23:37:43 thorpej Exp $ */
/* $KAME: dest6.c,v 1.25 2001/02/22 01:39:16 itojun Exp $ */
/*
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dest6.c,v 1.15 2006/11/16 01:33:45 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: dest6.c,v 1.16 2008/04/08 23:37:43 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -81,7 +81,7 @@ dest6_input(struct mbuf **mp, int *offp, int proto)
for (optlen = 0; dstoptlen > 0; dstoptlen -= optlen, opt += optlen) {
if (*opt != IP6OPT_PAD1 &&
(dstoptlen < IP6OPT_MINLEN || *(opt + 1) + 2 > dstoptlen)) {
ip6stat.ip6s_toosmall++;
ip6stat[IP6_STAT_TOOSMALL]++;
goto bad;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: frag6.c,v 1.42 2008/02/27 19:40:56 matt Exp $ */
/* $NetBSD: frag6.c,v 1.43 2008/04/08 23:37:43 thorpej Exp $ */
/* $KAME: frag6.c,v 1.40 2002/05/27 21:40:31 itojun Exp $ */
/*
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: frag6.c,v 1.42 2008/02/27 19:40:56 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: frag6.c,v 1.43 2008/04/08 23:37:43 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -218,7 +218,7 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
return IPPROTO_DONE;
}
ip6stat.ip6s_fragments++;
ip6stat[IP6_STAT_FRAGMENTS]++;
in6_ifstat_inc(dstifp, ifs6_reass_reqd);
/* offset now points to data portion */
@ -552,7 +552,7 @@ insert:
m->m_pkthdr.len = plen;
}
ip6stat.ip6s_reassembled++;
ip6stat[IP6_STAT_REASSEMBLED]++;
in6_ifstat_inc(dstifp, ifs6_reass_ok);
/*
@ -567,7 +567,7 @@ insert:
dropfrag:
in6_ifstat_inc(dstifp, ifs6_reass_fail);
ip6stat.ip6s_fragdropped++;
ip6stat[IP6_STAT_FRAGDROPPED]++;
m_freem(m);
IP6Q_UNLOCK();
return IPPROTO_DONE;
@ -686,7 +686,7 @@ frag6_slowtimo(void)
--q6->ip6q_ttl;
q6 = q6->ip6q_next;
if (q6->ip6q_prev->ip6q_ttl == 0) {
ip6stat.ip6s_fragtimeout++;
ip6stat[IP6_STAT_FRAGTIMEOUT]++;
/* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
frag6_freef(q6->ip6q_prev);
}
@ -698,7 +698,7 @@ frag6_slowtimo(void)
*/
while (frag6_nfragpackets > (u_int)ip6_maxfragpackets &&
ip6q.ip6q_prev) {
ip6stat.ip6s_fragoverflow++;
ip6stat[IP6_STAT_FRAGOVERFLOW]++;
/* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
frag6_freef(ip6q.ip6q_prev);
}
@ -727,7 +727,7 @@ frag6_drain(void)
if (ip6q_lock_try() == 0)
return;
while (ip6q.ip6q_next != &ip6q) {
ip6stat.ip6s_fragdropped++;
ip6stat[IP6_STAT_FRAGDROPPED]++;
/* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
frag6_freef(ip6q.ip6q_next);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: icmp6.c,v 1.143 2008/04/08 15:04:35 thorpej Exp $ */
/* $NetBSD: icmp6.c,v 1.144 2008/04/08 23:37:43 thorpej Exp $ */
/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
/*
@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.143 2008/04/08 15:04:35 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.144 2008/04/08 23:37:43 thorpej Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@ -1898,7 +1898,7 @@ icmp6_rip6_input(struct mbuf **mp, int off)
sorwakeup(last->in6p_socket);
} else {
m_freem(m);
ip6stat.ip6s_delivered--;
ip6stat[IP6_STAT_DELIVERED]--;
}
return IPPROTO_DONE;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: in6_gif.c,v 1.53 2007/12/20 19:53:33 dyoung Exp $ */
/* $NetBSD: in6_gif.c,v 1.54 2008/04/08 23:37:43 thorpej Exp $ */
/* $KAME: in6_gif.c,v 1.62 2001/07/29 04:27:25 itojun Exp $ */
/*
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in6_gif.c,v 1.53 2007/12/20 19:53:33 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: in6_gif.c,v 1.54 2008/04/08 23:37:43 thorpej Exp $");
#include "opt_inet.h"
#include "opt_iso.h"
@ -230,13 +230,13 @@ int in6_gif_input(struct mbuf **mp, int *offp, int proto)
if (gifp == NULL || (gifp->if_flags & IFF_UP) == 0) {
m_freem(m);
ip6stat.ip6s_nogif++;
ip6stat[IP6_STAT_NOGIF]++;
return IPPROTO_DONE;
}
#ifndef GIF_ENCAPCHECK
if (!gif_validate6(ip6, (struct gif_softc *)gifp, m->m_pkthdr.rcvif)) {
m_freem(m);
ip6stat.ip6s_nogif++;
ip6stat[IP6_STAT_NOGIF]++;
return IPPROTO_DONE;
}
#endif
@ -289,7 +289,7 @@ int in6_gif_input(struct mbuf **mp, int *offp, int proto)
break;
#endif
default:
ip6stat.ip6s_nogif++;
ip6stat[IP6_STAT_NOGIF]++;
m_freem(m);
return IPPROTO_DONE;
}

View File

@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.41 2008/02/27 19:40:56 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.42 2008/04/08 23:37:43 thorpej Exp $");
#include "opt_inet.h"
@ -722,7 +722,7 @@ selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
error = EHOSTUNREACH;
}
if (error == EHOSTUNREACH)
ip6stat.ip6s_noroute++;
ip6stat[IP6_STAT_NOROUTE]++;
if (retifp != NULL)
*retifp = ifp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip6_etherip.c,v 1.7 2007/12/20 19:53:33 dyoung Exp $ */
/* $NetBSD: ip6_etherip.c,v 1.8 2008/04/08 23:37:43 thorpej Exp $ */
/*
* Copyright (c) 2006, Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip6_etherip.c,v 1.7 2007/12/20 19:53:33 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip6_etherip.c,v 1.8 2008/04/08 23:37:43 thorpej Exp $");
#include "opt_inet.h"
@ -202,7 +202,7 @@ ip6_etherip_input(struct mbuf *m, ...)
if (proto != IPPROTO_ETHERIP) {
m_freem(m);
ip6stat.ip6s_nogif++;
ip6stat[IP6_STAT_NOGIF]++;
return IPPROTO_DONE;
}
@ -230,7 +230,7 @@ ip6_etherip_input(struct mbuf *m, ...)
/* no matching device found */
if (!ifp) {
m_freem(m);
ip6stat.ip6s_odropped++;
ip6stat[IP6_STAT_ODROPPED]++;
return IPPROTO_DONE;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip6_flow.c,v 1.13 2008/01/04 23:35:00 dyoung Exp $ */
/* $NetBSD: ip6_flow.c,v 1.14 2008/04/08 23:37:43 thorpej Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip6_flow.c,v 1.13 2008/01/04 23:35:00 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip6_flow.c,v 1.14 2008/04/08 23:37:43 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -318,12 +318,12 @@ ip6flow_addstats(const struct ip6flow *ip6f)
if ((rt = rtcache_validate(&ip6f->ip6f_ro)) != NULL)
rt->rt_use += ip6f->ip6f_uses;
ip6stat.ip6s_fastforwardflows = ip6flow_inuse;
ip6stat.ip6s_cantforward += ip6f->ip6f_dropped;
ip6stat.ip6s_odropped += ip6f->ip6f_dropped;
ip6stat.ip6s_total += ip6f->ip6f_uses;
ip6stat.ip6s_forward += ip6f->ip6f_forwarded;
ip6stat.ip6s_fastforward += ip6f->ip6f_forwarded;
ip6stat[IP6_STAT_FASTFORWARDFLOWS] = ip6flow_inuse;
ip6stat[IP6_STAT_CANTFORWARD] += ip6f->ip6f_dropped;
ip6stat[IP6_STAT_ODROPPED] += ip6f->ip6f_dropped;
ip6stat[IP6_STAT_TOTAL] += ip6f->ip6f_uses;
ip6stat[IP6_STAT_FORWARD] += ip6f->ip6f_forwarded;
ip6stat[IP6_STAT_FASTFORWARD] += ip6f->ip6f_forwarded;
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip6_forward.c,v 1.62 2008/01/14 04:16:45 dyoung Exp $ */
/* $NetBSD: ip6_forward.c,v 1.63 2008/04/08 23:37:43 thorpej Exp $ */
/* $KAME: ip6_forward.c,v 1.109 2002/09/11 08:10:17 sakane Exp $ */
/*
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.62 2008/01/14 04:16:45 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip6_forward.c,v 1.63 2008/04/08 23:37:43 thorpej Exp $");
#include "opt_ipsec.h"
#include "opt_pfil_hooks.h"
@ -143,7 +143,7 @@ ip6_forward(struct mbuf *m, int srcrt)
if ((m->m_flags & (M_BCAST|M_MCAST)) != 0 ||
IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) ||
IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src)) {
ip6stat.ip6s_cantforward++;
ip6stat[IP6_STAT_CANTFORWARD]++;
/* XXX in6_ifstat_inc(rt->rt_ifp, ifs6_in_discard) */
if (ip6_log_time + ip6_log_interval < time_second) {
ip6_log_time = time_second;
@ -184,7 +184,7 @@ ip6_forward(struct mbuf *m, int srcrt)
IP_FORWARDING, &error);
if (sp == NULL) {
ipsec6stat.out_inval++;
ip6stat.ip6s_cantforward++;
ip6stat[IP6_STAT_CANTFORWARD]++;
if (mcopy) {
#if 0
/* XXX: what icmp ? */
@ -205,7 +205,7 @@ ip6_forward(struct mbuf *m, int srcrt)
* This packet is just discarded.
*/
ipsec6stat.out_polvio++;
ip6stat.ip6s_cantforward++;
ip6stat[IP6_STAT_CANTFORWARD]++;
key_freesp(sp);
if (mcopy) {
#if 0
@ -227,7 +227,7 @@ ip6_forward(struct mbuf *m, int srcrt)
if (sp->req == NULL) {
/* XXX should be panic ? */
printf("ip6_forward: No IPsec request specified.\n");
ip6stat.ip6s_cantforward++;
ip6stat[IP6_STAT_CANTFORWARD]++;
key_freesp(sp);
if (mcopy) {
#if 0
@ -311,7 +311,7 @@ ip6_forward(struct mbuf *m, int srcrt)
/* don't show these error codes to the user */
break;
}
ip6stat.ip6s_cantforward++;
ip6stat[IP6_STAT_CANTFORWARD]++;
if (mcopy) {
#if 0
/* XXX: what icmp ? */
@ -368,7 +368,7 @@ ip6_forward(struct mbuf *m, int srcrt)
sockaddr_in6_init(&u.dst6, &ip6->ip6_dst, 0, 0, 0);
if ((rt = rtcache_lookup(&ip6_forward_rt, &u.dst)) == NULL) {
ip6stat.ip6s_noroute++;
ip6stat[IP6_STAT_NOROUTE]++;
/* XXX in6_ifstat_inc(rt->rt_ifp, ifs6_in_noroute) */
if (mcopy) {
icmp6_error(mcopy, ICMP6_DST_UNREACH,
@ -383,7 +383,7 @@ ip6_forward(struct mbuf *m, int srcrt)
* rtcache_getdst(ip6_forward_rt)->sin6_addr was equal to
* ip6->ip6_dst
*/
ip6stat.ip6s_noroute++;
ip6stat[IP6_STAT_NOROUTE]++;
/* XXX in6_ifstat_inc(rt->rt_ifp, ifs6_in_noroute) */
if (mcopy) {
icmp6_error(mcopy, ICMP6_DST_UNREACH,
@ -409,14 +409,14 @@ ip6_forward(struct mbuf *m, int srcrt)
src_in6 = ip6->ip6_src;
if (in6_setscope(&src_in6, rt->rt_ifp, &outzone)) {
/* XXX: this should not happen */
ip6stat.ip6s_cantforward++;
ip6stat.ip6s_badscope++;
ip6stat[IP6_STAT_CANTFORWARD]++;
ip6stat[IP6_STAT_BADSCOPE]++;
m_freem(m);
return;
}
if (in6_setscope(&src_in6, m->m_pkthdr.rcvif, &inzone)) {
ip6stat.ip6s_cantforward++;
ip6stat.ip6s_badscope++;
ip6stat[IP6_STAT_CANTFORWARD]++;
ip6stat[IP6_STAT_BADSCOPE]++;
m_freem(m);
return;
}
@ -425,8 +425,8 @@ ip6_forward(struct mbuf *m, int srcrt)
&& !ipsecrt
#endif
) {
ip6stat.ip6s_cantforward++;
ip6stat.ip6s_badscope++;
ip6stat[IP6_STAT_CANTFORWARD]++;
ip6stat[IP6_STAT_BADSCOPE]++;
in6_ifstat_inc(rt->rt_ifp, ifs6_in_discard);
if (ip6_log_time + ip6_log_interval < time_second) {
@ -472,8 +472,8 @@ ip6_forward(struct mbuf *m, int srcrt)
if (in6_setscope(&dst_in6, m->m_pkthdr.rcvif, &inzone) != 0 ||
in6_setscope(&dst_in6, rt->rt_ifp, &outzone) != 0 ||
inzone != outzone) {
ip6stat.ip6s_cantforward++;
ip6stat.ip6s_badscope++;
ip6stat[IP6_STAT_CANTFORWARD]++;
ip6stat[IP6_STAT_BADSCOPE]++;
m_freem(m);
return;
}
@ -622,12 +622,12 @@ ip6_forward(struct mbuf *m, int srcrt)
error = nd6_output(rt->rt_ifp, origifp, m, dst, rt);
if (error) {
in6_ifstat_inc(rt->rt_ifp, ifs6_out_discard);
ip6stat.ip6s_cantforward++;
ip6stat[IP6_STAT_CANTFORWARD]++;
} else {
ip6stat.ip6s_forward++;
ip6stat[IP6_STAT_FORWARD]++;
in6_ifstat_inc(rt->rt_ifp, ifs6_out_forward);
if (type)
ip6stat.ip6s_redirectsent++;
ip6stat[IP6_STAT_REDIRECTSENT]++;
else {
#ifdef GATEWAY
if (m->m_flags & M_CANFASTFWD)

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip6_input.c,v 1.114 2008/02/27 19:40:56 matt Exp $ */
/* $NetBSD: ip6_input.c,v 1.115 2008/04/08 23:37:43 thorpej Exp $ */
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */
/*
@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.114 2008/02/27 19:40:56 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.115 2008/04/08 23:37:43 thorpej Exp $");
#include "opt_inet.h"
#include "opt_inet6.h"
@ -146,7 +146,7 @@ int ip6_sourcecheck_interval; /* XXX */
struct pfil_head inet6_pfil_hook;
#endif
struct ip6stat ip6stat;
uint64_t ip6stat[IP6_NSTATS];
static void ip6_init2(void *);
static struct m_tag *ip6_setdstifaddr(struct mbuf *, const struct in6_ifaddr *);
@ -280,25 +280,26 @@ ip6_input(struct mbuf *m)
*/
if (m->m_flags & M_EXT) {
if (m->m_next)
ip6stat.ip6s_mext2m++;
ip6stat[IP6_STAT_MEXT2M]++;
else
ip6stat.ip6s_mext1++;
ip6stat[IP6_STAT_MEXT1]++;
} else {
#define M2MMAX __arraycount(ip6stat.ip6s_m2m)
#define M2MMAX 32
if (m->m_next) {
if (m->m_flags & M_LOOP) {
ip6stat.ip6s_m2m[lo0ifp->if_index]++; /* XXX */
} else if (m->m_pkthdr.rcvif->if_index < M2MMAX)
ip6stat.ip6s_m2m[m->m_pkthdr.rcvif->if_index]++;
else
ip6stat.ip6s_m2m[0]++;
/*XXX*/ ip6stat[IP6_STAT_M2M + lo0ifp->if_index]++;
} else if (m->m_pkthdr.rcvif->if_index < M2MMAX) {
ip6stat[IP6_STAT_M2M +
m->m_pkthdr.rcvif->if_index]++;
} else
ip6stat[IP6_STAT_M2M]++;
} else
ip6stat.ip6s_m1++;
ip6stat[IP6_STAT_M1]++;
#undef M2MMAX
}
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_receive);
ip6stat.ip6s_total++;
ip6stat[IP6_STAT_TOTAL]++;
/*
* If the IPv6 header is not aligned, slurp it up into a new
@ -311,14 +312,14 @@ ip6_input(struct mbuf *m)
if ((m = m_copyup(m, sizeof(struct ip6_hdr),
(max_linkhdr + 3) & ~3)) == NULL) {
/* XXXJRT new stat, please */
ip6stat.ip6s_toosmall++;
ip6stat[IP6_STAT_TOOSMALL]++;
in6_ifstat_inc(inifp, ifs6_in_hdrerr);
return;
}
} else if (__predict_false(m->m_len < sizeof(struct ip6_hdr))) {
struct ifnet *inifp = m->m_pkthdr.rcvif;
if ((m = m_pullup(m, sizeof(struct ip6_hdr))) == NULL) {
ip6stat.ip6s_toosmall++;
ip6stat[IP6_STAT_TOOSMALL]++;
in6_ifstat_inc(inifp, ifs6_in_hdrerr);
return;
}
@ -327,7 +328,7 @@ ip6_input(struct mbuf *m)
ip6 = mtod(m, struct ip6_hdr *);
if ((ip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) {
ip6stat.ip6s_badvers++;
ip6stat[IP6_STAT_BADVERS]++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_hdrerr);
goto bad;
}
@ -376,7 +377,7 @@ ip6_input(struct mbuf *m)
}
#endif /* PFIL_HOOKS */
ip6stat.ip6s_nxthist[ip6->ip6_nxt]++;
ip6stat[IP6_STAT_NXTHIST + ip6->ip6_nxt]++;
#ifdef ALTQ
if (altq_input != NULL && (*altq_input)(m, AF_INET6) == 0) {
@ -393,7 +394,7 @@ ip6_input(struct mbuf *m)
/*
* XXX: "badscope" is not very suitable for a multicast source.
*/
ip6stat.ip6s_badscope++;
ip6stat[IP6_STAT_BADSCOPE]++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr);
goto bad;
}
@ -411,7 +412,7 @@ ip6_input(struct mbuf *m)
*/
if (IN6_IS_ADDR_V4MAPPED(&ip6->ip6_src) ||
IN6_IS_ADDR_V4MAPPED(&ip6->ip6_dst)) {
ip6stat.ip6s_badscope++;
ip6stat[IP6_STAT_BADSCOPE]++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr);
goto bad;
}
@ -425,7 +426,7 @@ ip6_input(struct mbuf *m)
*/
if (IN6_IS_ADDR_V4COMPAT(&ip6->ip6_src) ||
IN6_IS_ADDR_V4COMPAT(&ip6->ip6_dst)) {
ip6stat.ip6s_badscope++;
ip6stat[IP6_STAT_BADSCOPE]++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr);
goto bad;
}
@ -446,12 +447,12 @@ ip6_input(struct mbuf *m)
goto bad;
ip6 = mtod(m, struct ip6_hdr *);
if (in6_clearscope(&ip6->ip6_src) || in6_clearscope(&ip6->ip6_dst)) {
ip6stat.ip6s_badscope++; /* XXX */
ip6stat[IP6_STAT_BADSCOPE]++;/*XXX*/
goto bad;
}
if (in6_setscope(&ip6->ip6_src, m->m_pkthdr.rcvif, NULL) ||
in6_setscope(&ip6->ip6_dst, m->m_pkthdr.rcvif, NULL)) {
ip6stat.ip6s_badscope++;
ip6stat[IP6_STAT_BADSCOPE]++;
goto bad;
}
@ -470,8 +471,8 @@ ip6_input(struct mbuf *m)
if (in6m)
ours = 1;
else if (!ip6_mrouter) {
ip6stat.ip6s_notmember++;
ip6stat.ip6s_cantforward++;
ip6stat[IP6_STAT_NOTMEMBER]++;
ip6stat[IP6_STAT_CANTFORWARD]++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard);
goto bad;
}
@ -486,9 +487,9 @@ ip6_input(struct mbuf *m)
*/
rt = rtcache_lookup2(&ip6_forward_rt, &u.dst, 1, &hit);
if (hit)
ip6stat.ip6s_forward_cachehit++;
ip6stat[IP6_STAT_FORWARD_CACHEHIT]++;
else
ip6stat.ip6s_forward_cachemiss++;
ip6stat[IP6_STAT_FORWARD_CACHEMISS]++;
#define rt6_getkey(__rt) satocsin6(rt_getkey(__rt))
@ -578,7 +579,7 @@ ip6_input(struct mbuf *m)
* and we're not a router.
*/
if (!ip6_forwarding) {
ip6stat.ip6s_cantforward++;
ip6stat[IP6_STAT_CANTFORWARD]++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard);
goto bad;
}
@ -633,7 +634,7 @@ ip6_input(struct mbuf *m)
* contained, ip6_hopopts_input() must set a valid
* (non-zero) payload length to the variable plen.
*/
ip6stat.ip6s_badoptions++;
ip6stat[IP6_STAT_BADOPTIONS]++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard);
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_hdrerr);
icmp6_error(m, ICMP6_PARAM_PROB,
@ -644,7 +645,7 @@ ip6_input(struct mbuf *m)
IP6_EXTHDR_GET(hbh, struct ip6_hbh *, m, sizeof(struct ip6_hdr),
sizeof(struct ip6_hbh));
if (hbh == NULL) {
ip6stat.ip6s_tooshort++;
ip6stat[IP6_STAT_TOOSHORT]++;
return;
}
KASSERT(IP6_HDR_ALIGNED_P(hbh));
@ -666,7 +667,7 @@ ip6_input(struct mbuf *m)
* Drop packet if shorter than we expect.
*/
if (m->m_pkthdr.len - sizeof(struct ip6_hdr) < plen) {
ip6stat.ip6s_tooshort++;
ip6stat[IP6_STAT_TOOSHORT]++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_truncated);
goto bad;
}
@ -691,7 +692,7 @@ ip6_input(struct mbuf *m)
* must be discarded, else it may be accepted below.
*/
if (ip6_mrouter && ip6_mforward(ip6, m->m_pkthdr.rcvif, m)) {
ip6stat.ip6s_cantforward++;
ip6stat[IP6_STAT_CANTFORWARD]++;
m_freem(m);
return;
}
@ -717,7 +718,7 @@ ip6_input(struct mbuf *m)
*/
if (IN6_IS_ADDR_V4MAPPED(&ip6->ip6_src) ||
IN6_IS_ADDR_V4MAPPED(&ip6->ip6_dst)) {
ip6stat.ip6s_badscope++;
ip6stat[IP6_STAT_BADSCOPE]++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_addrerr);
goto bad;
}
@ -733,14 +734,14 @@ ip6_input(struct mbuf *m)
ia6->ia_ifa.ifa_data.ifad_inbytes += m->m_pkthdr.len;
}
#endif
ip6stat.ip6s_delivered++;
ip6stat[IP6_STAT_DELIVERED]++;
in6_ifstat_inc(deliverifp, ifs6_in_deliver);
nest = 0;
rh_present = 0;
while (nxt != IPPROTO_DONE) {
if (ip6_hdrnestlimit && (++nest > ip6_hdrnestlimit)) {
ip6stat.ip6s_toomanyhdr++;
ip6stat[IP6_STAT_TOOMANYHDR]++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_hdrerr);
goto bad;
}
@ -750,7 +751,7 @@ ip6_input(struct mbuf *m)
* more sanity checks in header chain processing.
*/
if (m->m_pkthdr.len < off) {
ip6stat.ip6s_tooshort++;
ip6stat[IP6_STAT_TOOSHORT]++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_truncated);
goto bad;
}
@ -759,7 +760,7 @@ ip6_input(struct mbuf *m)
if (rh_present++) {
in6_ifstat_inc(m->m_pkthdr.rcvif,
ifs6_in_hdrerr);
ip6stat.ip6s_badoptions++;
ip6stat[IP6_STAT_BADOPTIONS]++;
goto bad;
}
}
@ -873,14 +874,14 @@ ip6_hopopts_input(u_int32_t *plenp, u_int32_t *rtalertp,
IP6_EXTHDR_GET(hbh, struct ip6_hbh *, m,
sizeof(struct ip6_hdr), sizeof(struct ip6_hbh));
if (hbh == NULL) {
ip6stat.ip6s_tooshort++;
ip6stat[IP6_STAT_TOOSHORT]++;
return -1;
}
hbhlen = (hbh->ip6h_len + 1) << 3;
IP6_EXTHDR_GET(hbh, struct ip6_hbh *, m, sizeof(struct ip6_hdr),
hbhlen);
if (hbh == NULL) {
ip6stat.ip6s_tooshort++;
ip6stat[IP6_STAT_TOOSHORT]++;
return -1;
}
KASSERT(IP6_HDR_ALIGNED_P(hbh));
@ -924,7 +925,7 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
break;
case IP6OPT_PADN:
if (hbhlen < IP6OPT_MINLEN) {
ip6stat.ip6s_toosmall++;
ip6stat[IP6_STAT_TOOSMALL]++;
goto bad;
}
optlen = *(opt + 1) + 2;
@ -932,7 +933,7 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
case IP6OPT_RTALERT:
/* XXX may need check for alignment */
if (hbhlen < IP6OPT_RTALERT_LEN) {
ip6stat.ip6s_toosmall++;
ip6stat[IP6_STAT_TOOSMALL]++;
goto bad;
}
if (*(opt + 1) != IP6OPT_RTALERT_LEN - 2) {
@ -949,7 +950,7 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
case IP6OPT_JUMBO:
/* XXX may need check for alignment */
if (hbhlen < IP6OPT_JUMBO_LEN) {
ip6stat.ip6s_toosmall++;
ip6stat[IP6_STAT_TOOSMALL]++;
goto bad;
}
if (*(opt + 1) != IP6OPT_JUMBO_LEN - 2) {
@ -967,7 +968,7 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
*/
ip6 = mtod(m, struct ip6_hdr *);
if (ip6->ip6_plen) {
ip6stat.ip6s_badoptions++;
ip6stat[IP6_STAT_BADOPTIONS]++;
icmp6_error(m, ICMP6_PARAM_PROB,
ICMP6_PARAMPROB_HEADER,
erroff + opt - opthead);
@ -991,7 +992,7 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
* there's no explicit mention in specification.
*/
if (*plenp != 0) {
ip6stat.ip6s_badoptions++;
ip6stat[IP6_STAT_BADOPTIONS]++;
icmp6_error(m, ICMP6_PARAM_PROB,
ICMP6_PARAMPROB_HEADER,
erroff + opt + 2 - opthead);
@ -1003,7 +1004,7 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
* jumbo payload length must be larger than 65535.
*/
if (jumboplen <= IPV6_MAXPACKET) {
ip6stat.ip6s_badoptions++;
ip6stat[IP6_STAT_BADOPTIONS]++;
icmp6_error(m, ICMP6_PARAM_PROB,
ICMP6_PARAMPROB_HEADER,
erroff + opt + 2 - opthead);
@ -1014,7 +1015,7 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen,
break;
default: /* unknown option */
if (hbhlen < IP6OPT_MINLEN) {
ip6stat.ip6s_toosmall++;
ip6stat[IP6_STAT_TOOSMALL]++;
goto bad;
}
optlen = ip6_unknown_opt(opt, m,
@ -1051,11 +1052,11 @@ ip6_unknown_opt(u_int8_t *optp, struct mbuf *m, int off)
m_freem(m);
return (-1);
case IP6OPT_TYPE_FORCEICMP: /* send ICMP even if multicasted */
ip6stat.ip6s_badoptions++;
ip6stat[IP6_STAT_BADOPTIONS]++;
icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_OPTION, off);
return (-1);
case IP6OPT_TYPE_ICMP: /* send ICMP if not multicasted */
ip6stat.ip6s_badoptions++;
ip6stat[IP6_STAT_BADOPTIONS]++;
ip6 = mtod(m, struct ip6_hdr *);
if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) ||
(m->m_flags & (M_BCAST|M_MCAST)))
@ -1170,14 +1171,14 @@ ip6_savecontrol(struct in6pcb *in6p, struct mbuf **mp,
ext = ip6_pullexthdr(m, sizeof(struct ip6_hdr),
xip6->ip6_nxt);
if (ext == NULL) {
ip6stat.ip6s_tooshort++;
ip6stat[IP6_STAT_TOOSHORT]++;
return;
}
hbh = mtod(ext, struct ip6_hbh *);
hbhlen = (hbh->ip6h_len + 1) << 3;
if (hbhlen != ext->m_len) {
m_freem(ext);
ip6stat.ip6s_tooshort++;
ip6stat[IP6_STAT_TOOSHORT]++;
return;
}
@ -1229,7 +1230,7 @@ ip6_savecontrol(struct in6pcb *in6p, struct mbuf **mp,
ext = ip6_pullexthdr(m, off, nxt);
if (ext == NULL) {
ip6stat.ip6s_tooshort++;
ip6stat[IP6_STAT_TOOSHORT]++;
return;
}
ip6e = mtod(ext, struct ip6_ext *);
@ -1239,7 +1240,7 @@ ip6_savecontrol(struct in6pcb *in6p, struct mbuf **mp,
elen = (ip6e->ip6e_len + 1) << 3;
if (elen != ext->m_len) {
m_freem(ext);
ip6stat.ip6s_tooshort++;
ip6stat[IP6_STAT_TOOSHORT]++;
return;
}
KASSERT(IP6_HDR_ALIGNED_P(ip6e));
@ -1893,7 +1894,7 @@ SYSCTL_SETUP(sysctl_net_inet6_ip6_setup, "sysctl net.inet6.ip6 subtree setup")
CTLFLAG_PERMANENT,
CTLTYPE_STRUCT, "stats",
SYSCTL_DESCR("IPv6 statistics"),
NULL, 0, &ip6stat, sizeof(ip6stat),
NULL, 0, ip6stat, sizeof(ip6stat),
CTL_NET, PF_INET6, IPPROTO_IPV6,
IPV6CTL_STATS, CTL_EOL);
sysctl_createv(clog, 0, NULL, NULL,

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip6_mroute.c,v 1.87 2008/02/27 19:40:56 matt Exp $ */
/* $NetBSD: ip6_mroute.c,v 1.88 2008/04/08 23:37:43 thorpej Exp $ */
/* $KAME: ip6_mroute.c,v 1.49 2001/07/25 09:21:18 jinmei Exp $ */
/*
@ -117,7 +117,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.87 2008/02/27 19:40:56 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.88 2008/04/08 23:37:43 thorpej Exp $");
#include "opt_inet.h"
#include "opt_mrouting.h"
@ -1057,7 +1057,7 @@ ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m)
* (although such packets must normally set the hop limit field to 1).
*/
if (IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src)) {
ip6stat.ip6s_cantforward++;
ip6stat[IP6_STAT_CANTFORWARD]++;
if (ip6_log_time + ip6_log_interval < time_second) {
ip6_log_time = time_second;
log(LOG_DEBUG,
@ -1475,7 +1475,7 @@ ip6_mdq(struct mbuf *m, struct ifnet *ifp, struct mf6c *rt)
dst0 = ip6->ip6_dst;
if ((error = in6_setscope(&src0, ifp, &iszone)) != 0 ||
(error = in6_setscope(&dst0, ifp, &idzone)) != 0) {
ip6stat.ip6s_badscope++;
ip6stat[IP6_STAT_BADSCOPE]++;
return (error);
}
for (mifp = mif6table, mifi = 0; mifi < nummifs; mifp++, mifi++)
@ -1496,7 +1496,7 @@ ip6_mdq(struct mbuf *m, struct ifnet *ifp, struct mf6c *rt)
in6_setscope(&dst0, mif6table[mifi].m6_ifp,
&odzone) ||
iszone != oszone || idzone != odzone) {
ip6stat.ip6s_badscope++;
ip6stat[IP6_STAT_BADSCOPE]++;
continue;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip6_output.c,v 1.126 2008/01/14 04:16:45 dyoung Exp $ */
/* $NetBSD: ip6_output.c,v 1.127 2008/04/08 23:37:43 thorpej Exp $ */
/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
/*
@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.126 2008/01/14 04:16:45 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.127 2008/04/08 23:37:43 thorpej Exp $");
#include "opt_inet.h"
#include "opt_inet6.h"
@ -552,16 +552,16 @@ skip_ipsec2:;
if (IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_src) &&
(flags & IPV6_UNSPECSRC) == 0) {
error = EOPNOTSUPP;
ip6stat.ip6s_badscope++;
ip6stat[IP6_STAT_BADSCOPE]++;
goto bad;
}
if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_src)) {
error = EOPNOTSUPP;
ip6stat.ip6s_badscope++;
ip6stat[IP6_STAT_BADSCOPE]++;
goto bad;
}
ip6stat.ip6s_localout++;
ip6stat[IP6_STAT_LOCALOUT]++;
/*
* Route packet.
@ -759,7 +759,7 @@ skip_ipsec2:;
* Confirm that the outgoing interface supports multicast.
*/
if (!(ifp->if_flags & IFF_MULTICAST)) {
ip6stat.ip6s_noroute++;
ip6stat[IP6_STAT_NOROUTE]++;
in6_ifstat_inc(ifp, ifs6_out_discard);
error = ENETUNREACH;
goto bad;
@ -1092,7 +1092,7 @@ skip_ipsec2:;
MGETHDR(m, M_DONTWAIT, MT_HEADER);
if (!m) {
error = ENOBUFS;
ip6stat.ip6s_odropped++;
ip6stat[IP6_STAT_ODROPPED]++;
goto sendorfree;
}
m->m_pkthdr.rcvif = NULL;
@ -1105,7 +1105,7 @@ skip_ipsec2:;
m->m_len = sizeof(*mhip6);
error = ip6_insertfraghdr(m0, m, hlen, &ip6f);
if (error) {
ip6stat.ip6s_odropped++;
ip6stat[IP6_STAT_ODROPPED]++;
goto sendorfree;
}
ip6f->ip6f_offlg = htons((u_int16_t)((off - hlen) & ~7));
@ -1117,7 +1117,7 @@ skip_ipsec2:;
sizeof(*ip6f) - sizeof(struct ip6_hdr)));
if ((m_frgpart = m_copy(m0, off, len)) == 0) {
error = ENOBUFS;
ip6stat.ip6s_odropped++;
ip6stat[IP6_STAT_ODROPPED]++;
goto sendorfree;
}
for (mlast = m; mlast->m_next; mlast = mlast->m_next)
@ -1128,7 +1128,7 @@ skip_ipsec2:;
ip6f->ip6f_reserved = 0;
ip6f->ip6f_ident = id;
ip6f->ip6f_nxt = nextproto;
ip6stat.ip6s_ofragments++;
ip6stat[IP6_STAT_OFRAGMENTS]++;
in6_ifstat_inc(ifp, ifs6_out_fragcreat);
}
@ -1168,7 +1168,7 @@ sendorfree:
}
if (error == 0)
ip6stat.ip6s_fragmented++;
ip6stat[IP6_STAT_FRAGMENTED]++;
done:
rtcache_free(&ip6route);
@ -1195,7 +1195,7 @@ bad:
m_freem(m);
goto done;
badscope:
ip6stat.ip6s_badscope++;
ip6stat[IP6_STAT_BADSCOPE]++;
in6_ifstat_inc(origifp, ifs6_out_discard);
if (error == 0)
error = EHOSTUNREACH; /* XXX */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip6_var.h,v 1.47 2008/03/19 08:10:18 dyoung Exp $ */
/* $NetBSD: ip6_var.h,v 1.48 2008/04/08 23:37:43 thorpej Exp $ */
/* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */
/*
@ -155,69 +155,73 @@ struct ip6_pktopts {
#define IP6PO_DONTFRAG 0x04 /* disable fragmentation (IPV6_DONTFRAG) */
};
struct ip6stat {
u_quad_t ip6s_total; /* total packets received */
u_quad_t ip6s_tooshort; /* packet too short */
u_quad_t ip6s_toosmall; /* not enough data */
u_quad_t ip6s_fragments; /* fragments received */
u_quad_t ip6s_fragdropped; /* frags dropped(dups, out of space) */
u_quad_t ip6s_fragtimeout; /* fragments timed out */
u_quad_t ip6s_fragoverflow; /* fragments that exceeded limit */
u_quad_t ip6s_forward; /* packets forwarded */
u_quad_t ip6s_cantforward; /* packets rcvd for unreachable dest */
u_quad_t ip6s_redirectsent; /* packets forwarded on same net */
u_quad_t ip6s_delivered; /* datagrams delivered to upper level*/
u_quad_t ip6s_localout; /* total ip packets generated here */
u_quad_t ip6s_odropped; /* lost packets due to nobufs, etc. */
u_quad_t ip6s_reassembled; /* total packets reassembled ok */
u_quad_t ip6s_fragmented; /* datagrams successfully fragmented */
u_quad_t ip6s_ofragments; /* output fragments created */
u_quad_t ip6s_cantfrag; /* don't fragment flag was set, etc. */
u_quad_t ip6s_badoptions; /* error in option processing */
u_quad_t ip6s_noroute; /* packets discarded due to no route */
u_quad_t ip6s_badvers; /* ip6 version != 6 */
u_quad_t ip6s_rawout; /* total raw ip packets generated */
u_quad_t ip6s_badscope; /* scope error */
u_quad_t ip6s_notmember; /* don't join this multicast group */
u_quad_t ip6s_nxthist[256]; /* next header history */
u_quad_t ip6s_m1; /* one mbuf */
u_quad_t ip6s_m2m[32]; /* two or more mbuf */
u_quad_t ip6s_mext1; /* one ext mbuf */
u_quad_t ip6s_mext2m; /* two or more ext mbuf */
u_quad_t ip6s_exthdrtoolong; /* ext hdr are not continuous */
u_quad_t ip6s_nogif; /* no match gif found */
u_quad_t ip6s_toomanyhdr; /* discarded due to too many headers */
/*
* IPv6 statistics.
* Each counter is an unsigned 64-bit value.
*/
#define IP6_STAT_TOTAL 0 /* total packets received */
#define IP6_STAT_TOOSHORT 1 /* packet too short */
#define IP6_STAT_TOOSMALL 2 /* not enough data */
#define IP6_STAT_FRAGMENTS 3 /* fragments received */
#define IP6_STAT_FRAGDROPPED 4 /* frags dropped (dups, out of space) */
#define IP6_STAT_FRAGTIMEOUT 5 /* fragments timed out */
#define IP6_STAT_FRAGOVERFLOW 6 /* fragments that exceed limit */
#define IP6_STAT_FORWARD 7 /* packets forwarded */
#define IP6_STAT_CANTFORWARD 8 /* packets rcvd for uncreachable dst */
#define IP6_STAT_REDIRECTSENT 9 /* packets forwarded on same net */
#define IP6_STAT_DELIVERED 10 /* datagrams delivered to upper level */
#define IP6_STAT_LOCALOUT 11 /* total IP packets generated here */
#define IP6_STAT_ODROPPED 12 /* lost packets due to nobufs, etc. */
#define IP6_STAT_REASSEMBLED 13 /* total packets reassembled ok */
#define IP6_STAT_FRAGMENTED 14 /* datagrams successfully fragmented */
#define IP6_STAT_OFRAGMENTS 15 /* output fragments created */
#define IP6_STAT_CANTFRAG 16 /* don't fragment flag was set, etc. */
#define IP6_STAT_BADOPTIONS 17 /* error in option processing */
#define IP6_STAT_NOROUTE 18 /* packets discarded due to no route */
#define IP6_STAT_BADVERS 19 /* ip6 version != 6 */
#define IP6_STAT_RAWOUT 20 /* total raw ip packets generated */
#define IP6_STAT_BADSCOPE 21 /* scope error */
#define IP6_STAT_NOTMEMBER 22 /* don't join this multicast group */
#define IP6_STAT_NXTHIST 23 /* next header histogram */
/* space for 256 counters */
#define IP6_STAT_M1 279 /* one mbuf */
#define IP6_STAT_M2M 280 /* two or more mbuf */
/* space for 32 counters */
#define IP6_STAT_MEXT1 312 /* one ext mbuf */
#define IP6_STAT_MEXT2M 313 /* two or more ext mbuf */
#define IP6_STAT_EXTHDRTOOLONG 314 /* ext hdr are not contiguous */
#define IP6_STAT_NOGIF 315 /* no match gif found */
#define IP6_STAT_TOOMANYHDR 316 /* discarded due to too many headers */
/*
* statistics for improvement of the source address selection
* algorithm:
* XXX: hardcoded 16 = # of ip6 multicast scope types + 1
*/
/* number of times that address selection fails */
u_quad_t ip6s_sources_none;
/* number of times that an address on the outgoing I/F is chosen */
u_quad_t ip6s_sources_sameif[16];
/* number of times that an address on a non-outgoing I/F is chosen */
u_quad_t ip6s_sources_otherif[16];
/*
* number of times that an address that has the same scope
* from the destination is chosen.
*/
u_quad_t ip6s_sources_samescope[16];
/*
* number of times that an address that has a different scope
* from the destination is chosen.
*/
u_quad_t ip6s_sources_otherscope[16];
/* number of times that an deprecated address is chosen */
u_quad_t ip6s_sources_deprecated[16];
#define IP6_STAT_SOURCES_NONE 317 /* number of times that address
selection fails */
#define IP6_STAT_SOURCES_SAMEIF 318 /* number of times that an address
on the outgoing I/F is chosen */
/* space for 16 counters */
#define IP6_STAT_SOURCES_OTHERIF 334 /* number of times that an address on
a non-outgoing I/F is chosen */
/* space for 16 counters */
#define IP6_STAT_SOURCES_SAMESCOPE 350 /* number of times that an address that
has the same scope from the dest.
is chosen */
/* space for 16 counters */
#define IP6_STAT_SOURCES_OTHERSCOPE 366 /* number of times that an address that
has a different scope from the dest.
is chosen */
/* space for 16 counters */
#define IP6_STAT_SOURCES_DEPRECATED 382 /* number of times that a deprecated
address is chosen */
/* space for 16 counters */
#define IP6_STAT_FORWARD_CACHEHIT 398
#define IP6_STAT_FORWARD_CACHEMISS 399
#define IP6_STAT_FASTFORWARD 400 /* packets fast forwarded */
#define IP6_STAT_FASTFORWARDFLOWS 401 /* number of fast forward flows */
u_quad_t ip6s_forward_cachehit;
u_quad_t ip6s_forward_cachemiss;
u_quad_t ip6s_fastforward; /* packets fast forwarded */
u_quad_t ip6s_fastforwardflows; /* number of fast forward flows*/
};
#define IP6_NSTATS 402
#define IP6FLOW_HASHBITS 6 /* should not be a multiple of 8 */
@ -263,7 +267,7 @@ struct ip6aux {
#define IP6_HDR_ALIGNED_P(ip) ((((vaddr_t) (ip)) & 3) == 0)
#endif
extern struct ip6stat ip6stat; /* statistics */
extern uint64_t ip6stat[IP6_NSTATS]; /* statistics */
extern u_int32_t ip6_id; /* fragment identifier */
extern int ip6_defhlim; /* default hop limit */
extern int ip6_defmcasthlim; /* default multicast hop limit */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ipsec.c,v 1.125 2008/04/07 06:31:28 thorpej Exp $ */
/* $NetBSD: ipsec.c,v 1.126 2008/04/08 23:37:43 thorpej Exp $ */
/* $KAME: ipsec.c,v 1.136 2002/05/19 00:36:39 itojun Exp $ */
/*
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.125 2008/04/07 06:31:28 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.126 2008/04/08 23:37:43 thorpej Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@ -3026,7 +3026,7 @@ ipsec6_output_tunnel(struct ipsec_output_state *state, struct secpolicy *sp,
sockaddr_in6_init(&u.dst6, &ip6->ip6_dst, 0, 0, 0);
if ((rt = rtcache_lookup(state->ro, &u.dst)) == NULL) {
rtcache_free(state->ro);
ip6stat.ip6s_noroute++;
ip6stat[IP6_STAT_NOROUTE]++;
ipsec6stat.out_noroute++;
error = EHOSTUNREACH;
goto bad;

View File

@ -1,4 +1,4 @@
/* $NetBSD: raw_ip6.c,v 1.92 2008/04/08 15:04:35 thorpej Exp $ */
/* $NetBSD: raw_ip6.c,v 1.93 2008/04/08 23:37:43 thorpej Exp $ */
/* $KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $ */
/*
@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.92 2008/04/08 15:04:35 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.93 2008/04/08 23:37:43 thorpej Exp $");
#include "opt_ipsec.h"
@ -235,7 +235,7 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
if (last && ipsec6_in_reject(m, last)) {
m_freem(m);
ipsec6stat.in_polvio++;
ip6stat.ip6s_delivered--;
ip6stat[IP6_STAT_DELIVERED]--;
/* do not inject data into pcb */
} else
#endif /* IPSEC */
@ -249,7 +249,7 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
*/
if (!last)
ipsec6stat.in_polvio++;
ip6stat.ip6s_delivered--;
ip6stat[IP6_STAT_DELIVERED]--;
/* do not inject data into pcb */
} else
#endif /* FAST_IPSEC */
@ -279,7 +279,7 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
ICMP6_PARAMPROB_NEXTHEADER,
prvnxtp - mtod(m, u_int8_t *));
}
ip6stat.ip6s_delivered--;
ip6stat[IP6_STAT_DELIVERED]--;
}
return IPPROTO_DONE;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: route6.c,v 1.21 2007/10/29 16:54:43 dyoung Exp $ */
/* $NetBSD: route6.c,v 1.22 2008/04/08 23:37:43 thorpej Exp $ */
/* $KAME: route6.c,v 1.22 2000/12/03 00:54:00 itojun Exp $ */
/*
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: route6.c,v 1.21 2007/10/29 16:54:43 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: route6.c,v 1.22 2008/04/08 23:37:43 thorpej Exp $");
#include <sys/param.h>
#include <sys/mbuf.h>
@ -64,7 +64,7 @@ route6_input(struct mbuf **mp, int *offp, int proto)
ip6 = mtod(m, struct ip6_hdr *);
IP6_EXTHDR_GET(rh, struct ip6_rthdr *, m, off, sizeof(*rh));
if (rh == NULL) {
ip6stat.ip6s_tooshort++;
ip6stat[IP6_STAT_TOOSHORT]++;
return IPPROTO_DONE;
}
@ -97,7 +97,7 @@ route6_input(struct mbuf **mp, int *offp, int proto)
*/
IP6_EXTHDR_GET(rh, struct ip6_rthdr *, m, off, rhlen);
if (rh == NULL) {
ip6stat.ip6s_tooshort++;
ip6stat[IP6_STAT_TOOSHORT]++;
return IPPROTO_DONE;
}
if (ip6_rthdr0(m, ip6, (struct ip6_rthdr0 *)rh))
@ -110,7 +110,7 @@ route6_input(struct mbuf **mp, int *offp, int proto)
rhlen = (rh->ip6r_len + 1) << 3;
break; /* Final dst. Just ignore the header. */
}
ip6stat.ip6s_badoptions++;
ip6stat[IP6_STAT_BADOPTIONS]++;
icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,
(char *)&rh->ip6r_type - (char *)ip6);
return (IPPROTO_DONE);
@ -148,14 +148,14 @@ ip6_rthdr0(struct mbuf *m, struct ip6_hdr *ip6,
* RFC 2462: this limitation was removed since strict/loose
* bitmap field was deleted.
*/
ip6stat.ip6s_badoptions++;
ip6stat[IP6_STAT_BADOPTIONS]++;
icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,
(char *)&rh0->ip6r0_len - (char *)ip6);
return (-1);
}
if ((addrs = rh0->ip6r0_len / 2) < rh0->ip6r0_segleft) {
ip6stat.ip6s_badoptions++;
ip6stat[IP6_STAT_BADOPTIONS]++;
icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,
(char *)&rh0->ip6r0_segleft - (char *)ip6);
return (-1);
@ -174,14 +174,14 @@ ip6_rthdr0(struct mbuf *m, struct ip6_hdr *ip6,
IN6_IS_ADDR_UNSPECIFIED(nextaddr) ||
IN6_IS_ADDR_V4MAPPED(nextaddr) ||
IN6_IS_ADDR_V4COMPAT(nextaddr)) {
ip6stat.ip6s_badoptions++;
p6stat[IP6_STAT_BADOPTIONS]++;
goto bad;
}
if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) ||
IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_dst) ||
IN6_IS_ADDR_V4MAPPED(&ip6->ip6_dst) ||
IN6_IS_ADDR_V4COMPAT(&ip6->ip6_dst)) {
ip6stat.ip6s_badoptions++;
ip6stat[IP6_STAT_BADOPTIONS]++;
goto bad;
}
@ -193,7 +193,7 @@ ip6_rthdr0(struct mbuf *m, struct ip6_hdr *ip6,
if ((ip6a = ip6_getdstifaddr(m)) == NULL)
goto bad;
if (in6_setzoneid(nextaddr, ip6a->ip6a_scope_id) != 0) {
ip6stat.ip6s_badscope++;
ip6stat[IP6_STAT_BADSCOPE]++;
goto bad;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ipsec_input.c,v 1.17 2007/06/27 20:38:33 degroote Exp $ */
/* $NetBSD: ipsec_input.c,v 1.18 2008/04/08 23:37:43 thorpej Exp $ */
/* $FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec_input.c,v 1.2.4.2 2003/03/28 20:32:53 sam Exp $ */
/* $OpenBSD: ipsec_input.c,v 1.63 2003/02/20 18:35:43 deraadt Exp $ */
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.17 2007/06/27 20:38:33 degroote Exp $");
__KERNEL_RCSID(0, "$NetBSD: ipsec_input.c,v 1.18 2008/04/08 23:37:43 thorpej Exp $");
/*
* IPsec input processing.
@ -759,7 +759,7 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, int proto
nxt = nxt8;
while (nxt != IPPROTO_DONE) {
if (ip6_hdrnestlimit && (++nest > ip6_hdrnestlimit)) {
ip6stat.ip6s_toomanyhdr++;
ip6stat[IP6_STAT_TOOMANYHDR]++;
error = EINVAL;
goto bad;
}
@ -769,7 +769,7 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, int proto
* more sanity checks in header chain processing.
*/
if (m->m_pkthdr.len < skip) {
ip6stat.ip6s_tooshort++;
ip6stat[IP6_STAT_TOOSHORT]++;
in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_truncated);
error = EINVAL;
goto bad;

View File

@ -1,4 +1,4 @@
/* $NetBSD: inet6.c,v 1.44 2008/04/08 15:04:35 thorpej Exp $ */
/* $NetBSD: inet6.c,v 1.45 2008/04/08 23:37:43 thorpej Exp $ */
/* BSDI inet.c,v 2.3 1995/10/24 02:19:29 prb Exp */
/*
@ -64,7 +64,7 @@
#if 0
static char sccsid[] = "@(#)inet.c 8.4 (Berkeley) 4/20/94";
#else
__RCSID("$NetBSD: inet6.c,v 1.44 2008/04/08 15:04:35 thorpej Exp $");
__RCSID("$NetBSD: inet6.c,v 1.45 2008/04/08 23:37:43 thorpej Exp $");
#endif
#endif /* not lint */
@ -476,7 +476,7 @@ udp6_stats(off, name)
#undef p1
}
static char *ip6nh[] = {
static const char *ip6nh[] = {
/*0*/ "hop by hop",
"ICMP",
"IGMP",
@ -575,11 +575,9 @@ static char *ip6nh[] = {
* Dump IP6 statistics structure.
*/
void
ip6_stats(off, name)
u_long off;
char *name;
ip6_stats(u_long off, char *name)
{
struct ip6stat ip6stat;
uint64_t ip6stat[IP6_NSTATS];
int first, i;
struct protoent *ep;
const char *n;
@ -587,50 +585,50 @@ ip6_stats(off, name)
if (use_sysctl) {
size_t size = sizeof(ip6stat);
if (sysctlbyname("net.inet6.ip6.stats", &ip6stat, &size,
if (sysctlbyname("net.inet6.ip6.stats", ip6stat, &size,
NULL, 0) == -1)
err(1, "net.inet6.ip6.stats");
} else {
if (off == 0)
return;
kread(off, (char *)&ip6stat, sizeof (ip6stat));
kread(off, (char *)ip6stat, sizeof (ip6stat));
}
printf("%s:\n", name);
#define p(f, m) if (ip6stat.f || sflag <= 1) \
printf(m, (unsigned long long)ip6stat.f, plural(ip6stat.f))
#define p1(f, m) if (ip6stat.f || sflag <= 1) \
printf(m, (unsigned long long)ip6stat.f)
#define p(f, m) if (ip6stat[f] || sflag <= 1) \
printf(m, (unsigned long long)ip6stat[f], plural(ip6stat[f]))
#define p1(f, m) if (ip6stat[f] || sflag <= 1) \
printf(m, (unsigned long long)ip6stat[f])
p(ip6s_total, "\t%llu total packet%s received\n");
p1(ip6s_toosmall, "\t%llu with size smaller than minimum\n");
p1(ip6s_tooshort, "\t%llu with data size < data length\n");
p1(ip6s_badoptions, "\t%llu with bad options\n");
p1(ip6s_badvers, "\t%llu with incorrect version number\n");
p(ip6s_fragments, "\t%llu fragment%s received\n");
p(ip6s_fragdropped,
p(IP6_STAT_TOTAL, "\t%llu total packet%s received\n");
p1(IP6_STAT_TOOSMALL, "\t%llu with size smaller than minimum\n");
p1(IP6_STAT_TOOSHORT, "\t%llu with data size < data length\n");
p1(IP6_STAT_BADOPTIONS, "\t%llu with bad options\n");
p1(IP6_STAT_BADVERS, "\t%llu with incorrect version number\n");
p(IP6_STAT_FRAGMENTS, "\t%llu fragment%s received\n");
p(IP6_STAT_FRAGDROPPED,
"\t%llu fragment%s dropped (dup or out of space)\n");
p(ip6s_fragtimeout, "\t%llu fragment%s dropped after timeout\n");
p(ip6s_fragoverflow, "\t%llu fragment%s that exceeded limit\n");
p(ip6s_reassembled, "\t%llu packet%s reassembled ok\n");
p(ip6s_delivered, "\t%llu packet%s for this host\n");
p(ip6s_forward, "\t%llu packet%s forwarded\n");
p(ip6s_fastforward, "\t%llu packet%s fast forwarded\n");
p1(ip6s_fastforwardflows, "\t%llu fast forward flows\n");
p(ip6s_cantforward, "\t%llu packet%s not forwardable\n");
p(ip6s_redirectsent, "\t%llu redirect%s sent\n");
p(ip6s_localout, "\t%llu packet%s sent from this host\n");
p(ip6s_rawout, "\t%llu packet%s sent with fabricated ip header\n");
p(ip6s_odropped,
p(IP6_STAT_FRAGTIMEOUT, "\t%llu fragment%s dropped after timeout\n");
p(IP6_STAT_FRAGOVERFLOW, "\t%llu fragment%s that exceeded limit\n");
p(IP6_STAT_REASSEMBLED, "\t%llu packet%s reassembled ok\n");
p(IP6_STAT_DELIVERED, "\t%llu packet%s for this host\n");
p(IP6_STAT_FORWARD, "\t%llu packet%s forwarded\n");
p(IP6_STAT_FASTFORWARD, "\t%llu packet%s fast forwarded\n");
p1(IP6_STAT_FASTFORWARDFLOWS, "\t%llu fast forward flows\n");
p(IP6_STAT_CANTFORWARD, "\t%llu packet%s not forwardable\n");
p(IP6_STAT_REDIRECTSENT, "\t%llu redirect%s sent\n");
p(IP6_STAT_LOCALOUT, "\t%llu packet%s sent from this host\n");
p(IP6_STAT_RAWOUT, "\t%llu packet%s sent with fabricated ip header\n");
p(IP6_STAT_ODROPPED,
"\t%llu output packet%s dropped due to no bufs, etc.\n");
p(ip6s_noroute, "\t%llu output packet%s discarded due to no route\n");
p(ip6s_fragmented, "\t%llu output datagram%s fragmented\n");
p(ip6s_ofragments, "\t%llu fragment%s created\n");
p(ip6s_cantfrag, "\t%llu datagram%s that can't be fragmented\n");
p(ip6s_badscope, "\t%llu packet%s that violated scope rules\n");
p(ip6s_notmember, "\t%llu multicast packet%s which we don't join\n");
p(IP6_STAT_NOROUTE, "\t%llu output packet%s discarded due to no route\n");
p(IP6_STAT_FRAGMENTED, "\t%llu output datagram%s fragmented\n");
p(IP6_STAT_OFRAGMENTS, "\t%llu fragment%s created\n");
p(IP6_STAT_CANTFRAG, "\t%llu datagram%s that can't be fragmented\n");
p(IP6_STAT_BADSCOPE, "\t%llu packet%s that violated scope rules\n");
p(IP6_STAT_NOTMEMBER, "\t%llu multicast packet%s which we don't join\n");
for (first = 1, i = 0; i < 256; i++)
if (ip6stat.ip6s_nxthist[i] != 0) {
if (ip6stat[IP6_STAT_NXTHIST + i] != 0) {
if (first) {
printf("\tInput packet histogram:\n");
first = 0;
@ -642,31 +640,31 @@ ip6_stats(off, name)
n = ep->p_name;
if (n)
printf("\t\t%s: %llu\n", n,
(unsigned long long)ip6stat.ip6s_nxthist[i]);
(unsigned long long)ip6stat[IP6_STAT_NXTHIST + i]);
else
printf("\t\t#%d: %llu\n", i,
(unsigned long long)ip6stat.ip6s_nxthist[i]);
(unsigned long long)ip6stat[IP6_STAT_NXTHIST + i]);
}
printf("\tMbuf statistics:\n");
p(ip6s_m1, "\t\t%llu one mbuf%s\n");
p(IP6_STAT_M1, "\t\t%llu one mbuf%s\n");
for (first = 1, i = 0; i < 32; i++) {
char ifbuf[IFNAMSIZ];
if (ip6stat.ip6s_m2m[i] != 0) {
if (ip6stat[IP6_STAT_M2M + i] != 0) {
if (first) {
printf("\t\ttwo or more mbuf:\n");
first = 0;
}
printf("\t\t\t%s = %llu\n",
if_indextoname(i, ifbuf),
(unsigned long long)ip6stat.ip6s_m2m[i]);
(unsigned long long)ip6stat[IP6_STAT_M2M + i]);
}
}
p(ip6s_mext1, "\t\t%llu one ext mbuf%s\n");
p(ip6s_mext2m, "\t\t%llu two or more ext mbuf%s\n");
p(ip6s_exthdrtoolong,
p(IP6_STAT_MEXT1, "\t\t%llu one ext mbuf%s\n");
p(IP6_STAT_MEXT2M, "\t\t%llu two or more ext mbuf%s\n");
p(IP6_STAT_EXTHDRTOOLONG,
"\t%llu packet%s whose headers are not continuous\n");
p(ip6s_nogif, "\t%llu tunneling packet%s that can't find gif\n");
p(ip6s_toomanyhdr,
p(IP6_STAT_NOGIF, "\t%llu tunneling packet%s that can't find gif\n");
p(IP6_STAT_TOOMANYHDR,
"\t%llu packet%s discarded due to too many headers\n");
/* for debugging source address selection */
@ -686,60 +684,60 @@ ip6_stats(off, name)
break;\
default:\
printf("\t\t%llu addresses scope=%x\n",\
(unsigned long long)ip6stat.s, i);\
(unsigned long long)ip6stat[s], i);\
}\
} while(0);
} while(/*CONSTCOND*/0);
p(ip6s_sources_none,
p(IP6_STAT_SOURCES_NONE,
"\t%llu failure%s of source address selection\n");
for (first = 1, i = 0; i < 16; i++) {
if (ip6stat.ip6s_sources_sameif[i]) {
if (ip6stat[IP6_STAT_SOURCES_SAMEIF + i]) {
if (first) {
printf("\tsource addresses on an outgoing I/F\n");
first = 0;
}
PRINT_SCOPESTAT(ip6s_sources_sameif[i], i);
PRINT_SCOPESTAT(IP6_STAT_SOURCES_SAMEIF + i, i);
}
}
for (first = 1, i = 0; i < 16; i++) {
if (ip6stat.ip6s_sources_otherif[i]) {
if (ip6stat[IP6_STAT_SOURCES_OTHERIF + i]) {
if (first) {
printf("\tsource addresses on a non-outgoing I/F\n");
first = 0;
}
PRINT_SCOPESTAT(ip6s_sources_otherif[i], i);
PRINT_SCOPESTAT(IP6_STAT_SOURCES_OTHERIF + i, i);
}
}
for (first = 1, i = 0; i < 16; i++) {
if (ip6stat.ip6s_sources_samescope[i]) {
if (ip6stat[IP6_STAT_SOURCES_SAMESCOPE + i]) {
if (first) {
printf("\tsource addresses of same scope\n");
first = 0;
}
PRINT_SCOPESTAT(ip6s_sources_samescope[i], i);
PRINT_SCOPESTAT(IP6_STAT_SOURCES_SAMESCOPE + i, i);
}
}
for (first = 1, i = 0; i < 16; i++) {
if (ip6stat.ip6s_sources_otherscope[i]) {
if (ip6stat[IP6_STAT_SOURCES_OTHERSCOPE + i]) {
if (first) {
printf("\tsource addresses of a different scope\n");
first = 0;
}
PRINT_SCOPESTAT(ip6s_sources_otherscope[i], i);
PRINT_SCOPESTAT(IP6_STAT_SOURCES_OTHERSCOPE + i, i);
}
}
for (first = 1, i = 0; i < 16; i++) {
if (ip6stat.ip6s_sources_deprecated[i]) {
if (ip6stat[IP6_STAT_SOURCES_DEPRECATED + i]) {
if (first) {
printf("\tdeprecated source addresses\n");
first = 0;
}
PRINT_SCOPESTAT(ip6s_sources_deprecated[i], i);
PRINT_SCOPESTAT(IP6_STAT_SOURCES_DEPRECATED + i, i);
}
}
p1(ip6s_forward_cachehit, "\t%llu forward cache hit\n");
p1(ip6s_forward_cachemiss, "\t%llu forward cache miss\n");
p1(IP6_STAT_FORWARD_CACHEHIT, "\t%llu forward cache hit\n");
p1(IP6_STAT_FORWARD_CACHEMISS, "\t%llu forward cache miss\n");
#undef p
#undef p1
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip6.c,v 1.12 2006/10/22 16:43:24 christos Exp $ */
/* $NetBSD: ip6.c,v 1.13 2008/04/08 23:37:43 thorpej Exp $ */
/*
* Copyright (c) 1999, 2000 Andrew Doran <ad@NetBSD.org>
@ -29,7 +29,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: ip6.c,v 1.12 2006/10/22 16:43:24 christos Exp $");
__RCSID("$NetBSD: ip6.c,v 1.13 2008/04/08 23:37:43 thorpej Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -48,7 +48,7 @@ __RCSID("$NetBSD: ip6.c,v 1.12 2006/10/22 16:43:24 christos Exp $");
#define LHD(row, str) mvwprintw(wnd, row, 10, str)
#define RHD(row, str) mvwprintw(wnd, row, 45, str);
#define SHOW(stat, row, col) \
mvwprintw(wnd, row, col, "%9llu", (unsigned long long)curstat.stat)
mvwprintw(wnd, row, col, "%9llu", (unsigned long long)curstat[stat])
enum update {
UPDATE_TIME,
@ -57,9 +57,9 @@ enum update {
};
static enum update update = UPDATE_TIME;
static struct ip6stat curstat;
static struct ip6stat newstat;
static struct ip6stat oldstat;
static uint64_t curstat[IP6_NSTATS];
static uint64_t newstat[IP6_NSTATS];
static uint64_t oldstat[IP6_NSTATS];
static struct nlist namelist[] = {
{ .n_name = "_ip6stat" },
@ -137,50 +137,48 @@ showip6(void)
int i;
m2m = 0;
for (i = 0;
i < sizeof(curstat.ip6s_m2m)/sizeof(curstat.ip6s_m2m[0]);
i++) {
m2m += curstat.ip6s_m2m[i];
for (i = 0; i < 32; i++) {
m2m += curstat[IP6_STAT_M2M + i];
}
#endif
SHOW(ip6s_total, 0, 0);
SHOW(ip6s_toosmall, 1, 0);
SHOW(ip6s_tooshort, 2, 0);
SHOW(ip6s_badoptions, 3, 0);
SHOW(ip6s_badvers, 4, 0);
SHOW(ip6s_exthdrtoolong, 5, 0);
SHOW(ip6s_delivered, 6, 0);
SHOW(ip6s_notmember, 7, 0);
SHOW(ip6s_toomanyhdr, 8, 0);
SHOW(ip6s_nogif, 9, 0);
SHOW(IP6_STAT_TOTAL, 0, 0);
SHOW(IP6_STAT_TOOSMALL, 1, 0);
SHOW(IP6_STAT_TOOSHORT, 2, 0);
SHOW(IP6_STAT_BADOPTIONS, 3, 0);
SHOW(IP6_STAT_BADVERS, 4, 0);
SHOW(IP6_STAT_EXTHDRTOOLONG, 5, 0);
SHOW(IP6_STAT_DELIVERED, 6, 0);
SHOW(IP6_STAT_NOTMEMBER, 7, 0);
SHOW(IP6_STAT_TOOMANYHDR, 8, 0);
SHOW(IP6_STAT_NOGIF, 9, 0);
SHOW(ip6s_fragments, 11, 0);
SHOW(ip6s_fragdropped, 12, 0);
SHOW(ip6s_fragtimeout, 13, 0);
SHOW(ip6s_fragoverflow, 14, 0);
SHOW(ip6s_reassembled, 15, 0);
SHOW(IP6_STAT_FRAGMENTS, 11, 0);
SHOW(IP6_STAT_FRAGDROPPED, 12, 0);
SHOW(IP6_STAT_FRAGTIMEOUT, 13, 0);
SHOW(IP6_STAT_FRAGOVERFLOW, 14, 0);
SHOW(IP6_STAT_REASSEMBLED, 15, 0);
#if 0
SHOW(ip6s_m1, 17, 0);
SHOW(ip6s_mext1, 18, 0);
SHOW(ip6s_mext2m, 19, 0);
SHOW(IP6_STAT_M1, 17, 0);
SHOW(IP6_STAT_MEXT1, 18, 0);
SHOW(IP6_STAT_MEXT2M, 19, 0);
mvwprintw(wnd, 20, 0, "%9llu", (unsigned long long)m2m);
#endif
SHOW(ip6s_forward, 0, 35);
SHOW(ip6s_cantforward, 1, 35);
SHOW(ip6s_redirectsent, 2, 35);
SHOW(IP6_STAT_FORWARD, 0, 35);
SHOW(IP6_STAT_CANTFORWARD, 1, 35);
SHOW(IP6_STAT_REDIRECTSENT, 2, 35);
SHOW(ip6s_localout, 4, 35);
SHOW(ip6s_rawout, 5, 35);
SHOW(ip6s_odropped, 6, 35);
SHOW(ip6s_noroute, 7, 35);
SHOW(ip6s_fragmented, 8, 35);
SHOW(ip6s_ofragments, 9, 35);
SHOW(ip6s_cantfrag, 10, 35);
SHOW(IP6_STAT_LOCALOUT, 4, 35);
SHOW(IP6_STAT_RAWOUT, 5, 35);
SHOW(IP6_STAT_ODROPPED, 6, 35);
SHOW(IP6_STAT_NOROUTE, 7, 35);
SHOW(IP6_STAT_FRAGMENTED, 8, 35);
SHOW(IP6_STAT_OFRAGMENTS, 9, 35);
SHOW(IP6_STAT_CANTFRAG, 10, 35);
SHOW(ip6s_badscope, 12, 35);
SHOW(IP6_STAT_BADSCOPE, 12, 35);
}
int
@ -204,48 +202,22 @@ initip6(void)
void
fetchip6(void)
{
int i;
KREAD((void *)namelist[0].n_value, &newstat, sizeof(newstat));
KREAD((void *)namelist[0].n_value, newstat, sizeof(newstat));
ADJINETCTR(curstat, oldstat, newstat, ip6s_total);
ADJINETCTR(curstat, oldstat, newstat, ip6s_toosmall);
ADJINETCTR(curstat, oldstat, newstat, ip6s_tooshort);
ADJINETCTR(curstat, oldstat, newstat, ip6s_badoptions);
ADJINETCTR(curstat, oldstat, newstat, ip6s_badvers);
ADJINETCTR(curstat, oldstat, newstat, ip6s_exthdrtoolong);
ADJINETCTR(curstat, oldstat, newstat, ip6s_delivered);
ADJINETCTR(curstat, oldstat, newstat, ip6s_notmember);
ADJINETCTR(curstat, oldstat, newstat, ip6s_toomanyhdr);
ADJINETCTR(curstat, oldstat, newstat, ip6s_nogif);
ADJINETCTR(curstat, oldstat, newstat, ip6s_fragments);
ADJINETCTR(curstat, oldstat, newstat, ip6s_fragdropped);
ADJINETCTR(curstat, oldstat, newstat, ip6s_fragtimeout);
ADJINETCTR(curstat, oldstat, newstat, ip6s_fragoverflow);
ADJINETCTR(curstat, oldstat, newstat, ip6s_reassembled);
ADJINETCTR(curstat, oldstat, newstat, ip6s_m1);
ADJINETCTR(curstat, oldstat, newstat, ip6s_mext1);
ADJINETCTR(curstat, oldstat, newstat, ip6s_mext2m);
ADJINETCTR(curstat, oldstat, newstat, ip6s_forward);
ADJINETCTR(curstat, oldstat, newstat, ip6s_cantforward);
ADJINETCTR(curstat, oldstat, newstat, ip6s_redirectsent);
ADJINETCTR(curstat, oldstat, newstat, ip6s_localout);
ADJINETCTR(curstat, oldstat, newstat, ip6s_rawout);
ADJINETCTR(curstat, oldstat, newstat, ip6s_odropped);
ADJINETCTR(curstat, oldstat, newstat, ip6s_noroute);
ADJINETCTR(curstat, oldstat, newstat, ip6s_fragmented);
ADJINETCTR(curstat, oldstat, newstat, ip6s_ofragments);
ADJINETCTR(curstat, oldstat, newstat, ip6s_cantfrag);
ADJINETCTR(curstat, oldstat, newstat, ip6s_badscope);
for (i = 0; i < IP6_NSTATS; i++)
xADJINETCTR(curstat, oldstat, newstat, i);
if (update == UPDATE_TIME)
memcpy(&oldstat, &newstat, sizeof(oldstat));
memcpy(oldstat, newstat, sizeof(oldstat));
}
void
ip6_boot(char *args)
{
memset(&oldstat, 0, sizeof(oldstat));
memset(oldstat, 0, sizeof(oldstat));
update = UPDATE_BOOT;
}
@ -254,7 +226,7 @@ ip6_run(char *args)
{
if (update != UPDATE_RUN) {
memcpy(&oldstat, &newstat, sizeof(oldstat));
memcpy(oldstat, newstat, sizeof(oldstat));
update = UPDATE_RUN;
}
}
@ -264,7 +236,7 @@ ip6_time(char *args)
{
if (update != UPDATE_TIME) {
memcpy(&oldstat, &newstat, sizeof(oldstat));
memcpy(oldstat, newstat, sizeof(oldstat));
update = UPDATE_TIME;
}
}
@ -274,5 +246,5 @@ ip6_zero(char *args)
{
if (update == UPDATE_RUN)
memcpy(&oldstat, &newstat, sizeof(oldstat));
memcpy(oldstat, newstat, sizeof(oldstat));
}