Page MenuHomeFreeBSD

D43107.diff
No OneTemporary

D43107.diff

diff --git a/sys/netpfil/pf/pflow.c b/sys/netpfil/pf/pflow.c
--- a/sys/netpfil/pf/pflow.c
+++ b/sys/netpfil/pf/pflow.c
@@ -128,13 +128,19 @@
#define V_pflowif_list VNET(pflowif_list)
VNET_DEFINE(struct mtx, pflowif_list_mtx);
#define V_pflowif_list_mtx VNET(pflowif_list_mtx)
-VNET_DEFINE(struct pflowstats, pflowstats);
-#define V_pflowstats VNET(pflowstats)
+VNET_DEFINE(struct pflowstats, pflowstat);
+#define V_pflowstats VNET(pflowstat)
#define PFLOW_LOCK(_sc) mtx_lock(&(_sc)->sc_lock)
#define PFLOW_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_lock)
#define PFLOW_ASSERT(_sc) mtx_assert(&(_sc)->sc_lock, MA_OWNED)
+SYSCTL_NODE(_net, OID_AUTO, pflow, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
+ "PFLOW");
+SYSCTL_STRUCT(_net_pflow, OID_AUTO, stats, CTLFLAG_VNET | CTLFLAG_RW,
+ &VNET_NAME(pflowstat), pflowstats,
+ "PFLOW statistics (struct pflowstats, net/if_pflow.h)");
+
static void
vnet_pflowattach(void)
{
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c
--- a/usr.bin/netstat/if.c
+++ b/usr.bin/netstat/if.c
@@ -45,6 +45,7 @@
#include <arpa/inet.h>
#ifdef PF
#include <net/pfvar.h>
+#include <net/pflow.h>
#include <net/if_pfsync.h>
#endif
@@ -181,6 +182,31 @@
#undef p
xo_close_container(name);
}
+
+void
+pflow_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
+{
+ struct pflowstats pflowstat;
+
+ if (fetch_stats("net.pflow.stats", off, &pflowstat,
+ sizeof(pflowstat), kread) != 0)
+ return;
+
+ xo_emit("{T:/%s}:\n", name);
+ xo_open_container(name);
+
+#define p(f, m) if (pflowstat.f || sflag <= 1) \
+ xo_emit(m, (uintmax_t)pflowstat.f, plural(pflowstat.f))
+
+ p(pflow_flows, "\t{:flows/%ju} {N:/flow%s sent}\n");
+ p(pflow_packets, "\t{:packets/%ju} {N:/packet%s sent}\n");
+ p(pflow_onomem, "\t{:nomem/%ju} "
+ "{N:/send failed due to mbuf memory error}\n");
+ p(pflow_oerrors, "\t{:send-error/%ju} {N:/send error}\n");
+#undef p
+
+ xo_close_container(name);
+}
#endif /* PF */
/*
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c
--- a/usr.bin/netstat/main.c
+++ b/usr.bin/netstat/main.c
@@ -116,6 +116,8 @@
#ifdef PF
{ -1, N_PFSYNCSTATS, 1, NULL,
pfsync_stats, NULL, "pfsync", 1, 0 },
+ { -1, N_PFLOWSTATS, 1, NULL,
+ pflow_stats, NULL, "pflow", 1, 0 },
#endif
{ -1, N_ARPSTAT, 1, NULL,
arp_stats, NULL, "arp", 1, 0 },
diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h
--- a/usr.bin/netstat/netstat.h
+++ b/usr.bin/netstat/netstat.h
@@ -96,6 +96,7 @@
void pim_stats(u_long, const char *, int, int);
void carp_stats(u_long, const char *, int, int);
void pfsync_stats(u_long, const char *, int, int);
+void pflow_stats(u_long, const char *, int, int);
#ifdef IPSEC
void ipsec_stats(u_long, const char *, int, int);
void esp_stats(u_long, const char *, int, int);
diff --git a/usr.bin/netstat/nlist_symbols b/usr.bin/netstat/nlist_symbols
--- a/usr.bin/netstat/nlist_symbols
+++ b/usr.bin/netstat/nlist_symbols
@@ -31,6 +31,7 @@
all _nws_count
all _pfkeystat
all _pfsyncstats
+all _pflowstats
all _pim6stat
all _pimstat
all _rip6stat

File Metadata

Mime Type
text/plain
Expires
Sat, Jan 11, 6:18 PM (20 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15756512
Default Alt Text
D43107.diff (3 KB)

Event Timeline