summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authormaxim <maxim@FreeBSD.org>2011-12-19 05:50:34 +0000
committermaxim <maxim@FreeBSD.org>2011-12-19 05:50:34 +0000
commit330e98b5dec00a424988db6336dc195bb84dab04 (patch)
tree6ef199c9cdb0ed3626e65f1c649eef214229d2ca /usr.bin
parent473a67378d84b8efbe9e04f591c17c7f1f7fc89b (diff)
downloadFreeBSD-src-330e98b5dec00a424988db6336dc195bb84dab04.zip
FreeBSD-src-330e98b5dec00a424988db6336dc195bb84dab04.tar.gz
o Convert IPv6 read-only stats sysctls to the read-write ones.
o Teach netstat(1) -z to reset these stats sysctls. PR: bin/153206 Reviewed by: glebuis Sponsored by: NGINX, Inc. MFC after: 1 month
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/netstat/inet6.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/usr.bin/netstat/inet6.c b/usr.bin/netstat/inet6.c
index 411b0ca..03fef6e 100644
--- a/usr.bin/netstat/inet6.c
+++ b/usr.bin/netstat/inet6.c
@@ -360,15 +360,17 @@ static char *srcrule_str[] = {
void
ip6_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
{
- struct ip6stat ip6stat;
+ struct ip6stat ip6stat, zerostat;
int first, i;
size_t len;
len = sizeof ip6stat;
if (live) {
memset(&ip6stat, 0, len);
- if (sysctlbyname("net.inet6.ip6.stats", &ip6stat, &len, NULL,
- 0) < 0) {
+ if (zflag)
+ memset(&zerostat, 0, len);
+ if (sysctlbyname("net.inet6.ip6.stats", &ip6stat, &len,
+ zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
if (errno != ENOENT)
warn("sysctl: net.inet6.ip6.stats");
return;
@@ -840,15 +842,17 @@ static const char *icmp6names[] = {
void
icmp6_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
{
- struct icmp6stat icmp6stat;
+ struct icmp6stat icmp6stat, zerostat;
int i, first;
size_t len;
len = sizeof icmp6stat;
if (live) {
memset(&icmp6stat, 0, len);
+ if (zflag)
+ memset(&zerostat, 0, len);
if (sysctlbyname("net.inet6.icmp6.stats", &icmp6stat, &len,
- NULL, 0) < 0) {
+ zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
if (errno != ENOENT)
warn("sysctl: net.inet6.icmp6.stats");
return;
@@ -1033,14 +1037,16 @@ pim6_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
void
rip6_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
{
- struct rip6stat rip6stat;
+ struct rip6stat rip6stat, zerostat;
u_quad_t delivered;
size_t len;
len = sizeof(rip6stat);
if (live) {
+ if (zflag)
+ memset(&zerostat, 0, len);
if (sysctlbyname("net.inet6.ip6.rip6stats", &rip6stat, &len,
- NULL, 0) < 0) {
+ zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
if (errno != ENOENT)
warn("sysctl: net.inet6.ip6.rip6stats");
return;
OpenPOWER on IntegriCloud