svn commit: r239936 - in stable/9: sys/netinet6 usr.bin/netstat

Maxim Konovalov maxim at FreeBSD.org
Fri Aug 31 06:38:44 UTC 2012


Author: maxim
Date: Fri Aug 31 06:38:43 2012
New Revision: 239936
URL: http://svn.freebsd.org/changeset/base/239936

Log:
  MFC r228700: convert IPv6 read-only stats sysctls to the read-write ones.
  Teach netstat(1) -z to reset these sysctls.

Modified:
  stable/9/sys/netinet6/in6_proto.c
  stable/9/sys/netinet6/ip6_mroute.c
  stable/9/usr.bin/netstat/inet6.c
Directory Properties:
  stable/9/usr.bin/netstat/   (props changed)

Modified: stable/9/sys/netinet6/in6_proto.c
==============================================================================
--- stable/9/sys/netinet6/in6_proto.c	Fri Aug 31 06:34:46 2012	(r239935)
+++ stable/9/sys/netinet6/in6_proto.c	Fri Aug 31 06:38:43 2012	(r239936)
@@ -520,7 +520,7 @@ SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_
 	&VNET_NAME(ip6_sendredirects), 0, "");
 SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_DEFHLIM, hlim, CTLFLAG_RW,
 	&VNET_NAME(ip6_defhlim), 0, "");
-SYSCTL_VNET_STRUCT(_net_inet6_ip6, IPV6CTL_STATS, stats, CTLFLAG_RD,
+SYSCTL_VNET_STRUCT(_net_inet6_ip6, IPV6CTL_STATS, stats, CTLFLAG_RW,
 	&VNET_NAME(ip6stat), ip6stat, "");
 SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_MAXFRAGPACKETS, maxfragpackets,
 	CTLFLAG_RW, &VNET_NAME(ip6_maxfragpackets), 0, "");
@@ -573,7 +573,7 @@ SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_
 	CTLFLAG_RW, &VNET_NAME(ip6_auto_linklocal), 0,
 	"Default value of per-interface flag for automatically adding an IPv6"
 	" link-local address to interfaces when attached");
-SYSCTL_VNET_STRUCT(_net_inet6_ip6, IPV6CTL_RIP6STATS, rip6stats, CTLFLAG_RD,
+SYSCTL_VNET_STRUCT(_net_inet6_ip6, IPV6CTL_RIP6STATS, rip6stats, CTLFLAG_RW,
 	&VNET_NAME(rip6stat), rip6stat, "");
 SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_PREFER_TEMPADDR, prefer_tempaddr,
 	CTLFLAG_RW, &VNET_NAME(ip6_prefer_tempaddr), 0, "");
@@ -603,7 +603,7 @@ SYSCTL_VNET_INT(_net_inet6_icmp6, ICMPV6
 	CTLFLAG_RW, &VNET_NAME(icmp6_rediraccept), 0, "");
 SYSCTL_VNET_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRTIMEOUT, redirtimeout,
 	CTLFLAG_RW, &VNET_NAME(icmp6_redirtimeout), 0, "");
-SYSCTL_VNET_STRUCT(_net_inet6_icmp6, ICMPV6CTL_STATS, stats, CTLFLAG_RD,
+SYSCTL_VNET_STRUCT(_net_inet6_icmp6, ICMPV6CTL_STATS, stats, CTLFLAG_RW,
 	&VNET_NAME(icmp6stat), icmp6stat, "");
 SYSCTL_VNET_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_PRUNE, nd6_prune, CTLFLAG_RW,
 	&VNET_NAME(nd6_prune), 0, "");

Modified: stable/9/sys/netinet6/ip6_mroute.c
==============================================================================
--- stable/9/sys/netinet6/ip6_mroute.c	Fri Aug 31 06:34:46 2012	(r239935)
+++ stable/9/sys/netinet6/ip6_mroute.c	Fri Aug 31 06:38:43 2012	(r239936)
@@ -250,7 +250,7 @@ static mifi_t nummifs = 0;
 static mifi_t reg_mif_num = (mifi_t)-1;
 
 static struct pim6stat pim6stat;
-SYSCTL_STRUCT(_net_inet6_pim, PIM6CTL_STATS, stats, CTLFLAG_RD,
+SYSCTL_STRUCT(_net_inet6_pim, PIM6CTL_STATS, stats, CTLFLAG_RW,
     &pim6stat, pim6stat,
     "PIM Statistics (struct pim6stat, netinet6/pim_var.h)");
 

Modified: stable/9/usr.bin/netstat/inet6.c
==============================================================================
--- stable/9/usr.bin/netstat/inet6.c	Fri Aug 31 06:34:46 2012	(r239935)
+++ stable/9/usr.bin/netstat/inet6.c	Fri Aug 31 06:38:43 2012	(r239936)
@@ -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,
 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;


More information about the svn-src-stable mailing list