2004-02-05 12:02:37 +00:00
|
|
|
/* $KAME: ipsec.c,v 1.33 2003/07/25 09:54:32 itojun Exp $ */
|
2000-07-04 16:26:46 +00:00
|
|
|
|
2008-01-02 23:26:11 +00:00
|
|
|
/*-
|
2005-12-28 20:36:55 +00:00
|
|
|
* Copyright (c) 2005 NTT Multimedia Communications Laboratories, Inc.
|
|
|
|
* All rights reserved.
|
2008-01-02 23:26:11 +00:00
|
|
|
*
|
2005-12-28 20:36:55 +00:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2008-01-02 23:26:11 +00:00
|
|
|
*
|
2005-12-28 20:36:55 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
2008-01-02 23:26:11 +00:00
|
|
|
/*-
|
2000-07-04 16:26:46 +00:00
|
|
|
* Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
|
|
|
|
* All rights reserved.
|
2008-01-02 23:26:11 +00:00
|
|
|
*
|
2000-07-04 16:26:46 +00:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the project nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
2008-01-02 23:26:11 +00:00
|
|
|
*
|
2000-07-04 16:26:46 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
2008-01-02 23:26:11 +00:00
|
|
|
/*-
|
2000-07-04 16:26:46 +00:00
|
|
|
* Copyright (c) 1983, 1988, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2004-02-05 11:59:37 +00:00
|
|
|
#if 0
|
2004-07-26 20:18:11 +00:00
|
|
|
#ifndef lint
|
|
|
|
static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95";
|
2000-07-04 16:26:46 +00:00
|
|
|
#endif /* not lint */
|
2004-07-26 20:18:11 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
2000-07-04 16:26:46 +00:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/queue.h>
|
|
|
|
#include <sys/socket.h>
|
2007-07-16 17:15:55 +00:00
|
|
|
#include <sys/socketvar.h>
|
2000-07-04 16:26:46 +00:00
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
2007-07-01 12:08:08 +00:00
|
|
|
#ifdef IPSEC
|
2005-12-28 20:36:55 +00:00
|
|
|
#include <netipsec/ipsec.h>
|
|
|
|
#include <netipsec/ah_var.h>
|
|
|
|
#include <netipsec/esp_var.h>
|
|
|
|
#include <netipsec/ipcomp_var.h>
|
2000-07-04 16:26:46 +00:00
|
|
|
#endif
|
|
|
|
|
2006-07-28 16:09:19 +00:00
|
|
|
#include <stdint.h>
|
2000-07-04 16:26:46 +00:00
|
|
|
#include <stdio.h>
|
2009-12-13 03:14:06 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
2000-07-04 16:26:46 +00:00
|
|
|
#include "netstat.h"
|
|
|
|
|
2005-12-28 20:36:55 +00:00
|
|
|
#ifdef IPSEC
|
2001-06-11 12:39:29 +00:00
|
|
|
struct val2str {
|
|
|
|
int val;
|
|
|
|
const char *str;
|
2000-07-04 16:26:46 +00:00
|
|
|
};
|
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
static struct val2str ipsec_ahnames[] = {
|
|
|
|
{ SADB_AALG_NONE, "none", },
|
|
|
|
{ SADB_AALG_MD5HMAC, "hmac-md5", },
|
|
|
|
{ SADB_AALG_SHA1HMAC, "hmac-sha1", },
|
|
|
|
{ SADB_X_AALG_MD5, "md5", },
|
|
|
|
{ SADB_X_AALG_SHA, "sha", },
|
|
|
|
{ SADB_X_AALG_NULL, "null", },
|
|
|
|
#ifdef SADB_X_AALG_SHA2_256
|
|
|
|
{ SADB_X_AALG_SHA2_256, "hmac-sha2-256", },
|
|
|
|
#endif
|
|
|
|
#ifdef SADB_X_AALG_SHA2_384
|
|
|
|
{ SADB_X_AALG_SHA2_384, "hmac-sha2-384", },
|
|
|
|
#endif
|
|
|
|
#ifdef SADB_X_AALG_SHA2_512
|
|
|
|
{ SADB_X_AALG_SHA2_512, "hmac-sha2-512", },
|
2004-02-05 12:02:37 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SADB_X_AALG_RIPEMD160HMAC
|
|
|
|
{ SADB_X_AALG_RIPEMD160HMAC, "hmac-ripemd160", },
|
|
|
|
#endif
|
|
|
|
#ifdef SADB_X_AALG_AES_XCBC_MAC
|
|
|
|
{ SADB_X_AALG_AES_XCBC_MAC, "aes-xcbc-mac", },
|
2001-06-11 12:39:29 +00:00
|
|
|
#endif
|
|
|
|
{ -1, NULL },
|
2000-07-04 16:26:46 +00:00
|
|
|
};
|
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
static struct val2str ipsec_espnames[] = {
|
|
|
|
{ SADB_EALG_NONE, "none", },
|
|
|
|
{ SADB_EALG_DESCBC, "des-cbc", },
|
|
|
|
{ SADB_EALG_3DESCBC, "3des-cbc", },
|
|
|
|
{ SADB_EALG_NULL, "null", },
|
|
|
|
{ SADB_X_EALG_CAST128CBC, "cast128-cbc", },
|
|
|
|
{ SADB_X_EALG_BLOWFISHCBC, "blowfish-cbc", },
|
|
|
|
#ifdef SADB_X_EALG_RIJNDAELCBC
|
|
|
|
{ SADB_X_EALG_RIJNDAELCBC, "rijndael-cbc", },
|
2004-02-05 12:02:37 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SADB_X_EALG_AESCTR
|
|
|
|
{ SADB_X_EALG_AESCTR, "aes-ctr", },
|
2001-06-11 12:39:29 +00:00
|
|
|
#endif
|
|
|
|
{ -1, NULL },
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct val2str ipsec_compnames[] = {
|
|
|
|
{ SADB_X_CALG_NONE, "none", },
|
|
|
|
{ SADB_X_CALG_OUI, "oui", },
|
|
|
|
{ SADB_X_CALG_DEFLATE, "deflate", },
|
|
|
|
{ SADB_X_CALG_LZS, "lzs", },
|
|
|
|
{ -1, NULL },
|
2000-07-04 16:26:46 +00:00
|
|
|
};
|
|
|
|
|
2005-12-28 20:36:55 +00:00
|
|
|
static void ipsec_hist(const u_quad_t *hist, size_t histmax,
|
|
|
|
const struct val2str *name, const char *title);
|
|
|
|
static void print_ipsecstats(const struct ipsecstat *ipsecstat);
|
2000-07-04 16:26:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Dump IPSEC statistics structure.
|
|
|
|
*/
|
|
|
|
static void
|
2004-02-05 11:59:37 +00:00
|
|
|
ipsec_hist(const u_quad_t *hist, size_t histmax, const struct val2str *name,
|
2001-06-15 23:35:13 +00:00
|
|
|
const char *title)
|
2000-07-04 16:26:46 +00:00
|
|
|
{
|
|
|
|
int first;
|
|
|
|
size_t proto;
|
2001-06-11 12:39:29 +00:00
|
|
|
const struct val2str *p;
|
2000-07-04 16:26:46 +00:00
|
|
|
|
2001-06-11 12:39:29 +00:00
|
|
|
first = 1;
|
|
|
|
for (proto = 0; proto < histmax; proto++) {
|
2000-07-04 16:26:46 +00:00
|
|
|
if (hist[proto] <= 0)
|
|
|
|
continue;
|
|
|
|
if (first) {
|
|
|
|
printf("\t%s histogram:\n", title);
|
|
|
|
first = 0;
|
|
|
|
}
|
2001-06-11 12:39:29 +00:00
|
|
|
for (p = name; p && p->str; p++) {
|
2001-06-15 23:55:45 +00:00
|
|
|
if (p->val == (int)proto)
|
2001-06-11 12:39:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (p && p->str) {
|
2006-07-28 16:09:19 +00:00
|
|
|
printf("\t\t%s: %ju\n", p->str, (uintmax_t)hist[proto]);
|
2000-07-04 16:26:46 +00:00
|
|
|
} else {
|
2006-07-28 16:09:19 +00:00
|
|
|
printf("\t\t#%ld: %ju\n", (long)proto,
|
|
|
|
(uintmax_t)hist[proto]);
|
2000-07-04 16:26:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-12-28 20:36:55 +00:00
|
|
|
print_ipsecstats(const struct ipsecstat *ipsecstat)
|
2000-07-04 16:26:46 +00:00
|
|
|
{
|
2005-12-28 20:36:55 +00:00
|
|
|
#define p(f, m) if (ipsecstat->f || sflag <= 1) \
|
2006-07-28 16:09:19 +00:00
|
|
|
printf(m, (uintmax_t)ipsecstat->f, plural(ipsecstat->f))
|
2005-12-28 20:36:55 +00:00
|
|
|
#define pes(f, m) if (ipsecstat->f || sflag <= 1) \
|
2006-07-28 16:09:19 +00:00
|
|
|
printf(m, (uintmax_t)ipsecstat->f, plurales(ipsecstat->f))
|
2008-01-02 23:26:11 +00:00
|
|
|
#define hist(f, n, t) \
|
2001-06-15 23:55:45 +00:00
|
|
|
ipsec_hist((f), sizeof(f)/sizeof(f[0]), (n), (t));
|
2000-07-04 16:26:46 +00:00
|
|
|
|
2006-07-28 16:09:19 +00:00
|
|
|
p(in_success, "\t%ju inbound packet%s processed successfully\n");
|
|
|
|
p(in_polvio, "\t%ju inbound packet%s violated process security "
|
2004-02-05 11:59:37 +00:00
|
|
|
"policy\n");
|
2006-07-28 16:09:19 +00:00
|
|
|
p(in_nosa, "\t%ju inbound packet%s with no SA available\n");
|
|
|
|
p(in_inval, "\t%ju invalid inbound packet%s\n");
|
|
|
|
p(in_nomem, "\t%ju inbound packet%s failed due to insufficient memory\n");
|
|
|
|
p(in_badspi, "\t%ju inbound packet%s failed getting SPI\n");
|
|
|
|
p(in_ahreplay, "\t%ju inbound packet%s failed on AH replay check\n");
|
|
|
|
p(in_espreplay, "\t%ju inbound packet%s failed on ESP replay check\n");
|
|
|
|
p(in_ahauthsucc, "\t%ju inbound packet%s considered authentic\n");
|
|
|
|
p(in_ahauthfail, "\t%ju inbound packet%s failed on authentication\n");
|
2005-12-28 20:36:55 +00:00
|
|
|
hist(ipsecstat->in_ahhist, ipsec_ahnames, "AH input");
|
|
|
|
hist(ipsecstat->in_esphist, ipsec_espnames, "ESP input");
|
|
|
|
hist(ipsecstat->in_comphist, ipsec_compnames, "IPComp input");
|
2000-07-04 16:26:46 +00:00
|
|
|
|
2006-07-28 16:09:19 +00:00
|
|
|
p(out_success, "\t%ju outbound packet%s processed successfully\n");
|
|
|
|
p(out_polvio, "\t%ju outbound packet%s violated process security "
|
2004-02-05 11:59:37 +00:00
|
|
|
"policy\n");
|
2006-07-28 16:09:19 +00:00
|
|
|
p(out_nosa, "\t%ju outbound packet%s with no SA available\n");
|
|
|
|
p(out_inval, "\t%ju invalid outbound packet%s\n");
|
|
|
|
p(out_nomem, "\t%ju outbound packet%s failed due to insufficient memory\n");
|
|
|
|
p(out_noroute, "\t%ju outbound packet%s with no route\n");
|
2005-12-28 20:36:55 +00:00
|
|
|
hist(ipsecstat->out_ahhist, ipsec_ahnames, "AH output");
|
|
|
|
hist(ipsecstat->out_esphist, ipsec_espnames, "ESP output");
|
|
|
|
hist(ipsecstat->out_comphist, ipsec_compnames, "IPComp output");
|
2006-07-28 16:09:19 +00:00
|
|
|
p(spdcachelookup, "\t%ju SPD cache lookup%s\n");
|
|
|
|
pes(spdcachemiss, "\t%ju SPD cache miss%s\n");
|
2004-02-05 12:01:39 +00:00
|
|
|
#undef pes
|
2000-07-04 16:26:46 +00:00
|
|
|
#undef hist
|
2007-07-01 12:08:08 +00:00
|
|
|
p(ips_in_polvio, "\t%ju inbound packet%s violated process "
|
|
|
|
"security policy\n");
|
|
|
|
p(ips_out_polvio, "\t%ju outbound packet%s violated process "
|
|
|
|
"security policy\n");
|
|
|
|
p(ips_out_nosa, "\t%ju outbound packet%s with no SA available\n");
|
|
|
|
p(ips_out_nomem, "\t%ju outbound packet%s failed due to "
|
|
|
|
"insufficient memory\n");
|
|
|
|
p(ips_out_noroute, "\t%ju outbound packet%s with no route "
|
|
|
|
"available\n");
|
|
|
|
p(ips_out_inval, "\t%ju invalid outbound packet%s\n");
|
|
|
|
p(ips_out_bundlesa, "\t%ju outbound packet%s with bundled SAs\n");
|
|
|
|
p(ips_mbcoalesced, "\t%ju mbuf%s coalesced during clone\n");
|
|
|
|
p(ips_clcoalesced, "\t%ju cluster%s coalesced during clone\n");
|
|
|
|
p(ips_clcopied, "\t%ju cluster%s copied during clone\n");
|
|
|
|
p(ips_mbinserted, "\t%ju mbuf%s inserted during makespace\n");
|
|
|
|
#undef p
|
2000-07-04 16:26:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-07-16 17:15:55 +00:00
|
|
|
ipsec_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
|
2000-07-04 16:26:46 +00:00
|
|
|
{
|
2005-12-28 20:36:55 +00:00
|
|
|
struct ipsecstat ipsecstat;
|
|
|
|
|
2000-07-04 16:26:46 +00:00
|
|
|
if (off == 0)
|
|
|
|
return;
|
|
|
|
printf ("%s:\n", name);
|
2013-07-09 10:08:13 +00:00
|
|
|
kread_counters(off, (char *)&ipsecstat, sizeof(ipsecstat));
|
2000-07-04 16:26:46 +00:00
|
|
|
|
2005-12-28 20:36:55 +00:00
|
|
|
print_ipsecstats(&ipsecstat);
|
2000-07-04 16:26:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
Prepare network statistics structures for migration to PCPU counters.
Use uint64_t as type for all fields of structures.
Changed structures: ahstat, arpstat, espstat, icmp6_ifstat, icmp6stat,
in6_ifstat, ip6stat, ipcompstat, ipipstat, ipsecstat, mrt6stat, mrtstat,
pfkeystat, pim6stat, pimstat, rip6stat, udpstat.
Discussed with: arch@
2013-07-09 09:32:06 +00:00
|
|
|
static void ipsec_hist_new(const uint64_t *hist, size_t histmax,
|
2005-12-28 20:36:55 +00:00
|
|
|
const struct val2str *name, const char *title);
|
|
|
|
static void print_ahstats(const struct ahstat *ahstat);
|
|
|
|
static void print_espstats(const struct espstat *espstat);
|
|
|
|
static void print_ipcompstats(const struct ipcompstat *ipcompstat);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Dump IPSEC statistics structure.
|
|
|
|
*/
|
|
|
|
static void
|
Prepare network statistics structures for migration to PCPU counters.
Use uint64_t as type for all fields of structures.
Changed structures: ahstat, arpstat, espstat, icmp6_ifstat, icmp6stat,
in6_ifstat, ip6stat, ipcompstat, ipipstat, ipsecstat, mrt6stat, mrtstat,
pfkeystat, pim6stat, pimstat, rip6stat, udpstat.
Discussed with: arch@
2013-07-09 09:32:06 +00:00
|
|
|
ipsec_hist_new(const uint64_t *hist, size_t histmax,
|
2005-12-28 20:36:55 +00:00
|
|
|
const struct val2str *name, const char *title)
|
2000-07-04 16:26:46 +00:00
|
|
|
{
|
2005-12-28 20:36:55 +00:00
|
|
|
int first;
|
|
|
|
size_t proto;
|
|
|
|
const struct val2str *p;
|
2000-07-04 16:26:46 +00:00
|
|
|
|
2005-12-28 20:36:55 +00:00
|
|
|
first = 1;
|
|
|
|
for (proto = 0; proto < histmax; proto++) {
|
|
|
|
if (hist[proto] <= 0)
|
2000-07-04 16:26:46 +00:00
|
|
|
continue;
|
|
|
|
if (first) {
|
2005-12-28 20:36:55 +00:00
|
|
|
printf("\t%s histogram:\n", title);
|
2000-07-04 16:26:46 +00:00
|
|
|
first = 0;
|
|
|
|
}
|
2005-12-28 20:36:55 +00:00
|
|
|
for (p = name; p && p->str; p++) {
|
|
|
|
if (p->val == (int)proto)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (p && p->str) {
|
Prepare network statistics structures for migration to PCPU counters.
Use uint64_t as type for all fields of structures.
Changed structures: ahstat, arpstat, espstat, icmp6_ifstat, icmp6stat,
in6_ifstat, ip6stat, ipcompstat, ipipstat, ipsecstat, mrt6stat, mrtstat,
pfkeystat, pim6stat, pimstat, rip6stat, udpstat.
Discussed with: arch@
2013-07-09 09:32:06 +00:00
|
|
|
printf("\t\t%s: %ju\n", p->str,
|
|
|
|
(uintmax_t)hist[proto]);
|
2005-12-28 20:36:55 +00:00
|
|
|
} else {
|
Prepare network statistics structures for migration to PCPU counters.
Use uint64_t as type for all fields of structures.
Changed structures: ahstat, arpstat, espstat, icmp6_ifstat, icmp6stat,
in6_ifstat, ip6stat, ipcompstat, ipipstat, ipsecstat, mrt6stat, mrtstat,
pfkeystat, pim6stat, pimstat, rip6stat, udpstat.
Discussed with: arch@
2013-07-09 09:32:06 +00:00
|
|
|
printf("\t\t#%lu: %ju\n", (unsigned long)proto,
|
|
|
|
(uintmax_t)hist[proto]);
|
2000-07-04 16:26:46 +00:00
|
|
|
}
|
|
|
|
}
|
2005-12-28 20:36:55 +00:00
|
|
|
}
|
2008-01-02 23:26:11 +00:00
|
|
|
|
2005-12-28 20:36:55 +00:00
|
|
|
static void
|
|
|
|
print_ahstats(const struct ahstat *ahstat)
|
|
|
|
{
|
Prepare network statistics structures for migration to PCPU counters.
Use uint64_t as type for all fields of structures.
Changed structures: ahstat, arpstat, espstat, icmp6_ifstat, icmp6stat,
in6_ifstat, ip6stat, ipcompstat, ipipstat, ipsecstat, mrt6stat, mrtstat,
pfkeystat, pim6stat, pimstat, rip6stat, udpstat.
Discussed with: arch@
2013-07-09 09:32:06 +00:00
|
|
|
#define p(f, m) if (ahstat->f || sflag <= 1) \
|
2006-07-28 16:09:19 +00:00
|
|
|
printf("\t%ju" m, (uintmax_t)ahstat->f, plural(ahstat->f))
|
2008-01-02 23:26:11 +00:00
|
|
|
#define hist(f, n, t) \
|
2005-12-28 20:36:55 +00:00
|
|
|
ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t));
|
|
|
|
|
Prepare network statistics structures for migration to PCPU counters.
Use uint64_t as type for all fields of structures.
Changed structures: ahstat, arpstat, espstat, icmp6_ifstat, icmp6stat,
in6_ifstat, ip6stat, ipcompstat, ipipstat, ipsecstat, mrt6stat, mrtstat,
pfkeystat, pim6stat, pimstat, rip6stat, udpstat.
Discussed with: arch@
2013-07-09 09:32:06 +00:00
|
|
|
p(ahs_hdrops, " packet%s shorter than header shows\n");
|
|
|
|
p(ahs_nopf, " packet%s dropped; protocol family not supported\n");
|
|
|
|
p(ahs_notdb, " packet%s dropped; no TDB\n");
|
|
|
|
p(ahs_badkcr, " packet%s dropped; bad KCR\n");
|
|
|
|
p(ahs_qfull, " packet%s dropped; queue full\n");
|
|
|
|
p(ahs_noxform, " packet%s dropped; no transform\n");
|
|
|
|
p(ahs_wrap, " replay counter wrap%s\n");
|
|
|
|
p(ahs_badauth, " packet%s dropped; bad authentication detected\n");
|
|
|
|
p(ahs_badauthl, " packet%s dropped; bad authentication length\n");
|
|
|
|
p(ahs_replay, " possible replay packet%s detected\n");
|
|
|
|
p(ahs_input, " packet%s in\n");
|
|
|
|
p(ahs_output, " packet%s out\n");
|
|
|
|
p(ahs_invalid, " packet%s dropped; invalid TDB\n");
|
|
|
|
p(ahs_ibytes, " byte%s in\n");
|
|
|
|
p(ahs_obytes, " byte%s out\n");
|
|
|
|
p(ahs_toobig, " packet%s dropped; larger than IP_MAXPACKET\n");
|
|
|
|
p(ahs_pdrops, " packet%s blocked due to policy\n");
|
|
|
|
p(ahs_crypto, " crypto processing failure%s\n");
|
|
|
|
p(ahs_tunnel, " tunnel sanity check failure%s\n");
|
2005-12-28 20:36:55 +00:00
|
|
|
hist(ahstat->ahs_hist, ipsec_ahnames, "AH output");
|
|
|
|
|
Prepare network statistics structures for migration to PCPU counters.
Use uint64_t as type for all fields of structures.
Changed structures: ahstat, arpstat, espstat, icmp6_ifstat, icmp6stat,
in6_ifstat, ip6stat, ipcompstat, ipipstat, ipsecstat, mrt6stat, mrtstat,
pfkeystat, pim6stat, pimstat, rip6stat, udpstat.
Discussed with: arch@
2013-07-09 09:32:06 +00:00
|
|
|
#undef p
|
2005-12-28 20:36:55 +00:00
|
|
|
#undef hist
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-07-16 17:15:55 +00:00
|
|
|
ah_stats(u_long off, const char *name, int family __unused, int proto __unused)
|
2005-12-28 20:36:55 +00:00
|
|
|
{
|
|
|
|
struct ahstat ahstat;
|
|
|
|
|
|
|
|
if (off == 0)
|
|
|
|
return;
|
|
|
|
printf ("%s:\n", name);
|
2013-07-09 10:08:13 +00:00
|
|
|
kread_counters(off, (char *)&ahstat, sizeof(ahstat));
|
2005-12-28 20:36:55 +00:00
|
|
|
|
|
|
|
print_ahstats(&ahstat);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_espstats(const struct espstat *espstat)
|
|
|
|
{
|
Prepare network statistics structures for migration to PCPU counters.
Use uint64_t as type for all fields of structures.
Changed structures: ahstat, arpstat, espstat, icmp6_ifstat, icmp6stat,
in6_ifstat, ip6stat, ipcompstat, ipipstat, ipsecstat, mrt6stat, mrtstat,
pfkeystat, pim6stat, pimstat, rip6stat, udpstat.
Discussed with: arch@
2013-07-09 09:32:06 +00:00
|
|
|
#define p(f, m) if (espstat->f || sflag <= 1) \
|
2006-07-28 16:09:19 +00:00
|
|
|
printf("\t%ju" m, (uintmax_t)espstat->f, plural(espstat->f))
|
2008-01-02 23:26:11 +00:00
|
|
|
#define hist(f, n, t) \
|
2005-12-28 20:36:55 +00:00
|
|
|
ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t));
|
|
|
|
|
Prepare network statistics structures for migration to PCPU counters.
Use uint64_t as type for all fields of structures.
Changed structures: ahstat, arpstat, espstat, icmp6_ifstat, icmp6stat,
in6_ifstat, ip6stat, ipcompstat, ipipstat, ipsecstat, mrt6stat, mrtstat,
pfkeystat, pim6stat, pimstat, rip6stat, udpstat.
Discussed with: arch@
2013-07-09 09:32:06 +00:00
|
|
|
p(esps_hdrops, " packet%s shorter than header shows\n");
|
|
|
|
p(esps_nopf, " packet%s dropped; protocol family not supported\n");
|
|
|
|
p(esps_notdb, " packet%s dropped; no TDB\n");
|
|
|
|
p(esps_badkcr, " packet%s dropped; bad KCR\n");
|
|
|
|
p(esps_qfull, " packet%s dropped; queue full\n");
|
|
|
|
p(esps_noxform, " packet%s dropped; no transform\n");
|
|
|
|
p(esps_badilen, " packet%s dropped; bad ilen\n");
|
|
|
|
p(esps_wrap, " replay counter wrap%s\n");
|
|
|
|
p(esps_badenc, " packet%s dropped; bad encryption detected\n");
|
|
|
|
p(esps_badauth, " packet%s dropped; bad authentication detected\n");
|
|
|
|
p(esps_replay, " possible replay packet%s detected\n");
|
|
|
|
p(esps_input, " packet%s in\n");
|
|
|
|
p(esps_output, " packet%s out\n");
|
|
|
|
p(esps_invalid, " packet%s dropped; invalid TDB\n");
|
|
|
|
p(esps_ibytes, " byte%s in\n");
|
|
|
|
p(esps_obytes, " byte%s out\n");
|
|
|
|
p(esps_toobig, " packet%s dropped; larger than IP_MAXPACKET\n");
|
|
|
|
p(esps_pdrops, " packet%s blocked due to policy\n");
|
|
|
|
p(esps_crypto, " crypto processing failure%s\n");
|
|
|
|
p(esps_tunnel, " tunnel sanity check failure%s\n");
|
2005-12-28 20:36:55 +00:00
|
|
|
hist(espstat->esps_hist, ipsec_espnames, "ESP output");
|
|
|
|
|
Prepare network statistics structures for migration to PCPU counters.
Use uint64_t as type for all fields of structures.
Changed structures: ahstat, arpstat, espstat, icmp6_ifstat, icmp6stat,
in6_ifstat, ip6stat, ipcompstat, ipipstat, ipsecstat, mrt6stat, mrtstat,
pfkeystat, pim6stat, pimstat, rip6stat, udpstat.
Discussed with: arch@
2013-07-09 09:32:06 +00:00
|
|
|
#undef p
|
2005-12-28 20:36:55 +00:00
|
|
|
#undef hist
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-07-16 17:15:55 +00:00
|
|
|
esp_stats(u_long off, const char *name, int family __unused, int proto __unused)
|
2005-12-28 20:36:55 +00:00
|
|
|
{
|
|
|
|
struct espstat espstat;
|
|
|
|
|
|
|
|
if (off == 0)
|
|
|
|
return;
|
|
|
|
printf ("%s:\n", name);
|
2013-07-09 10:08:13 +00:00
|
|
|
kread_counters(off, (char *)&espstat, sizeof(espstat));
|
2005-12-28 20:36:55 +00:00
|
|
|
|
|
|
|
print_espstats(&espstat);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_ipcompstats(const struct ipcompstat *ipcompstat)
|
|
|
|
{
|
Prepare network statistics structures for migration to PCPU counters.
Use uint64_t as type for all fields of structures.
Changed structures: ahstat, arpstat, espstat, icmp6_ifstat, icmp6stat,
in6_ifstat, ip6stat, ipcompstat, ipipstat, ipsecstat, mrt6stat, mrtstat,
pfkeystat, pim6stat, pimstat, rip6stat, udpstat.
Discussed with: arch@
2013-07-09 09:32:06 +00:00
|
|
|
#define p(f, m) if (ipcompstat->f || sflag <= 1) \
|
2006-07-28 16:09:19 +00:00
|
|
|
printf("\t%ju" m, (uintmax_t)ipcompstat->f, plural(ipcompstat->f))
|
2008-01-02 23:26:11 +00:00
|
|
|
#define hist(f, n, t) \
|
2005-12-28 20:36:55 +00:00
|
|
|
ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t));
|
|
|
|
|
Prepare network statistics structures for migration to PCPU counters.
Use uint64_t as type for all fields of structures.
Changed structures: ahstat, arpstat, espstat, icmp6_ifstat, icmp6stat,
in6_ifstat, ip6stat, ipcompstat, ipipstat, ipsecstat, mrt6stat, mrtstat,
pfkeystat, pim6stat, pimstat, rip6stat, udpstat.
Discussed with: arch@
2013-07-09 09:32:06 +00:00
|
|
|
p(ipcomps_hdrops, " packet%s shorter than header shows\n");
|
|
|
|
p(ipcomps_nopf, " packet%s dropped; protocol family not supported\n");
|
|
|
|
p(ipcomps_notdb, " packet%s dropped; no TDB\n");
|
|
|
|
p(ipcomps_badkcr, " packet%s dropped; bad KCR\n");
|
|
|
|
p(ipcomps_qfull, " packet%s dropped; queue full\n");
|
|
|
|
p(ipcomps_noxform, " packet%s dropped; no transform\n");
|
|
|
|
p(ipcomps_wrap, " replay counter wrap%s\n");
|
|
|
|
p(ipcomps_input, " packet%s in\n");
|
|
|
|
p(ipcomps_output, " packet%s out\n");
|
|
|
|
p(ipcomps_invalid, " packet%s dropped; invalid TDB\n");
|
|
|
|
p(ipcomps_ibytes, " byte%s in\n");
|
|
|
|
p(ipcomps_obytes, " byte%s out\n");
|
|
|
|
p(ipcomps_toobig, " packet%s dropped; larger than IP_MAXPACKET\n");
|
|
|
|
p(ipcomps_pdrops, " packet%s blocked due to policy\n");
|
|
|
|
p(ipcomps_crypto, " crypto processing failure%s\n");
|
2005-12-28 20:36:55 +00:00
|
|
|
hist(ipcompstat->ipcomps_hist, ipsec_compnames, "COMP output");
|
Prepare network statistics structures for migration to PCPU counters.
Use uint64_t as type for all fields of structures.
Changed structures: ahstat, arpstat, espstat, icmp6_ifstat, icmp6stat,
in6_ifstat, ip6stat, ipcompstat, ipipstat, ipsecstat, mrt6stat, mrtstat,
pfkeystat, pim6stat, pimstat, rip6stat, udpstat.
Discussed with: arch@
2013-07-09 09:32:06 +00:00
|
|
|
p(ipcomps_threshold, " packet%s sent uncompressed; size < compr. algo. threshold\n");
|
|
|
|
p(ipcomps_uncompr, " packet%s sent uncompressed; compression was useless\n");
|
2005-12-28 20:36:55 +00:00
|
|
|
|
Prepare network statistics structures for migration to PCPU counters.
Use uint64_t as type for all fields of structures.
Changed structures: ahstat, arpstat, espstat, icmp6_ifstat, icmp6stat,
in6_ifstat, ip6stat, ipcompstat, ipipstat, ipsecstat, mrt6stat, mrtstat,
pfkeystat, pim6stat, pimstat, rip6stat, udpstat.
Discussed with: arch@
2013-07-09 09:32:06 +00:00
|
|
|
#undef p
|
2005-12-28 20:36:55 +00:00
|
|
|
#undef hist
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-07-16 17:15:55 +00:00
|
|
|
ipcomp_stats(u_long off, const char *name, int family __unused,
|
|
|
|
int proto __unused)
|
2005-12-28 20:36:55 +00:00
|
|
|
{
|
|
|
|
struct ipcompstat ipcompstat;
|
|
|
|
|
|
|
|
if (off == 0)
|
|
|
|
return;
|
|
|
|
printf ("%s:\n", name);
|
2013-07-09 10:08:13 +00:00
|
|
|
kread_counters(off, (char *)&ipcompstat, sizeof(ipcompstat));
|
2005-12-28 20:36:55 +00:00
|
|
|
|
|
|
|
print_ipcompstats(&ipcompstat);
|
|
|
|
}
|
|
|
|
|
2000-07-04 16:26:46 +00:00
|
|
|
#endif /*IPSEC*/
|