Home | History | Annotate | Line # | Download | only in netstat
fast_ipsec.c revision 1.9.4.1
      1  1.9.4.1      yamt /*	$NetBSD: fast_ipsec.c,v 1.9.4.1 2008/05/18 12:36:07 yamt Exp $ */
      2      1.1  jonathan /* 	$FreeBSD: src/tools/tools/crypto/ipsecstats.c,v 1.1.4.1 2003/06/03 00:13:13 sam Exp $ */
      3      1.1  jonathan 
      4      1.1  jonathan /*-
      5      1.1  jonathan  * Copyright (c) 2003, 2004 Jonathan Stone
      6      1.1  jonathan  * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
      7      1.1  jonathan  * All rights reserved.
      8      1.1  jonathan  *
      9      1.1  jonathan  * Redistribution and use in source and binary forms, with or without
     10      1.1  jonathan  * modification, are permitted provided that the following conditions
     11      1.1  jonathan  * are met:
     12      1.1  jonathan  * 1. Redistributions of source code must retain the above copyright
     13      1.1  jonathan  *    notice, this list of conditions and the following disclaimer.
     14      1.1  jonathan  * 2. Redistributions in binary form must reproduce the above copyright
     15      1.1  jonathan  *    notice, this list of conditions and the following disclaimer in the
     16      1.1  jonathan  *    documentation and/or other materials provided with the distribution.
     17      1.1  jonathan  *
     18      1.1  jonathan  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     19      1.1  jonathan  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     20      1.1  jonathan  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     21      1.1  jonathan  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     22      1.1  jonathan  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     23      1.1  jonathan  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     24      1.1  jonathan  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     25      1.1  jonathan  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     26      1.1  jonathan  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27      1.1  jonathan  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     28      1.1  jonathan  * SUCH DAMAGE.
     29      1.1  jonathan  *
     30      1.1  jonathan  * $FreeBSD: src/tools/tools/crypto/ipsecstats.c,v 1.1.4.1 2003/06/03 00:13:13 sam Exp $
     31      1.1  jonathan  */
     32      1.1  jonathan 
     33      1.1  jonathan #include <sys/cdefs.h>
     34      1.1  jonathan #ifndef lint
     35      1.1  jonathan #ifdef __NetBSD__
     36  1.9.4.1      yamt __RCSID("$NetBSD: fast_ipsec.c,v 1.9.4.1 2008/05/18 12:36:07 yamt Exp $");
     37      1.1  jonathan #endif
     38      1.1  jonathan #endif /* not lint*/
     39      1.1  jonathan 
     40      1.1  jonathan /* Kernel headers required, but not included, by netstat.h */
     41      1.1  jonathan #include <sys/types.h>
     42      1.1  jonathan #include <sys/socket.h>
     43      1.1  jonathan 
     44      1.1  jonathan /* Kernel headers for sysctl(3). */
     45      1.1  jonathan #include <sys/param.h>
     46      1.1  jonathan #include <sys/sysctl.h>
     47      1.1  jonathan 
     48      1.1  jonathan /* Kernel headers for FAST_IPSEC statistics */
     49      1.1  jonathan #include <net/pfkeyv2.h>
     50      1.1  jonathan #include <netipsec/esp_var.h>
     51      1.1  jonathan #include <netipsec/ah_var.h>
     52      1.1  jonathan #include <netipsec/ipip_var.h>
     53      1.1  jonathan #include <netipsec/ipcomp_var.h>
     54      1.1  jonathan #include <netipsec/ipsec_var.h>
     55      1.1  jonathan #include <netipsec/keydb.h>
     56      1.1  jonathan 
     57      1.2    petrov #include <machine/int_fmtio.h>
     58      1.2    petrov 
     59      1.7    rpaulo #include <kvm.h>
     60      1.1  jonathan #include <err.h>
     61      1.6    atatat #include <errno.h>
     62      1.1  jonathan #include <stdio.h>
     63      1.1  jonathan #include <string.h>
     64      1.1  jonathan 
     65      1.1  jonathan #include "netstat.h"
     66      1.1  jonathan 
     67      1.1  jonathan /*
     68      1.6    atatat  * Cache the check to see if we have fast_ipsec so that we don't
     69      1.6    atatat  * have to go to the kernel repeatedly.
     70      1.6    atatat  */
     71      1.6    atatat static int
     72      1.6    atatat have_fast_ipsec(void)
     73      1.6    atatat {
     74      1.6    atatat 	static int haveit = -1;
     75      1.6    atatat 
     76      1.6    atatat 	if (haveit == -1) {
     77      1.6    atatat 		if (sysctlbyname("net.inet.ipsec.ipsecstats", NULL, NULL,
     78      1.6    atatat 		    NULL, 0) == -1)
     79      1.6    atatat 			haveit = 0;
     80      1.6    atatat 		else
     81      1.6    atatat 			haveit = 1;
     82      1.6    atatat 	}
     83      1.6    atatat 
     84      1.6    atatat 	return (haveit);
     85      1.6    atatat }
     86      1.6    atatat 
     87      1.6    atatat /*
     88      1.1  jonathan  * Dispatch between fetching and printing (KAME) IPsec statistics,
     89      1.1  jonathan  * and FAST_IPSEC statistics, so the rest of netstat need not know
     90      1.1  jonathan  * about the vagaries of the two implementations.
     91      1.1  jonathan  */
     92      1.1  jonathan void
     93      1.1  jonathan ipsec_switch(u_long off, char * name)
     94      1.1  jonathan {
     95      1.6    atatat 
     96      1.6    atatat 	if (have_fast_ipsec())
     97      1.4  christos 		return fast_ipsec_stats(off, name);
     98      1.1  jonathan 
     99      1.5  jonathan 	return ipsec_stats(off, name);
    100      1.1  jonathan }
    101      1.1  jonathan 
    102      1.1  jonathan 
    103      1.1  jonathan /*
    104      1.1  jonathan  * Table-driven mapping from SADB algorithm codes to string names.
    105      1.1  jonathan  */
    106      1.1  jonathan struct alg {
    107      1.1  jonathan 	int		a;
    108      1.1  jonathan 	const char	*name;
    109      1.1  jonathan };
    110      1.1  jonathan static const struct alg aalgs[] = {
    111      1.1  jonathan 	{ SADB_AALG_NONE,	"none", },
    112      1.1  jonathan 	{ SADB_AALG_MD5HMAC,	"hmac-md5", },
    113      1.1  jonathan 	{ SADB_AALG_SHA1HMAC,	"hmac-sha1", },
    114      1.1  jonathan 	{ SADB_X_AALG_MD5,	"md5", },
    115      1.1  jonathan 	{ SADB_X_AALG_SHA,	"sha", },
    116      1.1  jonathan 	{ SADB_X_AALG_NULL,	"null", },
    117      1.1  jonathan 	{ SADB_X_AALG_SHA2_256,	"hmac-sha2-256", },
    118      1.1  jonathan 	{ SADB_X_AALG_SHA2_384,	"hmac-sha2-384", },
    119      1.1  jonathan 	{ SADB_X_AALG_SHA2_512,	"hmac-sha2-512", },
    120      1.1  jonathan };
    121      1.1  jonathan static const struct alg espalgs[] = {
    122      1.1  jonathan 	{ SADB_EALG_NONE,	"none", },
    123      1.1  jonathan 	{ SADB_EALG_DESCBC,	"des-cbc", },
    124      1.1  jonathan 	{ SADB_EALG_3DESCBC,	"3des-cbc", },
    125      1.1  jonathan 	{ SADB_EALG_NULL,	"null", },
    126      1.1  jonathan 	{ SADB_X_EALG_CAST128CBC, "cast128-cbc", },
    127      1.1  jonathan 	{ SADB_X_EALG_BLOWFISHCBC, "blowfish-cbc", },
    128      1.1  jonathan 	{ SADB_X_EALG_RIJNDAELCBC, "aes-cbc", },
    129      1.1  jonathan };
    130      1.1  jonathan static const struct alg ipcompalgs[] = {
    131      1.1  jonathan 	{ SADB_X_CALG_NONE,	"none", },
    132      1.1  jonathan 	{ SADB_X_CALG_OUI,	"oui", },
    133      1.1  jonathan 	{ SADB_X_CALG_DEFLATE,	"deflate", },
    134      1.1  jonathan 	{ SADB_X_CALG_LZS,	"lzs", },
    135      1.1  jonathan };
    136      1.1  jonathan #define	N(a)	(sizeof(a)/sizeof(a[0]))
    137      1.1  jonathan 
    138      1.1  jonathan static const char*
    139      1.1  jonathan algname(int a, const struct alg algs[], int nalgs)
    140      1.1  jonathan {
    141      1.1  jonathan 	static char buf[80];
    142      1.1  jonathan 	int i;
    143      1.1  jonathan 
    144      1.1  jonathan 	for (i = 0; i < nalgs; i++)
    145      1.1  jonathan 		if (algs[i].a == a)
    146      1.1  jonathan 			return algs[i].name;
    147      1.1  jonathan 	snprintf(buf, sizeof(buf), "alg#%u", a);
    148      1.1  jonathan 	return buf;
    149      1.1  jonathan }
    150      1.1  jonathan 
    151      1.1  jonathan /*
    152      1.1  jonathan  * Print the fast_ipsec statistics.
    153      1.1  jonathan  * Since NetBSD's netstat(1) seems not to find us for "netstat -s",
    154      1.1  jonathan  * but does(?) find KAME, be prepared to be called explicitly from
    155      1.1  jonathan  * netstat's main program for "netstat -s"; but silently do nothing
    156      1.1  jonathan  * if that happens when we are running on KAME IPsec.
    157      1.1  jonathan  */
    158      1.1  jonathan void
    159      1.1  jonathan fast_ipsec_stats(u_long off, char *name)
    160      1.1  jonathan {
    161  1.9.4.1      yamt 	uint64_t ipsecstats[IPSEC_NSTATS];
    162  1.9.4.1      yamt 	uint64_t ahstats[AH_NSTATS];
    163  1.9.4.1      yamt 	uint64_t espstats[ESP_NSTATS];
    164  1.9.4.1      yamt 	uint64_t ipcs[IPCOMP_NSTATS];
    165  1.9.4.1      yamt 	uint64_t ipips[IPIP_NSTATS];
    166      1.2    petrov 	int status;
    167      1.2    petrov 	size_t slen;
    168      1.1  jonathan 	int i;
    169      1.1  jonathan 
    170  1.9.4.1      yamt 	if (! use_sysctl) {
    171  1.9.4.1      yamt 		warnx("IPsec stats not available via KVM.");
    172  1.9.4.1      yamt 		return;
    173  1.9.4.1      yamt 	}
    174  1.9.4.1      yamt 
    175  1.9.4.1      yamt 	memset(ipsecstats, 0, sizeof(ipsecstats));
    176  1.9.4.1      yamt 	memset(ahstats, 0, sizeof(ahstats));
    177  1.9.4.1      yamt 	memset(espstats, 0, sizeof(espstats));
    178  1.9.4.1      yamt 	memset(ipcs, 0, sizeof(ipcs));
    179  1.9.4.1      yamt 	memset(ipips, 0, sizeof(ipips));
    180      1.1  jonathan 
    181      1.1  jonathan 	/* silence check */
    182      1.6    atatat 	if (!have_fast_ipsec())
    183      1.6    atatat 		return;
    184      1.1  jonathan 
    185      1.1  jonathan 	slen = sizeof(ipsecstats);
    186  1.9.4.1      yamt 	status = sysctlbyname("net.inet.ipsec.ipsecstats", ipsecstats, &slen,
    187      1.1  jonathan 			      NULL, 0);
    188      1.6    atatat 	if (status < 0 && errno != ENOMEM)
    189      1.6    atatat 		err(1, "net.inet.ipsec.ipsecstats");
    190      1.1  jonathan 
    191      1.1  jonathan 	slen = sizeof (ahstats);
    192  1.9.4.1      yamt 	status = sysctlbyname("net.inet.ah.ah_stats", ahstats, &slen, NULL, 0);
    193      1.6    atatat 	if (status < 0 && errno != ENOMEM)
    194      1.6    atatat 		err(1, "net.inet.ah.ah_stats");
    195      1.6    atatat 
    196      1.1  jonathan 	slen = sizeof (espstats);
    197  1.9.4.1      yamt 	status = sysctlbyname("net.inet.esp.esp_stats", espstats, &slen, NULL, 0);
    198      1.6    atatat 	if (status < 0 && errno != ENOMEM)
    199      1.6    atatat 		err(1, "net.inet.esp.esp_stats");
    200      1.6    atatat 
    201      1.6    atatat 	slen = sizeof(ipcs);
    202  1.9.4.1      yamt 	status = sysctlbyname("net.inet.ipcomp.ipcomp_stats", ipcs, &slen, NULL, 0);
    203      1.6    atatat 	if (status < 0 && errno != ENOMEM)
    204      1.6    atatat 		err(1, "net.inet.ipcomp.ipcomp_stats");
    205      1.6    atatat 
    206      1.6    atatat 	slen = sizeof(ipips);
    207  1.9.4.1      yamt 	status = sysctlbyname("net.inet.ipip.ipip_stats", ipips, &slen, NULL, 0);
    208      1.6    atatat 	if (status < 0 && errno != ENOMEM)
    209      1.6    atatat 		err(1, "net.inet.ipip.ipip_stats");
    210      1.1  jonathan 
    211      1.1  jonathan 	printf("(Fast) IPsec:\n");
    212      1.1  jonathan 
    213      1.2    petrov #define	STAT(x,fmt)	if ((x) || sflag <= 1) printf("\t%"PRIu64" " fmt "\n", x)
    214  1.9.4.1      yamt 	if (ipsecstats[IPSEC_STAT_IN_POLVIO]+ipsecstats[IPSEC_STAT_OUT_POLVIO])
    215      1.2    petrov 		printf("\t%"PRIu64" policy violations: %"PRIu64" input %"PRIu64" output\n",
    216  1.9.4.1      yamt 		        ipsecstats[IPSEC_STAT_IN_POLVIO] + ipsecstats[IPSEC_STAT_OUT_POLVIO],
    217  1.9.4.1      yamt 			ipsecstats[IPSEC_STAT_IN_POLVIO], ipsecstats[IPSEC_STAT_OUT_POLVIO]);
    218  1.9.4.1      yamt 	STAT(ipsecstats[IPSEC_STAT_OUT_NOSA], "no SA found (output)");
    219  1.9.4.1      yamt 	STAT(ipsecstats[IPSEC_STAT_OUT_NOMEM], "no memory available (output)");
    220  1.9.4.1      yamt 	STAT(ipsecstats[IPSEC_STAT_OUT_NOROUTE], "no route available (output)");
    221  1.9.4.1      yamt 	STAT(ipsecstats[IPSEC_STAT_OUT_INVAL], "generic errors (output)");
    222  1.9.4.1      yamt 	STAT(ipsecstats[IPSEC_STAT_OUT_BUNDLESA], "bundled SA processed (output)");
    223  1.9.4.1      yamt 	STAT(ipsecstats[IPSEC_STAT_SPDCACHELOOKUP], "SPD cache lookups");
    224  1.9.4.1      yamt 	STAT(ipsecstats[IPSEC_STAT_SPDCACHEMISS], "SPD cache misses");
    225      1.1  jonathan #undef STAT
    226      1.1  jonathan 	printf("\n");
    227      1.1  jonathan 
    228      1.1  jonathan 	printf("IPsec ah:\n");
    229      1.2    petrov #define	AHSTAT(x,fmt)	if ((x) || sflag <= 1) printf("\t%"PRIu64" ah " fmt "\n", x)
    230  1.9.4.1      yamt 	AHSTAT(ahstats[AH_STAT_INPUT],   "input packets processed");
    231  1.9.4.1      yamt 	AHSTAT(ahstats[AH_STAT_OUTPUT],  "output packets processed");
    232  1.9.4.1      yamt 	AHSTAT(ahstats[AH_STAT_HDROPS],  "headers too short");
    233  1.9.4.1      yamt 	AHSTAT(ahstats[AH_STAT_NOPF],    "headers for unsupported address family");
    234  1.9.4.1      yamt 	AHSTAT(ahstats[AH_STAT_NOTDB],   "packets with no SA");
    235  1.9.4.1      yamt 	AHSTAT(ahstats[AH_STAT_BADKCR], "packets dropped by crypto returning NULL mbuf");
    236  1.9.4.1      yamt 	AHSTAT(ahstats[AH_STAT_BADAUTH], "packets with bad authentication");
    237  1.9.4.1      yamt 	AHSTAT(ahstats[AH_STAT_NOXFORM], "packets with no xform");
    238  1.9.4.1      yamt 	AHSTAT(ahstats[AH_STAT_QFULL], "packets dropped due to queue full");
    239  1.9.4.1      yamt 	AHSTAT(ahstats[AH_STAT_WRAP],  "packets dropped for replay counter wrap");
    240  1.9.4.1      yamt 	AHSTAT(ahstats[AH_STAT_REPLAY],  "packets dropped for possible replay");
    241  1.9.4.1      yamt 	AHSTAT(ahstats[AH_STAT_BADAUTHL],"packets dropped for bad authenticator length");
    242  1.9.4.1      yamt 	AHSTAT(ahstats[AH_STAT_INVALID], "packets with an invalid SA");
    243  1.9.4.1      yamt 	AHSTAT(ahstats[AH_STAT_TOOBIG],  "packets too big");
    244  1.9.4.1      yamt 	AHSTAT(ahstats[AH_STAT_PDROPS],  "packets blocked due to policy");
    245  1.9.4.1      yamt 	AHSTAT(ahstats[AH_STAT_CRYPTO],  "failed crypto requests");
    246  1.9.4.1      yamt 	AHSTAT(ahstats[AH_STAT_TUNNEL],  "tunnel sanity check failures");
    247      1.1  jonathan 
    248      1.1  jonathan 	printf("\tah histogram:\n");
    249      1.1  jonathan 	for (i = 0; i < AH_ALG_MAX; i++)
    250  1.9.4.1      yamt 		if (ahstats[AH_STAT_HIST + i])
    251      1.2    petrov 			printf("\t\tah packets with %s: %"PRIu64"\n"
    252      1.1  jonathan 				, algname(i, aalgs, N(aalgs))
    253  1.9.4.1      yamt 				, ahstats[AH_STAT_HIST + i]
    254      1.1  jonathan 			);
    255  1.9.4.1      yamt 	AHSTAT(ahstats[AH_STAT_IBYTES], "bytes received");
    256  1.9.4.1      yamt 	AHSTAT(ahstats[AH_STAT_OBYTES], "bytes transmitted");
    257      1.1  jonathan #undef AHSTAT
    258      1.1  jonathan 	printf("\n");
    259      1.1  jonathan 
    260      1.1  jonathan 	printf("IPsec esp:\n");
    261      1.2    petrov #define	ESPSTAT(x,fmt) if ((x) || sflag <= 1) printf("\t%"PRIu64" esp " fmt "\n", x)
    262  1.9.4.1      yamt 	ESPSTAT(espstats[ESP_STAT_INPUT],"input packets processed");
    263  1.9.4.1      yamt 	ESPSTAT(espstats[ESP_STAT_OUTPUT],"output packets processed");
    264  1.9.4.1      yamt 	ESPSTAT(espstats[ESP_STAT_HDROPS],"headers too short");
    265  1.9.4.1      yamt 	ESPSTAT(espstats[ESP_STAT_NOPF], "headers for unsupported address family");
    266  1.9.4.1      yamt 	ESPSTAT(espstats[ESP_STAT_NOTDB],"packets with no SA");
    267  1.9.4.1      yamt 	ESPSTAT(espstats[ESP_STAT_BADKCR],"packets dropped by crypto returning NULL mbuf");
    268  1.9.4.1      yamt 	ESPSTAT(espstats[ESP_STAT_QFULL],"packets dropped due to queue full");
    269  1.9.4.1      yamt 	ESPSTAT(espstats[ESP_STAT_NOXFORM],"packets with no xform");
    270  1.9.4.1      yamt 	ESPSTAT(espstats[ESP_STAT_BADILEN],"packets with bad ilen");
    271  1.9.4.1      yamt 	ESPSTAT(espstats[ESP_STAT_BADENC],"packets with bad encryption");
    272  1.9.4.1      yamt 	ESPSTAT(espstats[ESP_STAT_BADAUTH],"packets with bad authentication");
    273  1.9.4.1      yamt 	ESPSTAT(espstats[ESP_STAT_WRAP], "packets dropped for replay counter wrap");
    274  1.9.4.1      yamt 	ESPSTAT(espstats[ESP_STAT_REPLAY],"packets dropped for possible replay");
    275  1.9.4.1      yamt 	ESPSTAT(espstats[ESP_STAT_INVALID],"packets with an invalid SA");
    276  1.9.4.1      yamt 	ESPSTAT(espstats[ESP_STAT_TOOBIG],"packets too big");
    277  1.9.4.1      yamt 	ESPSTAT(espstats[ESP_STAT_PDROPS],"packets blocked due to policy");
    278  1.9.4.1      yamt 	ESPSTAT(espstats[ESP_STAT_CRYPTO],"failed crypto requests");
    279  1.9.4.1      yamt 	ESPSTAT(espstats[ESP_STAT_TUNNEL],"tunnel sanity check failures");
    280      1.1  jonathan 	printf("\tesp histogram:\n");
    281      1.1  jonathan 	for (i = 0; i < ESP_ALG_MAX; i++)
    282  1.9.4.1      yamt 		if (espstats[ESP_STAT_HIST + i])
    283      1.2    petrov 			printf("\t\tesp packets with %s: %"PRIu64"\n"
    284      1.1  jonathan 				, algname(i, espalgs, N(espalgs))
    285  1.9.4.1      yamt 				, espstats[ESP_STAT_HIST + i]
    286      1.1  jonathan 			);
    287  1.9.4.1      yamt 	ESPSTAT(espstats[ESP_STAT_IBYTES], "bytes received");
    288  1.9.4.1      yamt 	ESPSTAT(espstats[ESP_STAT_OBYTES], "bytes transmitted");
    289      1.1  jonathan #undef ESPSTAT
    290      1.1  jonathan 	printf("IPsec ipip:\n");
    291      1.1  jonathan 
    292      1.1  jonathan #define	IPIPSTAT(x,fmt) \
    293      1.2    petrov 	if ((x) || sflag <= 1) printf("\t%"PRIu64" ipip " fmt "\n", x)
    294  1.9.4.1      yamt 	IPIPSTAT(ipips[IPIP_STAT_IPACKETS],"total input packets");
    295  1.9.4.1      yamt 	IPIPSTAT(ipips[IPIP_STAT_OPACKETS],"total output packets");
    296  1.9.4.1      yamt 	IPIPSTAT(ipips[IPIP_STAT_HDROPS],"packets too short for header length");
    297  1.9.4.1      yamt 	IPIPSTAT(ipips[IPIP_STAT_QFULL],"packets dropped due to queue full");
    298  1.9.4.1      yamt 	IPIPSTAT(ipips[IPIP_STAT_PDROPS],"packets blocked due to policy");
    299  1.9.4.1      yamt 	IPIPSTAT(ipips[IPIP_STAT_SPOOF],"IP spoofing attempts");
    300  1.9.4.1      yamt 	IPIPSTAT(ipips[IPIP_STAT_FAMILY],"protocol family mismatched");
    301  1.9.4.1      yamt 	IPIPSTAT(ipips[IPIP_STAT_UNSPEC],"missing tunnel-endpoint address");
    302  1.9.4.1      yamt 	IPIPSTAT(ipips[IPIP_STAT_IBYTES],"input bytes received");
    303  1.9.4.1      yamt 	IPIPSTAT(ipips[IPIP_STAT_OBYTES],"output bytes processed");
    304      1.1  jonathan #undef IPIPSTAT
    305      1.1  jonathan 
    306      1.1  jonathan 	printf("IPsec ipcomp:\n");
    307      1.1  jonathan #define	IPCOMP(x,fmt) \
    308      1.2    petrov 	if ((x) || sflag <= 1) printf("\t%"PRIu64" ipcomp " fmt "\n", x)
    309      1.1  jonathan 
    310  1.9.4.1      yamt 	IPCOMP(ipcs[IPCOMP_STAT_HDROPS],"packets too short for header length");
    311  1.9.4.1      yamt 	IPCOMP(ipcs[IPCOMP_STAT_NOPF],	"protocol family not supported");
    312  1.9.4.1      yamt 	IPCOMP(ipcs[IPCOMP_STAT_NOTDB],	"not db");
    313  1.9.4.1      yamt 	IPCOMP(ipcs[IPCOMP_STAT_BADKCR],"packets dropped by crypto returning NULL mbuf");
    314  1.9.4.1      yamt 	IPCOMP(ipcs[IPCOMP_STAT_QFULL],	"queue full");
    315  1.9.4.1      yamt         IPCOMP(ipcs[IPCOMP_STAT_NOXFORM],"no support for transform");
    316  1.9.4.1      yamt 	IPCOMP(ipcs[IPCOMP_STAT_WRAP],  "packets dropped for replay counter wrap");
    317  1.9.4.1      yamt 	IPCOMP(ipcs[IPCOMP_STAT_INPUT],	"input IPcomp packets");
    318  1.9.4.1      yamt 	IPCOMP(ipcs[IPCOMP_STAT_OUTPUT],"output IPcomp packets");
    319  1.9.4.1      yamt 	IPCOMP(ipcs[IPCOMP_STAT_INVALID],"specified an invalid TDB");
    320  1.9.4.1      yamt 	IPCOMP(ipcs[IPCOMP_STAT_TOOBIG],"packets decompressed as too big");
    321  1.9.4.1      yamt 	IPCOMP(ipcs[IPCOMP_STAT_MINLEN], "packets too short to be compressed");
    322  1.9.4.1      yamt 	IPCOMP(ipcs[IPCOMP_STAT_USELESS],"packet for which compression was useless");
    323  1.9.4.1      yamt 	IPCOMP(ipcs[IPCOMP_STAT_PDROPS],"packets blocked due to policy");
    324  1.9.4.1      yamt 	IPCOMP(ipcs[IPCOMP_STAT_CRYPTO],"failed crypto requests");
    325      1.1  jonathan 
    326      1.1  jonathan 	printf("\tIPcomp histogram:\n");
    327      1.1  jonathan 	for (i = 0; i < IPCOMP_ALG_MAX; i++)
    328  1.9.4.1      yamt 		if (ipcs[IPCOMP_STAT_HIST + i])
    329      1.2    petrov 			printf("\t\tIPcomp packets with %s: %"PRIu64"\n"
    330      1.1  jonathan 				, algname(i, ipcompalgs, N(ipcompalgs))
    331  1.9.4.1      yamt 				, ipcs[IPCOMP_STAT_HIST + i]
    332      1.1  jonathan 			);
    333  1.9.4.1      yamt 	IPCOMP(ipcs[IPCOMP_STAT_IBYTES],"input bytes");
    334  1.9.4.1      yamt 	IPCOMP(ipcs[IPCOMP_STAT_OBYTES],"output bytes");
    335      1.1  jonathan #undef IPCOMP
    336      1.1  jonathan }
    337