aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorChristian S.J. Peron <csjp@FreeBSD.org>2009-06-19 20:31:44 +0000
committerChristian S.J. Peron <csjp@FreeBSD.org>2009-06-19 20:31:44 +0000
commit0e37f3e196c6cb887be0de58c315aa1358caa363 (patch)
tree542c6420562d89c40cfcd91ff45fb324162ae4d1 /usr.bin
parent80b807fef2ba25a13619abc65eb8b47b7ea352d1 (diff)
downloadsrc-0e37f3e196c6cb887be0de58c315aa1358caa363.tar.gz
src-0e37f3e196c6cb887be0de58c315aa1358caa363.zip
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
Notes
Notes: svn path=/head/; revision=194512
Diffstat (limited to 'usr.bin')
-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 4455d04d618f..2ffeacbc7dea 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 f78b29f06a1b..71af7aa53fa3 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