From owner-p4-projects@FreeBSD.ORG Thu Jul 30 22:36:07 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7B5EE1065674; Thu, 30 Jul 2009 22:36:07 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 39E1D1065670 for ; Thu, 30 Jul 2009 22:36:07 +0000 (UTC) (envelope-from pgj@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 1DDFF8FC08 for ; Thu, 30 Jul 2009 22:36:07 +0000 (UTC) (envelope-from pgj@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n6UMa6T6041436 for ; Thu, 30 Jul 2009 22:36:06 GMT (envelope-from pgj@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n6UMa6C5041434 for perforce@freebsd.org; Thu, 30 Jul 2009 22:36:06 GMT (envelope-from pgj@FreeBSD.org) Date: Thu, 30 Jul 2009 22:36:06 GMT Message-Id: <200907302236.n6UMa6C5041434@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to pgj@FreeBSD.org using -f From: Gabor Pali To: Perforce Change Reviews Cc: Subject: PERFORCE change 166843 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jul 2009 22:36:08 -0000 http://perforce.freebsd.org/chv.cgi?CH=166843 Change 166843 by pgj@petymeg-current on 2009/07/30 22:35:19 - Libnetstatify ah_stats(). - Some minor nits for esp_stats() as well. Affected files ... .. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/extern.h#28 edit .. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/ipsec.c#4 edit .. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#36 edit Differences ... ==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/extern.h#28 (text+ko) ==== @@ -89,7 +89,7 @@ #ifdef IPSEC void ipsec_stats(u_long, const char *, int, int); void esp_stats(const struct stat_type *); -void ah_stats(u_long, const char *, int, int); +void ah_stats(const struct stat_type *); void ipcomp_stats(u_long, const char *, int, int); void pfkey_stats(const struct stat_type *); #endif ==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/ipsec.c#4 (text+ko) ==== @@ -277,7 +277,6 @@ static void ipsec_hist_new(const u_int32_t *hist, size_t histmax, const struct val2str *name, const char *title); -static void print_ahstats(const struct ahstat *ahstat); static void print_ipcompstats(const struct ipcompstat *ipcompstat); /* @@ -312,56 +311,52 @@ } } -static void -print_ahstats(const struct ahstat *ahstat) +void +ah_stats(const struct stat_type *sttp) { -#define p32(f, m) if (ahstat->f || sflag <= 1) \ - printf("\t%u" m, (unsigned int)ahstat->f, plural(ahstat->f)) -#define p64(f, m) if (ahstat->f || sflag <= 1) \ - printf("\t%ju" m, (uintmax_t)ahstat->f, plural(ahstat->f)) -#define hist(f, n, t) \ - ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t)); + const struct ah_stat *s; + int first, proto; - p32(ahs_hdrops, " packet%s shorter than header shows\n"); - p32(ahs_nopf, " packet%s dropped; protocol family not supported\n"); - p32(ahs_notdb, " packet%s dropped; no TDB\n"); - p32(ahs_badkcr, " packet%s dropped; bad KCR\n"); - p32(ahs_qfull, " packet%s dropped; queue full\n"); - p32(ahs_noxform, " packet%s dropped; no transform\n"); - p32(ahs_wrap, " replay counter wrap%s\n"); - p32(ahs_badauth, " packet%s dropped; bad authentication detected\n"); - p32(ahs_badauthl, " packet%s dropped; bad authentication length\n"); - p32(ahs_replay, " possible replay packet%s detected\n"); - p32(ahs_input, " packet%s in\n"); - p32(ahs_output, " packet%s out\n"); - p32(ahs_invalid, " packet%s dropped; invalid TDB\n"); - p64(ahs_ibytes, " byte%s in\n"); - p64(ahs_obytes, " byte%s out\n"); - p32(ahs_toobig, " packet%s dropped; larger than IP_MAXPACKET\n"); - p32(ahs_pdrops, " packet%s blocked due to policy\n"); - p32(ahs_crypto, " crypto processing failure%s\n"); - p32(ahs_tunnel, " tunnel sanity check failure%s\n"); - hist(ahstat->ahs_hist, ipsec_ahnames, "AH output"); - + s = netstat_get_ahstats(sttp); +#define p32(f, m) if (netstat_ahs_get_##f(s) || sflag <= 1) \ + printf("\t%u" m, netstat_ahs_get_##f(s), plural(netstat_ahs_get_##f(s))) +#define p64(f, m) if (netstat_ahs_get_##f(s) || sflag <= 1) \ + printf("\t%ju" m, netstat_ahs_get_##f(s), plural(netstat_ahs_get_##f(s))) + p32(hdrops, " packet%s shorter than header shows\n"); + p32(nopf, " packet%s dropped; protocol family not supported\n"); + p32(notdb, " packet%s dropped; no TDB\n"); + p32(badkcr, " packet%s dropped; bad KCR\n"); + p32(qfull, " packet%s dropped; queue full\n"); + p32(noxform, " packet%s dropped; no transform\n"); + p32(wrap, " replay counter wrap%s\n"); + p32(badauth, " packet%s dropped; bad authentication detected\n"); + p32(badauthl, " packet%s dropped; bad authentication length\n"); + p32(replay, " possible replay packet%s detected\n"); + p32(input, " packet%s in\n"); + p32(output, " packet%s out\n"); + p32(invalid, " packet%s dropped; invalid TDB\n"); + p64(ibytes, " byte%s in\n"); + p64(obytes, " byte%s out\n"); + p32(toobig, " packet%s dropped; larger than IP_MAXPACKET\n"); + p32(pdrops, " packet%s blocked due to policy\n"); + p32(crypto, " crypto processing failure%s\n"); + p32(tunnel, " tunnel sanity check failure%s\n"); + first = 1; + for (proto = 0; proto < NETSTAT_AH_HIST_MAX; proto++) { + if (netstat_ahs_get_hist(s, proto) == 0) + continue; + if (first != 0) { + printf("\tAH output histogram:\n"); + first = 0; + } + printf("\t\t%s: %u\n", netstat_ipsec_ahname(proto), + netstat_ahs_get_hist(s, proto)); + } #undef p32 #undef p64 -#undef hist } void -ah_stats(u_long off, const char *name, int family __unused, int proto __unused) -{ - struct ahstat ahstat; - - if (off == 0) - return; - printf ("%s:\n", name); - kread(off, (char *)&ahstat, sizeof(ahstat)); - - print_ahstats(&ahstat); -} - -void esp_stats(const struct stat_type *sttp) { const struct esp_stat *s; @@ -372,8 +367,6 @@ printf("\t%u" m, netstat_esps_get_##f(s), plural(netstat_esps_get_##f(s))) #define p64(f, m) if (netstat_esps_get_##f(s) || sflag <= 1) \ printf("\t%ju" m, netstat_esps_get_##f(s), plural(netstat_esps_get_##f(s))) -#define hist(f, n, t) \ - ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t)); p32(hdrops, " packet%s shorter than header shows\n"); p32(nopf, " packet%s dropped; protocol family not supported\n"); p32(notdb, " packet%s dropped; no TDB\n"); @@ -407,7 +400,6 @@ } #undef p32 #undef p64 -#undef hist } static void ==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#36 (text+ko) ==== @@ -107,11 +107,9 @@ { .n_name = "_mif6table" }, #define N_RTTRASH 14 { .n_name = "_rttrash" }, -#define N_AHSTAT 15 - { .n_name = "_ahstat" }, -#define N_IPCOMPSTAT 16 +#define N_IPCOMPSTAT 15 { .n_name = "_ipcompstat" }, -#define N_MFCTABLESIZE 17 +#define N_MFCTABLESIZE 16 { .n_name = "_mfctablesize" }, { .n_name = NULL }, }; @@ -150,8 +148,8 @@ #ifdef IPSEC { -1, N_IPSECSTAT, 1, NULL, NULL, stat_MAX, /* keep as compat */ ipsec_stats, NULL, "ipsec", 0, 0}, - { -1, N_AHSTAT, 1, NULL, NULL, stat_MAX, - ah_stats, NULL, "ah", 0, 0}, + { -1, 0, 1, NULL, ah_stats, stat_AH, + NULL, NULL, "ah", 0, 0}, { -1, 0, 1, NULL, esp_stats, stat_ESP, NULL, NULL, "esp", 0, 0}, { -1, N_IPCOMPSTAT, 1, NULL, NULL, stat_MAX,