PERFORCE change 166881 for review

Gabor Pali pgj at FreeBSD.org
Fri Jul 31 22:11:56 UTC 2009


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

Change 166881 by pgj at petymeg-current on 2009/07/31 22:10:55

	IPv4 forwarding statistics are now handled via libnetstat(3)
	in netstat(1).

Affected files ...

.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/extern.h#34 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#42 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/route.c#3 edit

Differences ...

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

@@ -120,7 +120,7 @@
 
 void	pr_rthdr(int);
 void	pr_family(int);
-void	rt_stats(u_long, u_long);
+void	rt_stats(const struct stat_type *);
 char	*ipx_pnet(struct sockaddr *);
 char	*ipx_phost(struct sockaddr *);
 char	*ns_phost(struct sockaddr *);

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

@@ -77,27 +77,23 @@
 
 
 static struct nlist nl[] = {
-#define	N_RTSTAT	0
-	{ .n_name = "_rtstat" },
-#define	N_RTREE		1
+#define	N_RTREE		0
 	{ .n_name = "_rt_tables"},
-#define	N_MFCHASHTBL	2
+#define	N_MFCHASHTBL	1
 	{ .n_name = "_mfchashtbl" },
-#define	N_VIFTABLE	3
+#define	N_VIFTABLE	2
 	{ .n_name = "_viftable" },
-#define	N_IPX		4
+#define	N_IPX		3
 	{ .n_name = "_ipxpcb_list"},
-#define	N_DDPCB		5
+#define	N_DDPCB		4
 	{ .n_name = "_ddpcb"},
-#define	N_NGSOCKS	6
+#define	N_NGSOCKS	5
 	{ .n_name = "_ngsocklist"},
-#define	N_MF6CTABLE	7
+#define	N_MF6CTABLE	6
 	{ .n_name = "_mf6ctable" },
-#define	N_MIF6TABLE	8
+#define	N_MIF6TABLE	7
 	{ .n_name = "_mif6table" },
-#define	N_RTTRASH	9
-	{ .n_name = "_rttrash" },
-#define	N_MFCTABLESIZE	10
+#define	N_MFCTABLESIZE	8
 	{ .n_name = "_mfctablesize" },
 	{ .n_name = NULL },
 };
@@ -458,11 +454,15 @@
 		exit(0);
 	}
 	if (rflag) {
-		kread(0, NULL, 0);
-		if (sflag)
-			rt_stats(nl[N_RTSTAT].n_value, nl[N_RTTRASH].n_value);
-		else
+		if (sflag) {
+			if (!live)
+				kread(0, NULL, 0);
+			statpr(rt_stats, stat_route, "routing");
+		}
+		else {
+			kread(0, NULL, 0);
 			routepr(nl[N_RTREE].n_value);
+		}	
 		exit(0);
 	}
 	if (gflag) {

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

@@ -985,36 +985,20 @@
  * Print routing statistics
  */
 void
-rt_stats(u_long rtsaddr, u_long rttaddr)
+rt_stats(const struct stat_type *sttp)
 {
-	struct rtstat rtstat;
-	int rttrash;
+	const struct route_stat *s;
 
-	if (rtsaddr == 0) {
-		printf("rtstat: symbol not in namelist\n");
-		return;
-	}
-	if (rttaddr == 0) {
-		printf("rttrash: symbol not in namelist\n");
-		return;
-	}
-	kread(rtsaddr, (char *)&rtstat, sizeof (rtstat));
-	kread(rttaddr, (char *)&rttrash, sizeof (rttrash));
-	printf("routing:\n");
-
-#define	p(f, m) if (rtstat.f || sflag <= 1) \
-	printf(m, rtstat.f, plural(rtstat.f))
-
-	p(rts_badredirect, "\t%u bad routing redirect%s\n");
-	p(rts_dynamic, "\t%u dynamically created route%s\n");
-	p(rts_newgateway, "\t%u new gateway%s due to redirects\n");
-	p(rts_unreach, "\t%u destination%s found unreachable\n");
-	p(rts_wildcard, "\t%u use%s of a wildcard route\n");
+	s = netstat_get_routestats(sttp);
+#define	p(f, m) if (netstat_routes_get_##f(s) || sflag <= 1) \
+	printf(m, netstat_routes_get_##f(s), plural(netstat_routes_get_##f(s)))
+	p(badredirect, "\t%ju bad routing redirect%s\n");
+	p(dynamic, "\t%ju dynamically created route%s\n");
+	p(newgateway, "\t%ju new gateway%s due to redirects\n");
+	p(unreach, "\t%ju destination%s found unreachable\n");
+	p(wildcard, "\t%ju use%s of a wildcard route\n");
+	p(trash, "\t%ju route%s not in table but not freed\n");
 #undef p
-
-	if (rttrash || sflag <= 1)
-		printf("\t%u route%s not in table but not freed\n",
-		    rttrash, plural(rttrash));
 }
 
 char *


More information about the p4-projects mailing list