PERFORCE change 166830 for review
Gabor Pali
pgj at FreeBSD.org
Thu Jul 30 19:28:41 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=166830
Change 166830 by pgj at petymeg-current on 2009/07/30 19:27:55
Use libnetstat(3) in netstat(1) for pfsync statistics.
Affected files ...
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/extern.h#25 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/if.c#4 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#33 edit
Differences ...
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/extern.h#25 (text+ko) ====
@@ -85,7 +85,7 @@
void igmp_stats(const struct stat_type *);
void pim_stats(const struct stat_type *);
void carp_stats(const struct stat_type *);
-void pfsync_stats(u_long, const char *, int, int);
+void pfsync_stats(const struct stat_type *);
#ifdef IPSEC
void ipsec_stats(u_long, const char *, int, int);
void esp_stats(u_long, const char *, int, int);
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/if.c#4 (text+ko) ====
@@ -86,46 +86,31 @@
* Dump pfsync statistics structure.
*/
void
-pfsync_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
+pfsync_stats(const struct stat_type *sttp)
{
- struct pfsyncstats pfsyncstat, zerostat;
- size_t len = sizeof(struct pfsyncstats);
+ const struct pfsync_stat *s;
- if (live) {
- if (zflag)
- memset(&zerostat, 0, len);
- if (sysctlbyname("net.inet.pfsync.stats", &pfsyncstat, &len,
- zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
- if (errno != ENOENT)
- warn("sysctl: net.inet.pfsync.stats");
- return;
- }
- } else
- kread(off, &pfsyncstat, len);
-
- printf("%s:\n", name);
-
-#define p(f, m) if (pfsyncstat.f || sflag <= 1) \
- printf(m, (uintmax_t)pfsyncstat.f, plural(pfsyncstat.f))
-#define p2(f, m) if (pfsyncstat.f || sflag <= 1) \
- printf(m, (uintmax_t)pfsyncstat.f)
-
- p(pfsyncs_ipackets, "\t%ju packet%s received (IPv4)\n");
- p(pfsyncs_ipackets6, "\t%ju packet%s received (IPv6)\n");
- p(pfsyncs_badif, "\t\t%ju packet%s discarded for bad interface\n");
- p(pfsyncs_badttl, "\t\t%ju packet%s discarded for bad ttl\n");
- p(pfsyncs_hdrops, "\t\t%ju packet%s shorter than header\n");
- p(pfsyncs_badver, "\t\t%ju packet%s discarded for bad version\n");
- p(pfsyncs_badauth, "\t\t%ju packet%s discarded for bad HMAC\n");
- p(pfsyncs_badact,"\t\t%ju packet%s discarded for bad action\n");
- p(pfsyncs_badlen, "\t\t%ju packet%s discarded for short packet\n");
- p(pfsyncs_badval, "\t\t%ju state%s discarded for bad values\n");
- p(pfsyncs_stale, "\t\t%ju stale state%s\n");
- p(pfsyncs_badstate, "\t\t%ju failed state lookup/insert%s\n");
- p(pfsyncs_opackets, "\t%ju packet%s sent (IPv4)\n");
- p(pfsyncs_opackets6, "\t%ju packet%s sent (IPv6)\n");
- p2(pfsyncs_onomem, "\t\t%ju send failed due to mbuf memory error\n");
- p2(pfsyncs_oerrors, "\t\t%ju send error\n");
+ s = netstat_get_pfsyncstats(sttp);
+#define p(f, m) if (netstat_pfsyncs_get_##f(s) || sflag <= 1) \
+ printf(m, netstat_pfsyncs_get_##f(s), plural(netstat_pfsyncs_get_##f(s)))
+#define p2(f, m) if (netstat_pfsyncs_get_##f(s) || sflag <= 1) \
+ printf(m, netstat_pfsyncs_get_##f(s))
+ p(ipackets, "\t%ju packet%s received (IPv4)\n");
+ p(ipackets6, "\t%ju packet%s received (IPv6)\n");
+ p(badif, "\t\t%ju packet%s discarded for bad interface\n");
+ p(badttl, "\t\t%ju packet%s discarded for bad ttl\n");
+ p(hdrops, "\t\t%ju packet%s shorter than header\n");
+ p(badver, "\t\t%ju packet%s discarded for bad version\n");
+ p(badauth, "\t\t%ju packet%s discarded for bad HMAC\n");
+ p(badact,"\t\t%ju packet%s discarded for bad action\n");
+ p(badlen, "\t\t%ju packet%s discarded for short packet\n");
+ p(badval, "\t\t%ju state%s discarded for bad values\n");
+ p(stale, "\t\t%ju stale state%s\n");
+ p(badstate, "\t\t%ju failed state lookup/insert%s\n");
+ p(opackets, "\t%ju packet%s sent (IPv4)\n");
+ p(opackets6, "\t%ju packet%s sent (IPv6)\n");
+ p2(onomem, "\t\t%ju send failed due to mbuf memory error\n");
+ p2(oerrors, "\t\t%ju send error\n");
#undef p
#undef p2
}
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#33 (text+ko) ====
@@ -109,15 +109,13 @@
{ .n_name = "_pfkeystat" },
#define N_RTTRASH 15
{ .n_name = "_rttrash" },
-#define N_PFSYNCSTAT 16
- { .n_name = "_pfsyncstats" },
-#define N_AHSTAT 17
+#define N_AHSTAT 16
{ .n_name = "_ahstat" },
-#define N_ESPSTAT 18
+#define N_ESPSTAT 17
{ .n_name = "_espstat" },
-#define N_IPCOMPSTAT 19
+#define N_IPCOMPSTAT 18
{ .n_name = "_ipcompstat" },
-#define N_MFCTABLESIZE 20
+#define N_MFCTABLESIZE 19
{ .n_name = "_mfctablesize" },
{ .n_name = NULL },
};
@@ -167,8 +165,8 @@
NULL, NULL, "pim", 1, IPPROTO_PIM },
{ -1, 0, 1, NULL, carp_stats, stat_CARP,
NULL, NULL, "carp", 1, 0 },
- { -1, N_PFSYNCSTAT, 1, NULL, NULL, stat_MAX,
- pfsync_stats, NULL, "pfsync", 1, 0 },
+ { -1, 0, 1, NULL, pfsync_stats, stat_pfsync,
+ NULL, NULL, "pfsync", 1, 0 },
{ -1, -1, 0, NULL, NULL, stat_MAX,
NULL, NULL, NULL, 0, 0 }
};
More information about the p4-projects
mailing list