Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

counted precise statistics of error messages (including redirects)

to be generated.
  • Loading branch information...
commit 9fb415a995b2c78316fe73c2aa0d926ae6ff1167 1 parent ff52485
jinmei authored

Showing 1 changed file with 65 additions and 1 deletion. Show diff stats Hide diff stats

  1. +65 1 kame/sys/netinet6/icmp6.c
66 kame/sys/netinet6/icmp6.c
... ... @@ -1,4 +1,4 @@
1   -/* $KAME: icmp6.c,v 1.110 2000/06/04 12:54:56 itojun Exp $ */
  1 +/* $KAME: icmp6.c,v 1.111 2000/06/11 17:24:31 jinmei Exp $ */
2 2
3 3 /*
4 4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -145,6 +145,7 @@ static struct rttimer_queue *icmp6_mtudisc_timeout_q = NULL;
145 145 extern int pmtu_expire;
146 146 #endif
147 147
  148 +static void icmp6_errcount __P((struct icmp6errstat *, int, int));
148 149 #ifndef HAVE_NRL_INPCB
149 150 static int icmp6_rip6_input __P((struct mbuf **, int));
150 151 #endif
@@ -185,6 +186,64 @@ icmp6_init()
185 186 #endif
186 187 }
187 188
  189 +static void
  190 +icmp6_errcount(stat, type, code)
  191 + struct icmp6errstat *stat;
  192 + int type, code;
  193 +{
  194 + switch(type) {
  195 + case ICMP6_DST_UNREACH:
  196 + switch (code) {
  197 + case ICMP6_DST_UNREACH_NOROUTE:
  198 + stat->icp6errs_dst_unreach_noroute++;
  199 + return;
  200 + case ICMP6_DST_UNREACH_ADMIN:
  201 + stat->icp6errs_dst_unreach_admin++;
  202 + return;
  203 + case ICMP6_DST_UNREACH_BEYONDSCOPE:
  204 + stat->icp6errs_dst_unreach_beyondscope++;
  205 + return;
  206 + case ICMP6_DST_UNREACH_ADDR:
  207 + stat->icp6errs_dst_unreach_addr++;
  208 + return;
  209 + case ICMP6_DST_UNREACH_NOPORT:
  210 + stat->icp6errs_dst_unreach_noport++;
  211 + return;
  212 + }
  213 + break;
  214 + case ICMP6_PACKET_TOO_BIG:
  215 + stat->icp6errs_packet_too_big++;
  216 + return;
  217 + case ICMP6_TIME_EXCEEDED:
  218 + switch(code) {
  219 + case ICMP6_TIME_EXCEED_TRANSIT:
  220 + stat->icp6errs_time_exceed_transit++;
  221 + return;
  222 + case ICMP6_TIME_EXCEED_REASSEMBLY:
  223 + stat->icp6errs_time_exceed_reassembly++;
  224 + return;
  225 + }
  226 + break;
  227 + case ICMP6_PARAM_PROB:
  228 + switch(code) {
  229 + case ICMP6_PARAMPROB_HEADER:
  230 + stat->icp6errs_paramprob_header++;
  231 + return;
  232 + case ICMP6_PARAMPROB_NEXTHEADER:
  233 + stat->icp6errs_paramprob_nextheader++;
  234 + return;
  235 + case ICMP6_PARAMPROB_OPTION:
  236 + stat->icp6errs_paramprob_option++;
  237 + return;
  238 + }
  239 + break;
  240 + case ND_REDIRECT:
  241 + stat->icp6errs_redirect++;
  242 + break;
  243 + }
  244 + stat->icp6errs_unknown++;
  245 +}
  246 +
188 247 /*
189 248 * Generate an error packet of type error in response to bad IP6 packet.
190 249 */
@@ -201,6 +260,9 @@ icmp6_error(m, type, code, param)
201 260
202 261 icmp6stat.icp6s_error++;
203 262
  263 + /* count per-type-code statistics */
  264 + icmp6_errcount(&icmp6stat.icp6s_outerrhist, type, code);
  265 +
204 266 #ifdef M_DECRYPTED /*not openbsd*/
205 267 if (m->m_flags & M_DECRYPTED) {
206 268 icmp6stat.icp6s_canterror++;
@@ -2278,6 +2340,8 @@ icmp6_redirect_output(m0, rt)
2278 2340 struct ifnet *outif = NULL;
2279 2341 struct sockaddr_in6 src_sa;
2280 2342
  2343 + icmp6_errcount(&icmp6stat.icp6s_outerrhist, ND_REDIRECT, 0);
  2344 +
2281 2345 /* if we are not router, we don't send icmp6 redirect */
2282 2346 if (!ip6_forwarding || ip6_accept_rtadv)
2283 2347 goto fail;

0 comments on commit 9fb415a

Please sign in to comment.
Something went wrong with that request. Please try again.