PERFORCE change 166662 for review

Gabor Pali pgj at FreeBSD.org
Mon Jul 27 22:06:56 UTC 2009


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

Change 166662 by pgj at petymeg-current on 2009/07/27 22:06:00

	Move pim_stats() into libnetstat(3) in netstat(1).

Affected files ...

.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/extern.h#16 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/inet.c#31 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#24 edit

Differences ...

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

@@ -83,7 +83,7 @@
 void	ip_stats(const struct stat_type *);
 void	icmp_stats(const struct stat_type *);
 void	igmp_stats(u_long, const char *, int, int);
-void	pim_stats(u_long, const char *, int, int);
+void	pim_stats(const struct stat_type *);
 void	carp_stats(const struct stat_type *);
 void	pfsync_stats(u_long, const char *, int, int);
 #ifdef IPSEC

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

@@ -678,45 +678,27 @@
  * Dump PIM statistics structure.
  */
 void
-pim_stats(u_long off __unused, const char *name, int af1 __unused,
-    int proto __unused)
+pim_stats(const struct stat_type *sttp)
 {
-	struct pimstat pimstat, zerostat;
-	size_t len = sizeof pimstat;
+	const struct pim_stat *s;
 
-	if (live) {
-		if (zflag)
-			memset(&zerostat, 0, len);
-		if (sysctlbyname("net.inet.pim.stats", &pimstat, &len,
-		    zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
-			if (errno != ENOENT)
-				warn("sysctl: net.inet.pim.stats");
-			return;
-		}
-	} else {
-		if (off == 0)
-			return;
-		kread(off, &pimstat, len);
-	}
-
-	printf("%s:\n", name);
-
-#define	p(f, m) if (pimstat.f || sflag <= 1) \
-    printf(m, (uintmax_t)pimstat.f, plural(pimstat.f))
-#define	py(f, m) if (pimstat.f || sflag <= 1) \
-    printf(m, (uintmax_t)pimstat.f, pimstat.f != 1 ? "ies" : "y")
-	p(pims_rcv_total_msgs, "\t%ju message%s received\n");
-	p(pims_rcv_total_bytes, "\t%ju byte%s received\n");
-	p(pims_rcv_tooshort, "\t%ju message%s received with too few bytes\n");
-        p(pims_rcv_badsum, "\t%ju message%s received with bad checksum\n");
-	p(pims_rcv_badversion, "\t%ju message%s received with bad version\n");
-	p(pims_rcv_registers_msgs, "\t%ju data register message%s received\n");
-	p(pims_rcv_registers_bytes, "\t%ju data register byte%s received\n");
-	p(pims_rcv_registers_wrongiif,
+	s = netstat_get_pimstats(sttp);
+#define	p(f, m) if (netstat_pims_get_##f(s) || sflag <= 1) \
+    printf(m, netstat_pims_get_##f(s), plural(netstat_pims_get_##f(s)))
+#define	py(f, m) if (netstat_pims_get_##f(s) || sflag <= 1) \
+    printf(m, netstat_pims_get_##f(s), netstat_pims_get_##f(s) != 1 ? "ies" : "y")
+	p(rcv_total_msgs, "\t%ju message%s received\n");
+	p(rcv_total_bytes, "\t%ju byte%s received\n");
+	p(rcv_tooshort, "\t%ju message%s received with too few bytes\n");
+        p(rcv_badsum, "\t%ju message%s received with bad checksum\n");
+	p(rcv_badversion, "\t%ju message%s received with bad version\n");
+	p(rcv_registers_msgs, "\t%ju data register message%s received\n");
+	p(rcv_registers_bytes, "\t%ju data register byte%s received\n");
+	p(rcv_registers_wrongiif,
 	    "\t%ju data register message%s received on wrong iif\n");
-	p(pims_rcv_badregisters, "\t%ju bad register%s received\n");
-	p(pims_snd_registers_msgs, "\t%ju data register message%s sent\n");
-	p(pims_snd_registers_bytes, "\t%ju data register byte%s sent\n");
+	p(rcv_badregisters, "\t%ju bad register%s received\n");
+	p(snd_registers_msgs, "\t%ju data register message%s sent\n");
+	p(snd_registers_bytes, "\t%ju data register byte%s sent\n");
 #undef p
 #undef py
 }

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

@@ -129,13 +129,11 @@
 	{ .n_name = "_ipcompstat" },
 #define	N_IGMPSTAT	25
 	{ .n_name = "_igmpstat" },
-#define	N_PIMSTAT	26
-	{ .n_name = "_pimstat" },
-#define	N_RIP6STAT	27
+#define	N_RIP6STAT	26
 	{ .n_name = "_rip6stat" },
-#define	N_SCTPSTAT	28
+#define	N_SCTPSTAT	27
 	{ .n_name = "_sctpstat" },
-#define	N_MFCTABLESIZE	29
+#define	N_MFCTABLESIZE	28
 	{ .n_name = "_mfctablesize" },
 	{ .n_name = NULL },
 };
@@ -181,8 +179,8 @@
 	{ -1,		N_IPCOMPSTAT,	1,	NULL,	NULL, stat_MAX,
 	  ipcomp_stats,	NULL,		"ipcomp", 0,	0},
 #endif
-	{ 0,		N_PIMSTAT,	1,	NULL,	NULL, stat_MAX,
-	  pim_stats,	NULL,		"pim",	1,	IPPROTO_PIM },
+	{ 0,		0,		1,	NULL,	pim_stats, stat_PIM,
+	  NULL,		NULL,		"pim",	1,	IPPROTO_PIM },
 	{ -1,		0,		1,	NULL,	carp_stats, stat_CARP,
 	  NULL,		NULL,		"carp",	1,	0 },
 	{ -1,		N_PFSYNCSTAT,	1,	NULL,	NULL, stat_MAX,


More information about the p4-projects mailing list