From owner-svn-src-head@freebsd.org Sun Aug 14 13:17:56 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C21AFBB99EB; Sun, 14 Aug 2016 13:17:56 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9E4991A05; Sun, 14 Aug 2016 13:17:56 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u7EDHteR016398; Sun, 14 Aug 2016 13:17:55 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u7EDHtNS016395; Sun, 14 Aug 2016 13:17:55 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201608141317.u7EDHtNS016395@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Sun, 14 Aug 2016 13:17:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r304076 - head/sbin/ipfw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Aug 2016 13:17:56 -0000 Author: ae Date: Sun Aug 14 13:17:55 2016 New Revision: 304076 URL: https://svnweb.freebsd.org/changeset/base/304076 Log: Make statistics nat64lsn, nat64stl an nptv6 output netstat-like: "@value @description" and fix build due to -Wformat errors. Modified: head/sbin/ipfw/nat64lsn.c head/sbin/ipfw/nat64stl.c head/sbin/ipfw/nptv6.c Modified: head/sbin/ipfw/nat64lsn.c ============================================================================== --- head/sbin/ipfw/nat64lsn.c Sun Aug 14 09:26:10 2016 (r304075) +++ head/sbin/ipfw/nat64lsn.c Sun Aug 14 13:17:55 2016 (r304076) @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -687,7 +688,6 @@ nat64lsn_get_stats(const char *name, uin return (-1); } -#define _P_STAT(_s, _f) printf("%8s:\t%lu\n", #_f, _s._f) static void nat64lsn_stats(const char *name, uint8_t set) { @@ -696,34 +696,61 @@ nat64lsn_stats(const char *name, uint8_t if (nat64lsn_get_stats(name, set, &stats) != 0) err(EX_OSERR, "Error retrieving stats"); - _P_STAT(stats, opcnt64); - _P_STAT(stats, opcnt46); - _P_STAT(stats, ofrags); - _P_STAT(stats, ifrags); - _P_STAT(stats, oerrors); - _P_STAT(stats, noroute4); - _P_STAT(stats, noroute6); - _P_STAT(stats, noproto); - _P_STAT(stats, nomem); - _P_STAT(stats, dropped); - - _P_STAT(stats, hostcount); - _P_STAT(stats, tcpchunks); - _P_STAT(stats, udpchunks); - _P_STAT(stats, icmpchunks); - _P_STAT(stats, jcalls); - _P_STAT(stats, jrequests); - _P_STAT(stats, jhostsreq); - _P_STAT(stats, jportreq); - _P_STAT(stats, jhostfails); - _P_STAT(stats, jportfails); - _P_STAT(stats, jreinjected); - _P_STAT(stats, jmaxlen); - _P_STAT(stats, jnomem); - _P_STAT(stats, screated); - _P_STAT(stats, sdeleted); - _P_STAT(stats, spgcreated); - _P_STAT(stats, spgdeleted); + if (co.use_set != 0 || set != 0) + printf("set %u ", set); + printf("nat64lsn %s\n", name); + printf("\t%ju packets translated from IPv6 to IPv4\n", + (uintmax_t)stats.opcnt64); + printf("\t%ju packets translated from IPv4 to IPv6\n", + (uintmax_t)stats.opcnt46); + printf("\t%ju IPv6 fragments created\n", + (uintmax_t)stats.ofrags); + printf("\t%ju IPv4 fragments received\n", + (uintmax_t)stats.ifrags); + printf("\t%ju output packets dropped due to no bufs, etc.\n", + (uintmax_t)stats.oerrors); + printf("\t%ju output packets discarded due to no IPv4 route\n", + (uintmax_t)stats.noroute4); + printf("\t%ju output packets discarded due to no IPv6 route\n", + (uintmax_t)stats.noroute6); + printf("\t%ju packets discarded due to unsupported protocol\n", + (uintmax_t)stats.noproto); + printf("\t%ju packets discarded due to memory allocation problems\n", + (uintmax_t)stats.nomem); + printf("\t%ju packets discarded due to some errors\n", + (uintmax_t)stats.dropped); + printf("\t%ju packets not matched with IPv4 prefix\n", + (uintmax_t)stats.nomatch4); + + printf("\t%ju mbufs queued for post processing\n", + (uintmax_t)stats.jreinjected); + printf("\t%ju times the job queue was processed\n", + (uintmax_t)stats.jcalls); + printf("\t%ju job requests queued\n", + (uintmax_t)stats.jrequests); + printf("\t%ju job requests queue limit reached\n", + (uintmax_t)stats.jmaxlen); + printf("\t%ju job requests failed due to memory allocation problems\n", + (uintmax_t)stats.jnomem); + + printf("\t%ju hosts allocated\n", (uintmax_t)stats.hostcount); + printf("\t%ju hosts requested\n", (uintmax_t)stats.jhostsreq); + printf("\t%ju host requests failed\n", (uintmax_t)stats.jhostfails); + + printf("\t%ju portgroups requested\n", (uintmax_t)stats.jportreq); + printf("\t%ju portgroups allocated\n", (uintmax_t)stats.spgcreated); + printf("\t%ju portgroups deleted\n", (uintmax_t)stats.spgdeleted); + printf("\t%ju portgroup requests failed\n", + (uintmax_t)stats.jportfails); + printf("\t%ju portgroups allocated for TCP\n", + (uintmax_t)stats.tcpchunks); + printf("\t%ju portgroups allocated for UDP\n", + (uintmax_t)stats.udpchunks); + printf("\t%ju portgroups allocated for ICMP\n", + (uintmax_t)stats.icmpchunks); + + printf("\t%ju states created\n", (uintmax_t)stats.screated); + printf("\t%ju states deleted\n", (uintmax_t)stats.sdeleted); } static int Modified: head/sbin/ipfw/nat64stl.c ============================================================================== --- head/sbin/ipfw/nat64stl.c Sun Aug 14 09:26:10 2016 (r304075) +++ head/sbin/ipfw/nat64stl.c Sun Aug 14 13:17:55 2016 (r304076) @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -386,7 +387,6 @@ nat64stl_get_stats(const char *name, uin return (-1); } -#define _P_STAT(_s, _f) printf("%8s:\t%lu\n", #_f, _s._f) static void nat64stl_stats(const char *name, uint8_t set) { @@ -395,16 +395,30 @@ nat64stl_stats(const char *name, uint8_t if (nat64stl_get_stats(name, set, &stats) != 0) err(EX_OSERR, "Error retrieving stats"); - _P_STAT(stats, opcnt64); - _P_STAT(stats, opcnt46); - _P_STAT(stats, ofrags); - _P_STAT(stats, ifrags); - _P_STAT(stats, oerrors); - _P_STAT(stats, noroute4); - _P_STAT(stats, noroute6); - _P_STAT(stats, noproto); - _P_STAT(stats, nomem); - _P_STAT(stats, dropped); + if (co.use_set != 0 || set != 0) + printf("set %u ", set); + printf("nat64stl %s\n", name); + + printf("\t%ju packets translated from IPv6 to IPv4\n", + (uintmax_t)stats.opcnt64); + printf("\t%ju packets translated from IPv4 to IPv6\n", + (uintmax_t)stats.opcnt46); + printf("\t%ju IPv6 fragments created\n", + (uintmax_t)stats.ofrags); + printf("\t%ju IPv4 fragments received\n", + (uintmax_t)stats.ifrags); + printf("\t%ju output packets dropped due to no bufs, etc.\n", + (uintmax_t)stats.oerrors); + printf("\t%ju output packets discarded due to no IPv4 route\n", + (uintmax_t)stats.noroute4); + printf("\t%ju output packets discarded due to no IPv6 route\n", + (uintmax_t)stats.noroute6); + printf("\t%ju packets discarded due to unsupported protocol\n", + (uintmax_t)stats.noproto); + printf("\t%ju packets discarded due to memory allocation problems\n", + (uintmax_t)stats.nomem); + printf("\t%ju packets discarded due to some errors\n", + (uintmax_t)stats.dropped); } /* Modified: head/sbin/ipfw/nptv6.c ============================================================================== --- head/sbin/ipfw/nptv6.c Sun Aug 14 09:26:10 2016 (r304075) +++ head/sbin/ipfw/nptv6.c Sun Aug 14 13:17:55 2016 (r304076) @@ -309,11 +309,14 @@ nptv6_stats(const char *name, uint8_t se if (nptv6_get_stats(name, set, &stats) != 0) err(EX_OSERR, "Error retrieving stats"); - printf("Number of packets translated (internal to external): %ju\n", + if (co.use_set != 0 || set != 0) + printf("set %u ", set); + printf("nptv6 %s\n", name); + printf("\t%ju packets translated (internal to external)\n", (uintmax_t)stats.in2ex); - printf("Number of packets translated (external to internal): %ju\n", + printf("\t%ju packets translated (external to internal)\n", (uintmax_t)stats.ex2in); - printf("Number of packets dropped due to some error: %ju\n", + printf("\t%ju packets dropped due to some error\n", (uintmax_t)stats.dropped); }