summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat
diff options
context:
space:
mode:
authorcsjp <csjp@FreeBSD.org>2009-06-19 20:31:44 +0000
committercsjp <csjp@FreeBSD.org>2009-06-19 20:31:44 +0000
commit888867acdc7211b6c6703412875edd2511f53679 (patch)
tree542c6420562d89c40cfcd91ff45fb324162ae4d1 /usr.bin/netstat
parentaed2d90f2622ec4c64bf8576250ad0f4a54dd094 (diff)
downloadFreeBSD-src-888867acdc7211b6c6703412875edd2511f53679.zip
FreeBSD-src-888867acdc7211b6c6703412875edd2511f53679.tar.gz
Implement the -z (zero counters) option for the various bpf counters.
Add necessary changes to the kernel for this (basically introduce a bpf_zero_counters() function). As well, update the man page. MFC after: 1 month Discussed with: rwatson
Diffstat (limited to 'usr.bin/netstat')
-rw-r--r--usr.bin/netstat/bpf.c9
-rw-r--r--usr.bin/netstat/netstat.11
2 files changed, 9 insertions, 1 deletions
diff --git a/usr.bin/netstat/bpf.c b/usr.bin/netstat/bpf.c
index 4455d04..2ffeacb 100644
--- a/usr.bin/netstat/bpf.c
+++ b/usr.bin/netstat/bpf.c
@@ -91,10 +91,17 @@ bpf_flags(struct xbpf_d *bd, char *flagbuf)
void
bpf_stats(char *ifname)
{
- struct xbpf_d *d, *bd;
+ struct xbpf_d *d, *bd, zerostat;
char *pname, flagbuf[12];
size_t size;
+ if (zflag) {
+ bzero(&zerostat, sizeof(zerostat));
+ if (sysctlbyname("net.bpf.stats", NULL, NULL,
+ &zerostat, sizeof(zerostat)) < 0)
+ warn("failed to zero bpf counters");
+ return;
+ }
if (sysctlbyname("net.bpf.stats", NULL, &size,
NULL, 0) < 0) {
warn("net.bpf.stats");
diff --git a/usr.bin/netstat/netstat.1 b/usr.bin/netstat/netstat.1
index f78b29f..71af7aa 100644
--- a/usr.bin/netstat/netstat.1
+++ b/usr.bin/netstat/netstat.1
@@ -198,6 +198,7 @@ The network manages a private pool of memory buffers.
.Bk -words
.Nm
.Fl B
+.Op Fl z
.Op Fl I Ar interface
.Ek
.Xc
OpenPOWER on IntegriCloud