PERFORCE change 166873 for review
Gabor Pali
pgj at FreeBSD.org
Fri Jul 31 20:58:35 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=166873
Change 166873 by pgj at petymeg-current on 2009/07/31 20:57:53
Let function rt_stats() in netstat(1) call libnetstat(3) for
displaying statistics.
Affected files ...
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/extern.h#32 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#40 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/mroute.c#3 edit
Differences ...
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/extern.h#32 (text+ko) ====
@@ -163,5 +163,5 @@
void tp_stats(caddr_t, caddr_t);
void mroutepr(u_long, u_long, u_long);
-void mrt_stats(u_long);
+void mrt_stats(const struct stat_type *);
void bpf_stats(char *, void *);
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#40 (text+ko) ====
@@ -81,27 +81,25 @@
{ .n_name = "_rtstat" },
#define N_RTREE 1
{ .n_name = "_rt_tables"},
-#define N_MRTSTAT 2
- { .n_name = "_mrtstat" },
-#define N_MFCHASHTBL 3
+#define N_MFCHASHTBL 2
{ .n_name = "_mfchashtbl" },
-#define N_VIFTABLE 4
+#define N_VIFTABLE 3
{ .n_name = "_viftable" },
-#define N_IPX 5
+#define N_IPX 4
{ .n_name = "_ipxpcb_list"},
-#define N_DDPCB 6
+#define N_DDPCB 5
{ .n_name = "_ddpcb"},
-#define N_NGSOCKS 7
+#define N_NGSOCKS 6
{ .n_name = "_ngsocklist"},
-#define N_MRT6STAT 8
+#define N_MRT6STAT 7
{ .n_name = "_mrt6stat" },
-#define N_MF6CTABLE 9
+#define N_MF6CTABLE 8
{ .n_name = "_mf6ctable" },
-#define N_MIF6TABLE 10
+#define N_MIF6TABLE 9
{ .n_name = "_mif6table" },
-#define N_RTTRASH 11
+#define N_RTTRASH 10
{ .n_name = "_rttrash" },
-#define N_MFCTABLESIZE 12
+#define N_MFCTABLESIZE 11
{ .n_name = "_mfctablesize" },
{ .n_name = NULL },
};
@@ -473,7 +471,8 @@
kread(0, NULL, 0);
if (sflag) {
if (af == AF_INET || af == AF_UNSPEC)
- mrt_stats(nl[N_MRTSTAT].n_value);
+ statpr(mrt_stats, stat_mroute,
+ "IPv4 multicast forwarding");
#ifdef INET6
if (af == AF_INET6 || af == AF_UNSPEC)
mrt6_stats(nl[N_MRT6STAT].n_value);
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/mroute.c#3 (text+ko) ====
@@ -338,42 +338,28 @@
}
void
-mrt_stats(u_long mstaddr)
+mrt_stats(const struct stat_type *sttp)
{
- struct mrtstat mrtstat;
- size_t len = sizeof mrtstat;
+ const struct mroute_stat *s;
- if (live) {
- if (sysctlbyname("net.inet.ip.mrtstat", &mrtstat, &len, NULL,
- 0) < 0) {
- warn("sysctl: net.inet.ip.mrtstat");
- return;
- }
- } else
- kread(mstaddr, (char *)&mrtstat, sizeof(mrtstat));
-
- printf("IPv4 multicast forwarding:\n");
-
-#define p(f, m) if (mrtstat.f || sflag <= 1) \
- printf(m, mrtstat.f, plural(mrtstat.f))
-#define p2(f, m) if (mrtstat.f || sflag <= 1) \
- printf(m, mrtstat.f, plurales(mrtstat.f))
-
- p(mrts_mfc_lookups, "\t%lu multicast forwarding cache lookup%s\n");
- p2(mrts_mfc_misses, "\t%lu multicast forwarding cache miss%s\n");
- p(mrts_upcalls, "\t%lu upcall%s to multicast routing daemon\n");
- p(mrts_upq_ovflw, "\t%lu upcall queue overflow%s\n");
- p(mrts_upq_sockfull,
- "\t%lu upcall%s dropped due to full socket buffer\n");
- p(mrts_cache_cleanups, "\t%lu cache cleanup%s\n");
- p(mrts_no_route, "\t%lu datagram%s with no route for origin\n");
- p(mrts_bad_tunnel, "\t%lu datagram%s arrived with bad tunneling\n");
- p(mrts_cant_tunnel, "\t%lu datagram%s could not be tunneled\n");
- p(mrts_wrong_if, "\t%lu datagram%s arrived on wrong interface\n");
- p(mrts_drop_sel, "\t%lu datagram%s selectively dropped\n");
- p(mrts_q_overflow, "\t%lu datagram%s dropped due to queue overflow\n");
- p(mrts_pkt2large, "\t%lu datagram%s dropped for being too large\n");
-
+ s = netstat_get_mroutestats(sttp);
+#define p(f, m) if (netstat_mroutes_get_##f(s) || sflag <= 1) \
+ printf(m, netstat_mroutes_get_##f(s), plural(netstat_mroutes_get_##f(s)))
+#define p2(f, m) if (netstat_mroutes_get_##f(s) || sflag <= 1) \
+ printf(m, netstat_mroutes_get_##f(s), plurales(netstat_mroutes_get_##f(s)))
+ p(mfc_lookups, "\t%ju multicast forwarding cache lookup%s\n");
+ p2(mfc_misses, "\t%ju multicast forwarding cache miss%s\n");
+ p(upcalls, "\t%ju upcall%s to multicast routing daemon\n");
+ p(upq_ovflw, "\t%ju upcall queue overflow%s\n");
+ p(upq_sockfull, "\t%ju upcall%s dropped due to full socket buffer\n");
+ p(cache_cleanups, "\t%ju cache cleanup%s\n");
+ p(no_route, "\t%ju datagram%s with no route for origin\n");
+ p(bad_tunnel, "\t%ju datagram%s arrived with bad tunneling\n");
+ p(cant_tunnel, "\t%ju datagram%s could not be tunneled\n");
+ p(wrong_if, "\t%ju datagram%s arrived on wrong interface\n");
+ p(drop_sel, "\t%ju datagram%s selectively dropped\n");
+ p(q_overflow, "\t%ju datagram%s dropped due to queue overflow\n");
+ p(pkt2large, "\t%ju datagram%s dropped for being too large\n");
#undef p2
#undef p
}
More information about the p4-projects
mailing list