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

Note: This is ABI-compatible with the old icmp6stat structure; old netstat
binaries will continue to work properly.
This commit is contained in:
thorpej 2008-04-08 15:04:35 +00:00
parent 25ac1dd285
commit aa8724ff7b
10 changed files with 169 additions and 185 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: pf.c,v 1.48 2008/04/08 01:03:58 thorpej Exp $ */
/* $NetBSD: pf.c,v 1.49 2008/04/08 15:04:35 thorpej Exp $ */
/* $OpenBSD: pf.c,v 1.487 2005/04/22 09:53:18 dhartmei Exp $ */
/*
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pf.c,v 1.48 2008/04/08 01:03:58 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: pf.c,v 1.49 2008/04/08 15:04:35 thorpej Exp $");
#include "bpfilter.h"
#include "pflog.h"
@ -5839,7 +5839,7 @@ pf_check_proto_cksum(struct mbuf *m, int off, int len, u_int8_t p,
break;
#ifdef INET6
case IPPROTO_ICMPV6:
icmp6stat.icp6s_checksum++;
icmp6stat[ICMP6_STAT_CHECKSUM]++;
break;
#endif /* INET6 */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: icmp6.h,v 1.36 2007/12/25 18:33:46 perry Exp $ */
/* $NetBSD: icmp6.h,v 1.37 2008/04/08 15:04:35 thorpej Exp $ */
/* $KAME: icmp6.h,v 1.84 2003/04/23 10:26:51 itojun Exp $ */
@ -512,67 +512,53 @@ struct icmp6_filter {
* Variables related to this implementation
* of the internet control message protocol version 6.
*/
struct icmp6errstat {
u_quad_t icp6errs_dst_unreach_noroute;
u_quad_t icp6errs_dst_unreach_admin;
u_quad_t icp6errs_dst_unreach_beyondscope;
u_quad_t icp6errs_dst_unreach_addr;
u_quad_t icp6errs_dst_unreach_noport;
u_quad_t icp6errs_packet_too_big;
u_quad_t icp6errs_time_exceed_transit;
u_quad_t icp6errs_time_exceed_reassembly;
u_quad_t icp6errs_paramprob_header;
u_quad_t icp6errs_paramprob_nextheader;
u_quad_t icp6errs_paramprob_option;
u_quad_t icp6errs_redirect; /* we regard redirect as an error here */
u_quad_t icp6errs_unknown;
};
struct icmp6stat {
/* statistics related to icmp6 packets generated */
u_quad_t icp6s_error; /* # of calls to icmp6_error */
u_quad_t icp6s_canterror; /* no error 'cuz old was icmp */
u_quad_t icp6s_toofreq; /* no error 'cuz rate limitation */
u_quad_t icp6s_outhist[256];
/* statistics related to input message processed */
u_quad_t icp6s_badcode; /* icmp6_code out of range */
u_quad_t icp6s_tooshort; /* packet < sizeof(struct icmp6_hdr) */
u_quad_t icp6s_checksum; /* bad checksum */
u_quad_t icp6s_badlen; /* calculated bound mismatch */
/*
* IPv6 ICMP statistics.
* Each counter is an unsigned 64-bit value.
*/
#define ICMP6_STAT_ERROR 0 /* # of calls to icmp6_error */
#define ICMP6_STAT_CANTERROR 1 /* no error (old was icmp) */
#define ICMP6_STAT_TOOFREQ 2 /* no error (rate limitation) */
#define ICMP6_STAT_OUTHIST 3 /* # of output messages */
/* space for 256 counters */
#define ICMP6_STAT_BADCODE 259 /* icmp6_code out of range */
#define ICMP6_STAT_TOOSHORT 260 /* packet < sizeof(struct icmp6_hdr) */
#define ICMP6_STAT_CHECKSUM 261 /* bad checksum */
#define ICMP6_STAT_BADLEN 262 /* calculated bound mismatch */
/*
* number of responses: this member is inherited from netinet code, but
* for netinet6 code, it is already available in icp6s_outhist[].
* number of responses; this member is inherited from the netinet code,
* but for netinet6 code, it is already available in outhist[].
*/
u_quad_t icp6s_reflect;
u_quad_t icp6s_inhist[256];
u_quad_t icp6s_nd_toomanyopt; /* too many ND options */
struct icmp6errstat icp6s_outerrhist;
#define icp6s_odst_unreach_noroute \
icp6s_outerrhist.icp6errs_dst_unreach_noroute
#define icp6s_odst_unreach_admin icp6s_outerrhist.icp6errs_dst_unreach_admin
#define icp6s_odst_unreach_beyondscope \
icp6s_outerrhist.icp6errs_dst_unreach_beyondscope
#define icp6s_odst_unreach_addr icp6s_outerrhist.icp6errs_dst_unreach_addr
#define icp6s_odst_unreach_noport icp6s_outerrhist.icp6errs_dst_unreach_noport
#define icp6s_opacket_too_big icp6s_outerrhist.icp6errs_packet_too_big
#define icp6s_otime_exceed_transit \
icp6s_outerrhist.icp6errs_time_exceed_transit
#define icp6s_otime_exceed_reassembly \
icp6s_outerrhist.icp6errs_time_exceed_reassembly
#define icp6s_oparamprob_header icp6s_outerrhist.icp6errs_paramprob_header
#define icp6s_oparamprob_nextheader \
icp6s_outerrhist.icp6errs_paramprob_nextheader
#define icp6s_oparamprob_option icp6s_outerrhist.icp6errs_paramprob_option
#define icp6s_oredirect icp6s_outerrhist.icp6errs_redirect
#define icp6s_ounknown icp6s_outerrhist.icp6errs_unknown
u_quad_t icp6s_pmtuchg; /* path MTU changes */
u_quad_t icp6s_nd_badopt; /* bad ND options */
u_quad_t icp6s_badns; /* bad neighbor solicitation */
u_quad_t icp6s_badna; /* bad neighbor advertisement */
u_quad_t icp6s_badrs; /* bad router advertisement */
u_quad_t icp6s_badra; /* bad router advertisement */
u_quad_t icp6s_badredirect; /* bad redirect message */
};
#define ICMP6_STAT_REFLECT 263
#define ICMP6_STAT_INHIST 264 /* # of input messages */
/* space for 256 counters */
#define ICMP6_STAT_ND_TOOMANYOPT 520 /* too many ND options */
#define ICMP6_STAT_OUTERRHIST 521
/* space for 13 counters */
#define ICMP6_STAT_PMTUCHG 534 /* path MTU changes */
#define ICMP6_STAT_ND_BADOPT 535 /* bad ND options */
#define ICMP6_STAT_BADNS 536 /* bad neighbor solicititation */
#define ICMP6_STAT_BADNA 537 /* bad neighbor advertisement */
#define ICMP6_STAT_BADRS 538 /* bad router solicitiation */
#define ICMP6_STAT_BADRA 539 /* bad router advertisement */
#define ICMP6_STAT_BADREDIRECT 540 /* bad redirect message */
#define ICMP6_NSTATS 541
#define ICMP6_ERRSTAT_DST_UNREACH_NOROUTE 0
#define ICMP6_ERRSTAT_DST_UNREACH_ADMIN 1
#define ICMP6_ERRSTAT_DST_UNREACH_BEYONDSCOPE 2
#define ICMP6_ERRSTAT_DST_UNREACH_ADDR 3
#define ICMP6_ERRSTAT_DST_UNREACH_NOPORT 4
#define ICMP6_ERRSTAT_PACKET_TOO_BIG 5
#define ICMP6_ERRSTAT_TIME_EXCEED_TRANSIT 6
#define ICMP6_ERRSTAT_TIME_EXCEED_REASSEMBLY 7
#define ICMP6_ERRSTAT_PARAMPROB_HEADER 8
#define ICMP6_ERRSTAT_PARAMPROB_NEXTHEADER 9
#define ICMP6_ERRSTAT_PARAMPROB_OPTION 10
#define ICMP6_ERRSTAT_REDIRECT 11
#define ICMP6_ERRSTAT_UNKNOWN 12
/*
* Names for ICMP sysctl objects

View File

@ -1,4 +1,4 @@
/* $NetBSD: icmp6.c,v 1.142 2008/02/27 19:40:56 matt Exp $ */
/* $NetBSD: icmp6.c,v 1.143 2008/04/08 15:04:35 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.142 2008/02/27 19:40:56 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.143 2008/04/08 15:04:35 thorpej Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@ -117,7 +117,7 @@ __KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.142 2008/02/27 19:40:56 matt Exp $");
extern struct domain inet6domain;
struct icmp6stat icmp6stat;
uint64_t icmp6stat[ICMP6_NSTATS];
extern struct inpcbtable raw6cbtable;
extern int icmp6errppslim;
@ -152,7 +152,7 @@ static struct rttimer_queue *icmp6_redirect_timeout_q = NULL;
static int icmp6_redirect_hiwat = -1;
static int icmp6_redirect_lowat = -1;
static void icmp6_errcount(struct icmp6errstat *, int, int);
static void icmp6_errcount(uint64_t *, int, int);
static int icmp6_rip6_input(struct mbuf **, int);
static int icmp6_ratelimit(const struct in6_addr *, const int, const int);
static const char *icmp6_redirect_diag(struct in6_addr *,
@ -179,59 +179,59 @@ icmp6_init(void)
}
static void
icmp6_errcount(struct icmp6errstat *stat, int type, int code)
icmp6_errcount(uint64_t *stat, int type, int code)
{
switch (type) {
case ICMP6_DST_UNREACH:
switch (code) {
case ICMP6_DST_UNREACH_NOROUTE:
stat->icp6errs_dst_unreach_noroute++;
stat[ICMP6_ERRSTAT_DST_UNREACH_NOROUTE]++;
return;
case ICMP6_DST_UNREACH_ADMIN:
stat->icp6errs_dst_unreach_admin++;
stat[ICMP6_ERRSTAT_DST_UNREACH_ADMIN]++;
return;
case ICMP6_DST_UNREACH_BEYONDSCOPE:
stat->icp6errs_dst_unreach_beyondscope++;
stat[ICMP6_ERRSTAT_DST_UNREACH_BEYONDSCOPE]++;
return;
case ICMP6_DST_UNREACH_ADDR:
stat->icp6errs_dst_unreach_addr++;
stat[ICMP6_ERRSTAT_DST_UNREACH_ADDR]++;
return;
case ICMP6_DST_UNREACH_NOPORT:
stat->icp6errs_dst_unreach_noport++;
stat[ICMP6_ERRSTAT_DST_UNREACH_NOPORT]++;
return;
}
break;
case ICMP6_PACKET_TOO_BIG:
stat->icp6errs_packet_too_big++;
stat[ICMP6_ERRSTAT_PACKET_TOO_BIG]++;
return;
case ICMP6_TIME_EXCEEDED:
switch (code) {
case ICMP6_TIME_EXCEED_TRANSIT:
stat->icp6errs_time_exceed_transit++;
stat[ICMP6_ERRSTAT_TIME_EXCEED_TRANSIT]++;
return;
case ICMP6_TIME_EXCEED_REASSEMBLY:
stat->icp6errs_time_exceed_reassembly++;
stat[ICMP6_ERRSTAT_TIME_EXCEED_REASSEMBLY]++;
return;
}
break;
case ICMP6_PARAM_PROB:
switch (code) {
case ICMP6_PARAMPROB_HEADER:
stat->icp6errs_paramprob_header++;
stat[ICMP6_ERRSTAT_PARAMPROB_HEADER]++;
return;
case ICMP6_PARAMPROB_NEXTHEADER:
stat->icp6errs_paramprob_nextheader++;
stat[ICMP6_ERRSTAT_PARAMPROB_NEXTHEADER]++;
return;
case ICMP6_PARAMPROB_OPTION:
stat->icp6errs_paramprob_option++;
stat[ICMP6_ERRSTAT_PARAMPROB_OPTION]++;
return;
}
break;
case ND_REDIRECT:
stat->icp6errs_redirect++;
stat[ICMP6_ERRSTAT_REDIRECT]++;
return;
}
stat->icp6errs_unknown++;
stat[ICMP6_ERRSTAT_UNKNOWN]++;
}
/*
@ -297,13 +297,13 @@ icmp6_error(struct mbuf *m, int type, int code, int param)
int off;
int nxt;
icmp6stat.icp6s_error++;
icmp6stat[ICMP6_STAT_ERROR]++;
/* count per-type-code statistics */
icmp6_errcount(&icmp6stat.icp6s_outerrhist, type, code);
icmp6_errcount(&icmp6stat[ICMP6_STAT_OUTERRHIST], type, code);
if (m->m_flags & M_DECRYPTED) {
icmp6stat.icp6s_canterror++;
icmp6stat[ICMP6_STAT_CANTERROR]++;
goto freeit;
}
@ -350,7 +350,7 @@ icmp6_error(struct mbuf *m, int type, int code, int param)
IP6_EXTHDR_GET(icp, struct icmp6_hdr *, m, off,
sizeof(*icp));
if (icp == NULL) {
icmp6stat.icp6s_tooshort++;
icmp6stat[ICMP6_STAT_TOOSHORT]++;
return;
}
if (icp->icmp6_type < ICMP6_ECHO_REQUEST ||
@ -360,7 +360,7 @@ icmp6_error(struct mbuf *m, int type, int code, int param)
* Special case: for redirect (which is
* informational) we must not send icmp6 error.
*/
icmp6stat.icp6s_canterror++;
icmp6stat[ICMP6_STAT_CANTERROR]++;
goto freeit;
} else {
/* ICMPv6 informational - send the error */
@ -372,7 +372,7 @@ icmp6_error(struct mbuf *m, int type, int code, int param)
* It could be ICMPv6 error inside ESP. Take a safer side,
* don't respond.
*/
icmp6stat.icp6s_canterror++;
icmp6stat[ICMP6_STAT_CANTERROR]++;
goto freeit;
}
#endif
@ -384,7 +384,7 @@ icmp6_error(struct mbuf *m, int type, int code, int param)
/* Finally, do rate limitation check. */
if (icmp6_ratelimit(&oip6->ip6_src, type, code)) {
icmp6stat.icp6s_toofreq++;
icmp6stat[ICMP6_STAT_TOOFREQ]++;
goto freeit;
}
@ -425,7 +425,7 @@ icmp6_error(struct mbuf *m, int type, int code, int param)
*/
m->m_pkthdr.rcvif = NULL;
icmp6stat.icp6s_outhist[type]++;
icmp6stat[ICMP6_STAT_OUTHIST + type]++;
icmp6_reflect(m, sizeof(struct ip6_hdr)); /* header order: IPv6 - ICMPv6 */
return;
@ -461,7 +461,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
ip6 = mtod(m, struct ip6_hdr *);
if (icmp6len < sizeof(struct icmp6_hdr)) {
icmp6stat.icp6s_tooshort++;
icmp6stat[ICMP6_STAT_TOOSHORT]++;
icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_error);
goto freeit;
}
@ -471,7 +471,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
*/
IP6_EXTHDR_GET(icmp6, struct icmp6_hdr *, m, off, sizeof(*icmp6));
if (icmp6 == NULL) {
icmp6stat.icp6s_tooshort++;
icmp6stat[ICMP6_STAT_TOOSHORT]++;
/* m is invalid */
/*icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_error);*/
return IPPROTO_DONE;
@ -483,7 +483,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
nd6log((LOG_ERR,
"ICMP6 checksum error(%d|%x) %s\n",
icmp6->icmp6_type, sum, ip6_sprintf(&ip6->ip6_src)));
icmp6stat.icp6s_checksum++;
icmp6stat[ICMP6_STAT_CHECKSUM]++;
icmp6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_error);
goto freeit;
}
@ -506,7 +506,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
}
#endif
icmp6stat.icp6s_inhist[icmp6->icmp6_type]++;
icmp6stat[ICMP6_STAT_INHIST + icmp6->icmp6_type]++;
switch (icmp6->icmp6_type) {
case ICMP6_DST_UNREACH:
@ -617,8 +617,8 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
nicmp6->icmp6_type = ICMP6_ECHO_REPLY;
nicmp6->icmp6_code = 0;
if (n) {
icmp6stat.icp6s_reflect++;
icmp6stat.icp6s_outhist[ICMP6_ECHO_REPLY]++;
icmp6stat[ICMP6_STAT_REFLECT]++;
icmp6stat[ICMP6_STAT_OUTHIST + ICMP6_ECHO_REPLY]++;
icmp6_reflect(n, off);
}
if (!m)
@ -726,8 +726,8 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
}
#undef hostnamelen
if (n) {
icmp6stat.icp6s_reflect++;
icmp6stat.icp6s_outhist[ICMP6_WRUREPLY]++;
icmp6stat[ICMP6_STAT_REFLECT]++;
icmp6stat[ICMP6_STAT_OUTHIST + ICMP6_WRUREPLY]++;
icmp6_reflect(n, noff);
}
break;
@ -848,11 +848,11 @@ icmp6_input(struct mbuf **mp, int *offp, int proto)
break;
badcode:
icmp6stat.icp6s_badcode++;
icmp6stat[ICMP6_STAT_BADCODE]++;
break;
badlen:
icmp6stat.icp6s_badlen++;
icmp6stat[ICMP6_STAT_BADLEN]++;
break;
}
@ -875,13 +875,13 @@ icmp6_notify_error(struct mbuf *m, int off, int icmp6len, int code)
struct sockaddr_in6 icmp6src, icmp6dst;
if (icmp6len < sizeof(struct icmp6_hdr) + sizeof(struct ip6_hdr)) {
icmp6stat.icp6s_tooshort++;
icmp6stat[ICMP6_STAT_TOOSHORT]++;
goto freeit;
}
IP6_EXTHDR_GET(icmp6, struct icmp6_hdr *, m, off,
sizeof(*icmp6) + sizeof(struct ip6_hdr));
if (icmp6 == NULL) {
icmp6stat.icp6s_tooshort++;
icmp6stat[ICMP6_STAT_TOOSHORT]++;
return (-1);
}
eip6 = (struct ip6_hdr *)(icmp6 + 1);
@ -910,7 +910,7 @@ icmp6_notify_error(struct mbuf *m, int off, int icmp6len, int code)
IP6_EXTHDR_GET(eh, struct ip6_ext *, m,
eoff, sizeof(*eh));
if (eh == NULL) {
icmp6stat.icp6s_tooshort++;
icmp6stat[ICMP6_STAT_TOOSHORT]++;
return (-1);
}
@ -932,7 +932,7 @@ icmp6_notify_error(struct mbuf *m, int off, int icmp6len, int code)
IP6_EXTHDR_GET(rth, struct ip6_rthdr *, m,
eoff, sizeof(*rth));
if (rth == NULL) {
icmp6stat.icp6s_tooshort++;
icmp6stat[ICMP6_STAT_TOOSHORT]++;
return (-1);
}
rthlen = (rth->ip6r_len + 1) << 3;
@ -952,7 +952,7 @@ icmp6_notify_error(struct mbuf *m, int off, int icmp6len, int code)
struct ip6_rthdr0 *, m,
eoff, rthlen);
if (rth0 == NULL) {
icmp6stat.icp6s_tooshort++;
icmp6stat[ICMP6_STAT_TOOSHORT]++;
return (-1);
}
/* just ignore a bogus header */
@ -967,7 +967,7 @@ icmp6_notify_error(struct mbuf *m, int off, int icmp6len, int code)
IP6_EXTHDR_GET(fh, struct ip6_frag *, m,
eoff, sizeof(*fh));
if (fh == NULL) {
icmp6stat.icp6s_tooshort++;
icmp6stat[ICMP6_STAT_TOOSHORT]++;
return (-1);
}
/*
@ -998,7 +998,7 @@ icmp6_notify_error(struct mbuf *m, int off, int icmp6len, int code)
IP6_EXTHDR_GET(icmp6, struct icmp6_hdr *, m, off,
sizeof(*icmp6) + sizeof(struct ip6_hdr));
if (icmp6 == NULL) {
icmp6stat.icp6s_tooshort++;
icmp6stat[ICMP6_STAT_TOOSHORT]++;
return (-1);
}
@ -1095,7 +1095,7 @@ icmp6_mtudisc_update(struct ip6ctlparam *ip6cp, int validated)
!(rt->rt_rmx.rmx_locks & RTV_MTU) &&
(rt->rt_rmx.rmx_mtu > mtu || rt->rt_rmx.rmx_mtu == 0)) {
if (mtu < IN6_LINKMTU(rt->rt_ifp)) {
icmp6stat.icp6s_pmtuchg++;
icmp6stat[ICMP6_STAT_PMTUCHG]++;
rt->rt_rmx.rmx_mtu = mtu;
}
}
@ -2119,7 +2119,7 @@ icmp6_redirect_input(struct mbuf *m, int off)
IP6_EXTHDR_GET(nd_rd, struct nd_redirect *, m, off, icmp6len);
if (nd_rd == NULL) {
icmp6stat.icp6s_tooshort++;
icmp6stat[ICMP6_STAT_TOOSHORT]++;
return;
}
redtgt6 = nd_rd->nd_rd_target;
@ -2293,7 +2293,7 @@ icmp6_redirect_input(struct mbuf *m, int off)
return;
bad:
icmp6stat.icp6s_badredirect++;
icmp6stat[ICMP6_STAT_BADREDIRECT]++;
m_freem(m);
}
@ -2311,7 +2311,7 @@ icmp6_redirect_output(struct mbuf *m0, struct rtentry *rt)
u_char *p;
struct sockaddr_in6 src_sa;
icmp6_errcount(&icmp6stat.icp6s_outerrhist, ND_REDIRECT, 0);
icmp6_errcount(&icmp6stat[ICMP6_STAT_OUTERRHIST], ND_REDIRECT, 0);
/* if we are not router, we don't send icmp6 redirect */
if (!ip6_forwarding)
@ -2538,7 +2538,7 @@ noredhdropt:
icmp6_ifstat_inc(ifp, ifs6_out_msg);
icmp6_ifstat_inc(ifp, ifs6_out_redirect);
icmp6stat.icp6s_outhist[ND_REDIRECT]++;
icmp6stat[ICMP6_STAT_OUTHIST + ND_REDIRECT]++;
return;
@ -2760,7 +2760,7 @@ SYSCTL_SETUP(sysctl_net_inet6_icmp6_setup,
CTLFLAG_PERMANENT,
CTLTYPE_STRUCT, "stats",
SYSCTL_DESCR("ICMPv6 transmission statistics"),
NULL, 0, &icmp6stat, sizeof(icmp6stat),
NULL, 0, icmp6stat, sizeof(icmp6stat),
CTL_NET, PF_INET6, IPPROTO_ICMPV6,
ICMPV6CTL_STATS, CTL_EOL);
sysctl_createv(clog, 0, NULL, NULL,

View File

@ -1,4 +1,4 @@
/* $NetBSD: in6_var.h,v 1.56 2007/12/05 01:17:16 dyoung Exp $ */
/* $NetBSD: in6_var.h,v 1.57 2008/04/08 15:04:35 thorpej Exp $ */
/* $KAME: in6_var.h,v 1.81 2002/06/08 11:16:51 itojun Exp $ */
/*
@ -473,7 +473,7 @@ MALLOC_DECLARE(M_IP6OPT);
extern struct in6_ifaddr *in6_ifaddr;
extern struct icmp6stat icmp6stat;
extern uint64_t icmp6stat[/* XXX ICMP6_NSTATS */];
#define in6_ifstat_inc(ifp, tag) \
do { \
if (ifp) \

View File

@ -1,4 +1,4 @@
/* $NetBSD: mld6.c,v 1.42 2008/02/27 19:40:56 matt Exp $ */
/* $NetBSD: mld6.c,v 1.43 2008/04/08 15:04:35 thorpej Exp $ */
/* $KAME: mld6.c,v 1.25 2001/01/16 14:14:18 itojun Exp $ */
/*
@ -102,7 +102,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mld6.c,v 1.42 2008/02/27 19:40:56 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: mld6.c,v 1.43 2008/04/08 15:04:35 thorpej Exp $");
#include "opt_inet.h"
@ -329,7 +329,7 @@ mld_input(struct mbuf *m, int off)
IP6_EXTHDR_GET(mldh, struct mld_hdr *, m, off, sizeof(*mldh));
if (mldh == NULL) {
icmp6stat.icp6s_tooshort++;
icmp6stat[ICMP6_STAT_TOOSHORT]++;
return;
}
@ -536,7 +536,7 @@ mld_sendpkt(struct in6_multi *in6m, int type,
im6o.im6o_multicast_loop = (ip6_mrouter != NULL);
/* increment output statictics */
icmp6stat.icp6s_outhist[type]++;
icmp6stat[ICMP6_STAT_OUTHIST + type]++;
icmp6_ifstat_inc(ifp, ifs6_out_msg);
switch (type) {
case MLD_LISTENER_QUERY:

View File

@ -1,4 +1,4 @@
/* $NetBSD: nd6.c,v 1.123 2007/12/04 10:27:34 dyoung Exp $ */
/* $NetBSD: nd6.c,v 1.124 2008/04/08 15:04:35 thorpej Exp $ */
/* $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $ */
/*
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.123 2007/12/04 10:27:34 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.124 2008/04/08 15:04:35 thorpej Exp $");
#include "opt_ipsec.h"
@ -320,7 +320,7 @@ nd6_options(union nd_opts *ndopts)
* Message validation requires that all included
* options have a length that is greater than zero.
*/
icmp6stat.icp6s_nd_badopt++;
icmp6stat[ICMP6_STAT_ND_BADOPT]++;
bzero(ndopts, sizeof(*ndopts));
return -1;
}
@ -364,7 +364,7 @@ nd6_options(union nd_opts *ndopts)
skip1:
i++;
if (i > nd6_maxndopt) {
icmp6stat.icp6s_nd_toomanyopt++;
icmp6stat[ICMP6_STAT_ND_TOOMANYOPT]++;
nd6log((LOG_INFO, "too many loop in nd opt\n"));
break;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: nd6_nbr.c,v 1.83 2008/02/27 19:40:56 matt Exp $ */
/* $NetBSD: nd6_nbr.c,v 1.84 2008/04/08 15:04:35 thorpej Exp $ */
/* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */
/*
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.83 2008/02/27 19:40:56 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.84 2008/04/08 15:04:35 thorpej Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@ -115,7 +115,7 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len)
IP6_EXTHDR_GET(nd_ns, struct nd_neighbor_solicit *, m, off, icmp6len);
if (nd_ns == NULL) {
icmp6stat.icp6s_tooshort++;
icmp6stat[ICMP6_STAT_TOOSHORT]++;
return;
}
ip6 = mtod(m, struct ip6_hdr *); /* adjust pointer for safety */
@ -322,7 +322,7 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len)
nd6log((LOG_ERR, "nd6_ns_input: src=%s\n", ip6_sprintf(&saddr6)));
nd6log((LOG_ERR, "nd6_ns_input: dst=%s\n", ip6_sprintf(&daddr6)));
nd6log((LOG_ERR, "nd6_ns_input: tgt=%s\n", ip6_sprintf(&taddr6)));
icmp6stat.icp6s_badns++;
icmp6stat[ICMP6_STAT_BADNS]++;
m_freem(m);
}
@ -514,7 +514,7 @@ nd6_ns_output(struct ifnet *ifp, const struct in6_addr *daddr6,
ip6_output(m, NULL, &ro, dad ? IPV6_UNSPECSRC : 0, &im6o, NULL, NULL);
icmp6_ifstat_inc(ifp, ifs6_out_msg);
icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit);
icmp6stat.icp6s_outhist[ND_NEIGHBOR_SOLICIT]++;
icmp6stat[ICMP6_STAT_OUTHIST + ND_NEIGHBOR_SOLICIT]++;
rtcache_free(&ro);
return;
@ -568,7 +568,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
IP6_EXTHDR_GET(nd_na, struct nd_neighbor_advert *, m, off, icmp6len);
if (nd_na == NULL) {
icmp6stat.icp6s_tooshort++;
icmp6stat[ICMP6_STAT_TOOSHORT]++;
return;
}
@ -805,7 +805,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
return;
bad:
icmp6stat.icp6s_badna++;
icmp6stat[ICMP6_STAT_BADNA]++;
m_freem(m);
}
@ -971,7 +971,7 @@ nd6_na_output(
icmp6_ifstat_inc(ifp, ifs6_out_msg);
icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert);
icmp6stat.icp6s_outhist[ND_NEIGHBOR_ADVERT]++;
icmp6stat[ICMP6_STAT_OUTHIST + ND_NEIGHBOR_ADVERT]++;
rtcache_free(&ro);
return;

View File

@ -1,4 +1,4 @@
/* $NetBSD: nd6_rtr.c,v 1.73 2008/02/27 19:40:56 matt Exp $ */
/* $NetBSD: nd6_rtr.c,v 1.74 2008/04/08 15:04:35 thorpej Exp $ */
/* $KAME: nd6_rtr.c,v 1.95 2001/02/07 08:09:47 itojun Exp $ */
/*
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.73 2008/02/27 19:40:56 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.74 2008/04/08 15:04:35 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -141,7 +141,7 @@ nd6_rs_input(struct mbuf *m, int off, int icmp6len)
IP6_EXTHDR_GET(nd_rs, struct nd_router_solicit *, m, off, icmp6len);
if (nd_rs == NULL) {
icmp6stat.icp6s_tooshort++;
icmp6stat[ICMP6_STAT_TOOSHORT]++;
return;
}
@ -174,7 +174,7 @@ nd6_rs_input(struct mbuf *m, int off, int icmp6len)
return;
bad:
icmp6stat.icp6s_badrs++;
icmp6stat[ICMP6_STAT_BADRS]++;
m_freem(m);
}
@ -230,7 +230,7 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
IP6_EXTHDR_GET(nd_ra, struct nd_router_advert *, m, off, icmp6len);
if (nd_ra == NULL) {
icmp6stat.icp6s_tooshort++;
icmp6stat[ICMP6_STAT_TOOSHORT]++;
return;
}
@ -403,7 +403,7 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
return;
bad:
icmp6stat.icp6s_badra++;
icmp6stat[ICMP6_STAT_BADRA]++;
m_freem(m);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: raw_ip6.c,v 1.91 2007/11/27 22:45:30 christos Exp $ */
/* $NetBSD: raw_ip6.c,v 1.92 2008/04/08 15:04:35 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.91 2007/11/27 22:45:30 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.92 2008/04/08 15:04:35 thorpej Exp $");
#include "opt_ipsec.h"
@ -530,7 +530,7 @@ rip6_output(struct mbuf *m, struct socket *so, struct sockaddr_in6 *dstsock,
if (so->so_proto->pr_protocol == IPPROTO_ICMPV6) {
if (oifp)
icmp6_ifoutstat_inc(oifp, type, code);
icmp6stat.icp6s_outhist[type]++;
icmp6stat[ICMP6_STAT_OUTHIST + type]++;
} else
rip6stat.rip6s_opackets++;

View File

@ -1,4 +1,4 @@
/* $NetBSD: inet6.c,v 1.43 2008/02/16 07:16:01 matt Exp $ */
/* $NetBSD: inet6.c,v 1.44 2008/04/08 15:04:35 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.43 2008/02/16 07:16:01 matt Exp $");
__RCSID("$NetBSD: inet6.c,v 1.44 2008/04/08 15:04:35 thorpej Exp $");
#endif
#endif /* not lint */
@ -802,7 +802,7 @@ ip6_ifstats(ifname)
#undef p_5
}
static char *icmp6names[] = {
static const char *icmp6names[] = {
"#0",
"unreach",
"packet too big",
@ -1065,85 +1065,83 @@ static char *icmp6names[] = {
* Dump ICMPv6 statistics.
*/
void
icmp6_stats(off, name)
u_long off;
char *name;
icmp6_stats(u_long off, char *name)
{
struct icmp6stat icmp6stat;
uint64_t icmp6stat[ICMP6_NSTATS];
register int i, first;
if (use_sysctl) {
size_t size = sizeof(icmp6stat);
if (sysctlbyname("net.inet6.icmp6.stats", &icmp6stat, &size,
if (sysctlbyname("net.inet6.icmp6.stats", icmp6stat, &size,
NULL, 0) == -1)
err(1, "net.inet6.icmp6.stats");
} else {
if (off == 0)
return;
kread(off, (char *)&icmp6stat, sizeof (icmp6stat));
kread(off, (char *)icmp6stat, sizeof (icmp6stat));
}
printf("%s:\n", name);
#define p(f, m) if (icmp6stat.f || sflag <= 1) \
printf(m, (unsigned long long)icmp6stat.f, plural(icmp6stat.f))
#define p_5(f, m) if (icmp6stat.f || sflag <= 1) \
printf(m, (unsigned long long)icmp6stat.f)
#define p(f, m) if (icmp6stat[f] || sflag <= 1) \
printf(m, (unsigned long long)icmp6stat[f], plural(icmp6stat[f]))
#define p_oerr(f, m) if (icmp6stat[ICMP6_STAT_OUTERRHIST + f] || sflag <= 1) \
printf(m, (unsigned long long)icmp6stat[ICMP6_STAT_OUTERRHIST + f])
p(icp6s_error, "\t%llu call%s to icmp6_error\n");
p(icp6s_canterror,
p(ICMP6_STAT_ERROR, "\t%llu call%s to icmp6_error\n");
p(ICMP6_STAT_CANTERROR,
"\t%llu error%s not generated because old message was icmp6 or so\n");
p(icp6s_toofreq,
p(ICMP6_STAT_TOOFREQ,
"\t%llu error%s not generated because of rate limitation\n");
for (first = 1, i = 0; i < 256; i++)
if (icmp6stat.icp6s_outhist[i] != 0) {
if (icmp6stat[ICMP6_STAT_OUTHIST + i] != 0) {
if (first) {
printf("\tOutput packet histogram:\n");
first = 0;
}
printf("\t\t%s: %llu\n", icmp6names[i],
(unsigned long long)icmp6stat.icp6s_outhist[i]);
(unsigned long long)icmp6stat[ICMP6_STAT_OUTHIST + i]);
}
p(icp6s_badcode, "\t%llu message%s with bad code fields\n");
p(icp6s_tooshort, "\t%llu message%s < minimum length\n");
p(icp6s_checksum, "\t%llu bad checksum%s\n");
p(icp6s_badlen, "\t%llu message%s with bad length\n");
p(ICMP6_STAT_BADCODE, "\t%llu message%s with bad code fields\n");
p(ICMP6_STAT_TOOSHORT, "\t%llu message%s < minimum length\n");
p(ICMP6_STAT_CHECKSUM, "\t%llu bad checksum%s\n");
p(ICMP6_STAT_BADLEN, "\t%llu message%s with bad length\n");
for (first = 1, i = 0; i < ICMP6_MAXTYPE; i++)
if (icmp6stat.icp6s_inhist[i] != 0) {
if (icmp6stat[ICMP6_STAT_INHIST + i] != 0) {
if (first) {
printf("\tInput packet histogram:\n");
first = 0;
}
printf("\t\t%s: %llu\n", icmp6names[i],
(unsigned long long)icmp6stat.icp6s_inhist[i]);
(unsigned long long)icmp6stat[ICMP6_STAT_INHIST + i]);
}
printf("\tHistogram of error messages to be generated:\n");
p_5(icp6s_odst_unreach_noroute, "\t\t%llu no route\n");
p_5(icp6s_odst_unreach_admin, "\t\t%llu administratively prohibited\n");
p_5(icp6s_odst_unreach_beyondscope, "\t\t%llu beyond scope\n");
p_5(icp6s_odst_unreach_addr, "\t\t%llu address unreachable\n");
p_5(icp6s_odst_unreach_noport, "\t\t%llu port unreachable\n");
p_5(icp6s_opacket_too_big, "\t\t%llu packet too big\n");
p_5(icp6s_otime_exceed_transit, "\t\t%llu time exceed transit\n");
p_5(icp6s_otime_exceed_reassembly, "\t\t%llu time exceed reassembly\n");
p_5(icp6s_oparamprob_header, "\t\t%llu erroneous header field\n");
p_5(icp6s_oparamprob_nextheader, "\t\t%llu unrecognized next header\n");
p_5(icp6s_oparamprob_option, "\t\t%llu unrecognized option\n");
p_5(icp6s_oredirect, "\t\t%llu redirect\n");
p_5(icp6s_ounknown, "\t\t%llu unknown\n");
p_oerr(ICMP6_ERRSTAT_DST_UNREACH_NOROUTE, "\t\t%llu no route\n");
p_oerr(ICMP6_ERRSTAT_DST_UNREACH_ADMIN, "\t\t%llu administratively prohibited\n");
p_oerr(ICMP6_ERRSTAT_DST_UNREACH_BEYONDSCOPE, "\t\t%llu beyond scope\n");
p_oerr(ICMP6_ERRSTAT_DST_UNREACH_ADDR, "\t\t%llu address unreachable\n");
p_oerr(ICMP6_ERRSTAT_DST_UNREACH_NOPORT, "\t\t%llu port unreachable\n");
p_oerr(ICMP6_ERRSTAT_PACKET_TOO_BIG, "\t\t%llu packet too big\n");
p_oerr(ICMP6_ERRSTAT_TIME_EXCEED_TRANSIT, "\t\t%llu time exceed transit\n");
p_oerr(ICMP6_ERRSTAT_TIME_EXCEED_REASSEMBLY, "\t\t%llu time exceed reassembly\n");
p_oerr(ICMP6_ERRSTAT_PARAMPROB_HEADER, "\t\t%llu erroneous header field\n");
p_oerr(ICMP6_ERRSTAT_PARAMPROB_NEXTHEADER, "\t\t%llu unrecognized next header\n");
p_oerr(ICMP6_ERRSTAT_PARAMPROB_OPTION, "\t\t%llu unrecognized option\n");
p_oerr(ICMP6_ERRSTAT_REDIRECT, "\t\t%llu redirect\n");
p_oerr(ICMP6_ERRSTAT_UNKNOWN, "\t\t%llu unknown\n");
p(icp6s_reflect, "\t%llu message response%s generated\n");
p(icp6s_nd_toomanyopt, "\t%llu message%s with too many ND options\n");
p(icp6s_nd_badopt, "\t%llu message%s with bad ND options\n");
p(icp6s_badns, "\t%llu bad neighbor solicitation message%s\n");
p(icp6s_badna, "\t%llu bad neighbor advertisement message%s\n");
p(icp6s_badrs, "\t%llu bad router solicitation message%s\n");
p(icp6s_badra, "\t%llu bad router advertisement message%s\n");
p(icp6s_badredirect, "\t%llu bad redirect message%s\n");
p(icp6s_pmtuchg, "\t%llu path MTU change%s\n");
p(ICMP6_STAT_REFLECT, "\t%llu message response%s generated\n");
p(ICMP6_STAT_ND_TOOMANYOPT, "\t%llu message%s with too many ND options\n");
p(ICMP6_STAT_ND_BADOPT, "\t%llu message%s with bad ND options\n");
p(ICMP6_STAT_BADNS, "\t%llu bad neighbor solicitation message%s\n");
p(ICMP6_STAT_BADNA, "\t%llu bad neighbor advertisement message%s\n");
p(ICMP6_STAT_BADRS, "\t%llu bad router solicitation message%s\n");
p(ICMP6_STAT_BADRA, "\t%llu bad router advertisement message%s\n");
p(ICMP6_STAT_BADREDIRECT, "\t%llu bad redirect message%s\n");
p(ICMP6_STAT_PMTUCHG, "\t%llu path MTU change%s\n");
#undef p
#undef p_5
#undef p_oerr
}
/*