Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Jan 2016 19:52:18 +0000 (UTC)
From:      "George V. Neville-Neil" <gnn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r293344 - stable/10/usr.bin/netstat
Message-ID:  <201601071952.u07JqIGi021303@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gnn
Date: Thu Jan  7 19:52:17 2016
New Revision: 293344
URL: https://svnweb.freebsd.org/changeset/base/293344

Log:
  MFC: 292394
  
  Switch the IPsec related statistics to using the built in sysctl
  variable set rather than reading from kernel memory.
  This also makes the -z (zero) flag work correctly
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  stable/10/usr.bin/netstat/ipsec.c
  stable/10/usr.bin/netstat/main.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.bin/netstat/ipsec.c
==============================================================================
--- stable/10/usr.bin/netstat/ipsec.c	Thu Jan  7 19:47:26 2016	(r293343)
+++ stable/10/usr.bin/netstat/ipsec.c	Thu Jan  7 19:52:17 2016	(r293344)
@@ -199,10 +199,17 @@ ipsec_stats(u_long off, const char *name
 {
 	struct ipsecstat ipsecstat;
 
-	if (off == 0)
-		return;
+	if (strcmp(name, "ipsec6") == 0) {
+		if (fetch_stats("net.inet6.ipsec6.ipsecstats", off,&ipsecstat,
+				sizeof(ipsecstat), kread_counters) != 0)
+			return;
+	} else {
+		if (fetch_stats("net.inet.ipsec.ipsecstats", off, &ipsecstat,
+				sizeof(ipsecstat), kread_counters) != 0)
+			return;
+	}
+
 	printf ("%s:\n", name);
-	kread_counters(off, (char *)&ipsecstat, sizeof(ipsecstat));
 
 	print_ipsecstats(&ipsecstat);
 }
@@ -285,10 +292,10 @@ ah_stats(u_long off, const char *name, i
 {
 	struct ahstat ahstat;
 
-	if (off == 0)
+	if (fetch_stats("net.inet.ah.stats", off, &ahstat,
+	    sizeof(ahstat), kread_counters) != 0)
 		return;
 	printf ("%s:\n", name);
-	kread_counters(off, (char *)&ahstat, sizeof(ahstat));
 
 	print_ahstats(&ahstat);
 }
@@ -332,10 +339,10 @@ esp_stats(u_long off, const char *name, 
 {
 	struct espstat espstat;
 
-	if (off == 0)
+	if (fetch_stats("net.inet.esp.stats", off, &espstat,
+	    sizeof(espstat), kread_counters) != 0)
 		return;
 	printf ("%s:\n", name);
-	kread_counters(off, (char *)&espstat, sizeof(espstat));
 
 	print_espstats(&espstat);
 }
@@ -377,10 +384,10 @@ ipcomp_stats(u_long off, const char *nam
 {
 	struct ipcompstat ipcompstat;
 
-	if (off == 0)
+	if (fetch_stats("net.inet.ipcomp.stats", off, &ipcompstat,
+	    sizeof(ipcompstat), kread_counters) != 0)
 		return;
 	printf ("%s:\n", name);
-	kread_counters(off, (char *)&ipcompstat, sizeof(ipcompstat));
 
 	print_ipcompstats(&ipcompstat);
 }

Modified: stable/10/usr.bin/netstat/main.c
==============================================================================
--- stable/10/usr.bin/netstat/main.c	Thu Jan  7 19:47:26 2016	(r293343)
+++ stable/10/usr.bin/netstat/main.c	Thu Jan  7 19:52:17 2016	(r293344)
@@ -203,13 +203,13 @@ struct protox {
 	  igmp_stats,	NULL,		"igmp",	1,	IPPROTO_IGMP },
 #ifdef IPSEC
 	{ -1,		N_IPSECSTAT,	1,	NULL,	/* keep as compat */
-	  ipsec_stats,	NULL,		"ipsec", 0,	0},
+	  ipsec_stats,	NULL,		"ipsec", 1,	0},
 	{ -1,		N_AHSTAT,	1,	NULL,
-	  ah_stats,	NULL,		"ah",	0,	0},
+	  ah_stats,	NULL,		"ah",	1,	0},
 	{ -1,		N_ESPSTAT,	1,	NULL,
-	  esp_stats,	NULL,		"esp",	0,	0},
+	  esp_stats,	NULL,		"esp",	1,	0},
 	{ -1,		N_IPCOMPSTAT,	1,	NULL,
-	  ipcomp_stats,	NULL,		"ipcomp", 0,	0},
+	  ipcomp_stats,	NULL,		"ipcomp", 1,	0},
 #endif
 	{ N_RIPCBINFO,	N_PIMSTAT,	1,	protopr,
 	  pim_stats,	NULL,		"pim",	1,	IPPROTO_PIM },
@@ -241,7 +241,7 @@ struct protox ip6protox[] = {
 #endif
 #ifdef IPSEC
 	{ -1,		N_IPSEC6STAT,	1,	NULL,
-	  ipsec_stats,	NULL,		"ipsec6", 0,	0 },
+	  ipsec_stats,	NULL,		"ipsec6", 1,	0 },
 #endif
 #ifdef notyet
 	{ -1,		N_PIM6STAT,	1,	NULL,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601071952.u07JqIGi021303>