From owner-p4-projects@FreeBSD.ORG Thu Jul 30 17:28:27 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 56E5310656B2; Thu, 30 Jul 2009 17:28:26 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EBB0C10656B0 for ; Thu, 30 Jul 2009 17:28:25 +0000 (UTC) (envelope-from pgj@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id D93D38FC1C for ; Thu, 30 Jul 2009 17:28:25 +0000 (UTC) (envelope-from pgj@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n6UHSPB1097349 for ; Thu, 30 Jul 2009 17:28:25 GMT (envelope-from pgj@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n6UHSPxS097345 for perforce@freebsd.org; Thu, 30 Jul 2009 17:28:25 GMT (envelope-from pgj@FreeBSD.org) Date: Thu, 30 Jul 2009 17:28:25 GMT Message-Id: <200907301728.n6UHSPxS097345@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to pgj@FreeBSD.org using -f From: Gabor Pali To: Perforce Change Reviews Cc: Subject: PERFORCE change 166808 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jul 2009 17:28:27 -0000 http://perforce.freebsd.org/chv.cgi?CH=166808 Change 166808 by pgj@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 } };