PERFORCE change 166808 for review

Gabor Pali pgj at FreeBSD.org
Thu Jul 30 17:28:27 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=166808

Change 166808 by pgj at petymeg-current on 2009/07/30 17:27:57

	Modify netstat(1) to use libnetstat(3) for retrieving statistics
	on RIP6.

Affected files ...

.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/extern.h#22 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/inet6.c#5 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#30 edit

Differences ...

==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/extern.h#22 (text+ko) ====

@@ -99,7 +99,7 @@
 void	icmp6_stats(const struct stat_type *);
 void	icmp6_ifstats(char *);
 void	pim6_stats(const struct stat_type *);
-void	rip6_stats(u_long, const char *, int, int);
+void	rip6_stats(const struct stat_type *);
 void	mroute6pr(u_long, u_long);
 void	mrt6_stats(u_long);
 

==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/inet6.c#5 (text+ko) ====

@@ -742,44 +742,25 @@
  * Dump raw ip6 statistics structure.
  */
 void
-rip6_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
+rip6_stats(const struct stat_type *sttp)
 {
-	struct rip6stat rip6stat;
-	u_quad_t delivered;
-	size_t len;
+	const struct rip6_stat *s;
 
-	len = sizeof(rip6stat);
-	if (live) {
-		if (sysctlbyname("net.inet6.ip6.rip6stats", &rip6stat, &len,
-		    NULL, 0) < 0) {
-			if (errno != ENOENT)
-				warn("sysctl: net.inet6.ip6.rip6stats");
-			return;
-		}
-	} else
-		kread(off, &rip6stat, len);
-
-	printf("%s:\n", name);
-
-#define	p(f, m) if (rip6stat.f || sflag <= 1) \
-    printf(m, (uintmax_t)rip6stat.f, plural(rip6stat.f))
-	p(rip6s_ipackets, "\t%ju message%s received\n");
-	p(rip6s_isum, "\t%ju checksum calculation%s on inbound\n");
-	p(rip6s_badsum, "\t%ju message%s with bad checksum\n");
-	p(rip6s_nosock, "\t%ju message%s dropped due to no socket\n");
-	p(rip6s_nosockmcast,
-	    "\t%ju multicast message%s dropped due to no socket\n");
-	p(rip6s_fullsock,
-	    "\t%ju message%s dropped due to full socket buffers\n");
-	delivered = rip6stat.rip6s_ipackets -
-		    rip6stat.rip6s_badsum -
-		    rip6stat.rip6s_nosock -
-		    rip6stat.rip6s_nosockmcast -
-		    rip6stat.rip6s_fullsock;
-	if (delivered || sflag <= 1)
-		printf("\t%ju delivered\n", (uintmax_t)delivered);
-	p(rip6s_opackets, "\t%ju datagram%s output\n");
+	s = netstat_get_rip6stats(sttp);
+#define	p(f, m) if (netstat_rip6s_get_##f(s) || sflag <= 1) \
+    printf(m, netstat_rip6s_get_##f(s), plural(netstat_rip6s_get_##f(s)))
+#define	p_5(f, m) if (netstat_rip6s_get_##f(s) || sflag <= 1) \
+    printf(m, netstat_rip6s_get_##f(s))
+	p(ipackets, "\t%ju message%s received\n");
+	p(isum, "\t%ju checksum calculation%s on inbound\n");
+	p(badsum, "\t%ju message%s with bad checksum\n");
+	p(nosock, "\t%ju message%s dropped due to no socket\n");
+	p(nosockmcast, "\t%ju multicast message%s dropped due to no socket\n");
+	p(fullsock, "\t%ju message%s dropped due to full socket buffers\n");
+	p_5(delivered,"\t%ju delivered\n");
+	p(opackets, "\t%ju datagram%s output\n");
 #undef p
+#undef p_5
 }
 
 /*

==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#30 (text+ko) ====

@@ -121,9 +121,7 @@
 	{ .n_name = "_espstat" },
 #define	N_IPCOMPSTAT	21
 	{ .n_name = "_ipcompstat" },
-#define	N_RIP6STAT	22
-	{ .n_name = "_rip6stat" },
-#define	N_MFCTABLESIZE	23
+#define	N_MFCTABLESIZE	22
 	{ .n_name = "_mfctablesize" },
 	{ .n_name = NULL },
 };
@@ -197,8 +195,8 @@
 	{ -1,		0,		1,	NULL,	pim6_stats, stat_PIM6,
 	  NULL,		NULL,		"pim6",	1,	0 },
 #endif
-	{ -1,		N_RIP6STAT,	1,	NULL,	NULL, stat_MAX,
-	  rip6_stats,	NULL,		"rip6",	1,	0 },
+	{ -1,		0,		1,	NULL,	rip6_stats, stat_RIP6,
+	  NULL,		NULL,		"rip6",	1,	0 },
 	{ -1,		-1,		0,	NULL,	NULL, stat_MAX,
 	  NULL,		NULL,		NULL,	0,	0 }
 };


More information about the p4-projects mailing list