PERFORCE change 166846 for review
Gabor Pali
pgj at FreeBSD.org
Thu Jul 30 23:03:38 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=166846
Change 166846 by pgj at petymeg-current on 2009/07/30 23:02:52
Function ipcomp_stats() in netstat(1) now uses libnetstat(3).
Affected files ...
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/extern.h#29 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/ipsec.c#5 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#37 edit
Differences ...
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/extern.h#29 (text+ko) ====
@@ -90,7 +90,7 @@
void ipsec_stats(u_long, const char *, int, int);
void esp_stats(const struct stat_type *);
void ah_stats(const struct stat_type *);
-void ipcomp_stats(u_long, const char *, int, int);
+void ipcomp_stats(const struct stat_type *);
void pfkey_stats(const struct stat_type *);
#endif
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/ipsec.c#5 (text+ko) ====
@@ -274,43 +274,6 @@
print_ipsecstats(&ipsecstat);
}
-
-static void ipsec_hist_new(const u_int32_t *hist, size_t histmax,
- const struct val2str *name, const char *title);
-static void print_ipcompstats(const struct ipcompstat *ipcompstat);
-
-/*
- * Dump IPSEC statistics structure.
- */
-static void
-ipsec_hist_new(const u_int32_t *hist, size_t histmax,
- const struct val2str *name, const char *title)
-{
- int first;
- size_t proto;
- const struct val2str *p;
-
- first = 1;
- for (proto = 0; proto < histmax; proto++) {
- if (hist[proto] <= 0)
- continue;
- if (first) {
- printf("\t%s histogram:\n", title);
- first = 0;
- }
- for (p = name; p && p->str; p++) {
- if (p->val == (int)proto)
- break;
- }
- if (p && p->str) {
- printf("\t\t%s: %u\n", p->str, hist[proto]);
- } else {
- printf("\t\t#%lu: %u\n", (unsigned long)proto,
- hist[proto]);
- }
- }
-}
-
void
ah_stats(const struct stat_type *sttp)
{
@@ -402,48 +365,43 @@
#undef p64
}
-static void
-print_ipcompstats(const struct ipcompstat *ipcompstat)
+void
+ipcomp_stats(const struct stat_type *sttp)
{
-#define p32(f, m) if (ipcompstat->f || sflag <= 1) \
- printf("\t%u" m, (unsigned int)ipcompstat->f, plural(ipcompstat->f))
-#define p64(f, m) if (ipcompstat->f || sflag <= 1) \
- printf("\t%ju" m, (uintmax_t)ipcompstat->f, plural(ipcompstat->f))
-#define hist(f, n, t) \
- ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t));
+ const struct ipcomp_stat *s;
+ int first, proto;
- p32(ipcomps_hdrops, " packet%s shorter than header shows\n");
- p32(ipcomps_nopf, " packet%s dropped; protocol family not supported\n");
- p32(ipcomps_notdb, " packet%s dropped; no TDB\n");
- p32(ipcomps_badkcr, " packet%s dropped; bad KCR\n");
- p32(ipcomps_qfull, " packet%s dropped; queue full\n");
- p32(ipcomps_noxform, " packet%s dropped; no transform\n");
- p32(ipcomps_wrap, " replay counter wrap%s\n");
- p32(ipcomps_input, " packet%s in\n");
- p32(ipcomps_output, " packet%s out\n");
- p32(ipcomps_invalid, " packet%s dropped; invalid TDB\n");
- p64(ipcomps_ibytes, " byte%s in\n");
- p64(ipcomps_obytes, " byte%s out\n");
- p32(ipcomps_toobig, " packet%s dropped; larger than IP_MAXPACKET\n");
- p32(ipcomps_pdrops, " packet%s blocked due to policy\n");
- p32(ipcomps_crypto, " crypto processing failure%s\n");
- hist(ipcompstat->ipcomps_hist, ipsec_compnames, "COMP output");
-
+ s = netstat_get_ipcompstats(sttp);
+#define p32(f, m) if (netstat_ipcomps_get_##f(s) || sflag <= 1) \
+ printf("\t%u" m, netstat_ipcomps_get_##f(s), plural(netstat_ipcomps_get_##f(s)))
+#define p64(f, m) if (netstat_ipcomps_get_##f(s) || sflag <= 1) \
+ printf("\t%ju" m, netstat_ipcomps_get_##f(s), plural(netstat_ipcomps_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(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");
+ first = 1;
+ for (proto = 0; proto < NETSTAT_IPCOMP_HIST_MAX; proto++) {
+ if (netstat_ipcomps_get_hist(s, proto) == 0)
+ continue;
+ if (first != 0) {
+ printf("\tCOMP output histogram:\n");
+ first = 0;
+ }
+ printf("\t\t%s: %u\n", netstat_ipsec_ipcompname(proto),
+ netstat_ipcomps_get_hist(s, proto));
+ }
#undef p32
#undef p64
-#undef hist
-}
-
-void
-ipcomp_stats(u_long off, const char *name, int family __unused,
- int proto __unused)
-{
- struct ipcompstat ipcompstat;
-
- if (off == 0)
- return;
- printf ("%s:\n", name);
- kread(off, (char *)&ipcompstat, sizeof(ipcompstat));
-
- print_ipcompstats(&ipcompstat);
}
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#37 (text+ko) ====
@@ -107,9 +107,7 @@
{ .n_name = "_mif6table" },
#define N_RTTRASH 14
{ .n_name = "_rttrash" },
-#define N_IPCOMPSTAT 15
- { .n_name = "_ipcompstat" },
-#define N_MFCTABLESIZE 16
+#define N_MFCTABLESIZE 15
{ .n_name = "_mfctablesize" },
{ .n_name = NULL },
};
@@ -152,8 +150,8 @@
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,
- ipcomp_stats, NULL, "ipcomp", 0, 0},
+ { -1, 0, 1, NULL, ipcomp_stats, stat_IPcomp,
+ NULL, NULL, "ipcomp", 0, 0},
#endif
{ 0, 0, 1, NULL, pim_stats, stat_PIM,
NULL, NULL, "pim", 1, IPPROTO_PIM },
More information about the p4-projects
mailing list