diff options
author | Christian S.J. Peron <csjp@FreeBSD.org> | 2009-06-19 20:31:44 +0000 |
---|---|---|
committer | Christian S.J. Peron <csjp@FreeBSD.org> | 2009-06-19 20:31:44 +0000 |
commit | 0e37f3e196c6cb887be0de58c315aa1358caa363 (patch) | |
tree | 542c6420562d89c40cfcd91ff45fb324162ae4d1 /usr.bin | |
parent | 80b807fef2ba25a13619abc65eb8b47b7ea352d1 (diff) | |
download | src-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.c | 9 | ||||
-rw-r--r-- | usr.bin/netstat/netstat.1 | 1 |
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 |