PERFORCE change 166877 for review
Gabor Pali
pgj at FreeBSD.org
Fri Jul 31 21:24:03 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=166877
Change 166877 by pgj at petymeg-current on 2009/07/31 21:23:15
Make netstat(1) to use libnetstat(3) for juggling with
IPv6 multicast forwarding statistics.
Affected files ...
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/extern.h#33 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#41 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/mroute6.c#3 edit
Differences ...
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/extern.h#33 (text+ko) ====
@@ -102,7 +102,7 @@
void pim6_stats(const struct stat_type *);
void rip6_stats(const struct stat_type *);
void mroute6pr(u_long, u_long);
-void mrt6_stats(u_long);
+void mrt6_stats(const struct stat_type *);
struct sockaddr_in6;
struct in6_addr;
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#41 (text+ko) ====
@@ -91,15 +91,13 @@
{ .n_name = "_ddpcb"},
#define N_NGSOCKS 6
{ .n_name = "_ngsocklist"},
-#define N_MRT6STAT 7
- { .n_name = "_mrt6stat" },
-#define N_MF6CTABLE 8
+#define N_MF6CTABLE 7
{ .n_name = "_mf6ctable" },
-#define N_MIF6TABLE 9
+#define N_MIF6TABLE 8
{ .n_name = "_mif6table" },
-#define N_RTTRASH 10
+#define N_RTTRASH 9
{ .n_name = "_rttrash" },
-#define N_MFCTABLESIZE 11
+#define N_MFCTABLESIZE 10
{ .n_name = "_mfctablesize" },
{ .n_name = NULL },
};
@@ -475,7 +473,8 @@
"IPv4 multicast forwarding");
#ifdef INET6
if (af == AF_INET6 || af == AF_UNSPEC)
- mrt6_stats(nl[N_MRT6STAT].n_value);
+ statpr(mrt6_stats, stat_mroute6,
+ "IPv6 multicast forwarding");
#endif
} else {
if (af == AF_INET || af == AF_UNSPEC)
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/mroute6.c#3 (text+ko) ====
@@ -217,43 +217,28 @@
}
void
-mrt6_stats(u_long mstaddr)
+mrt6_stats(const struct stat_type *sttp)
{
- struct mrt6stat mrtstat;
- size_t len = sizeof mrtstat;
+ const struct mroute6_stat *s;
- if (live) {
- if (sysctlbyname("net.inet6.ip6.mrt6stat", &mrtstat, &len,
- NULL, 0) < 0) {
- warn("sysctl: net.inet6.ip6.mrt6stat");
- return;
- }
- } else
- kread(mstaddr, (char *)&mrtstat, sizeof(mrtstat));
-
- printf("IPv6 multicast forwarding:\n");
-
-#define p(f, m) if (mrtstat.f || sflag <= 1) \
- printf(m, (uintmax_t)mrtstat.f, plural(mrtstat.f))
-#define p2(f, m) if (mrtstat.f || sflag <= 1) \
- printf(m, (uintmax_t)mrtstat.f, plurales(mrtstat.f))
-
- p(mrt6s_mfc_lookups, "\t%ju multicast forwarding cache lookup%s\n");
- p2(mrt6s_mfc_misses, "\t%ju multicast forwarding cache miss%s\n");
- p(mrt6s_upcalls, "\t%ju upcall%s to multicast routing daemon\n");
- p(mrt6s_upq_ovflw, "\t%ju upcall queue overflow%s\n");
- p(mrt6s_upq_sockfull,
- "\t%ju upcall%s dropped due to full socket buffer\n");
- p(mrt6s_cache_cleanups, "\t%ju cache cleanup%s\n");
- p(mrt6s_no_route, "\t%ju datagram%s with no route for origin\n");
- p(mrt6s_bad_tunnel, "\t%ju datagram%s arrived with bad tunneling\n");
- p(mrt6s_cant_tunnel, "\t%ju datagram%s could not be tunneled\n");
- p(mrt6s_wrong_if, "\t%ju datagram%s arrived on wrong interface\n");
- p(mrt6s_drop_sel, "\t%ju datagram%s selectively dropped\n");
- p(mrt6s_q_overflow,
- "\t%ju datagram%s dropped due to queue overflow\n");
- p(mrt6s_pkt2large, "\t%ju datagram%s dropped for being too large\n");
-
+ s = netstat_get_mroute6stats(sttp);
+#define p(f, m) if (netstat_mroute6s_get_##f(s) || sflag <= 1) \
+ printf(m, netstat_mroute6s_get_##f(s), plural(netstat_mroute6s_get_##f(s)))
+#define p2(f, m) if (netstat_mroute6s_get_##f(s) || sflag <= 1) \
+ printf(m, netstat_mroute6s_get_##f(s), plurales(netstat_mroute6s_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