summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorae <ae@FreeBSD.org>2013-07-09 09:32:06 +0000
committerae <ae@FreeBSD.org>2013-07-09 09:32:06 +0000
commit1a36dfcc879833c6fdc45e20d39db618b110f55c (patch)
treecad0a71b5db80ecb80a8a7339f4a480cc96c54be /usr.bin
parent91dfaf8dd5d31f04188d8f43b006545b68878474 (diff)
downloadFreeBSD-src-1a36dfcc879833c6fdc45e20d39db618b110f55c.zip
FreeBSD-src-1a36dfcc879833c6fdc45e20d39db618b110f55c.tar.gz
Prepare network statistics structures for migration to PCPU counters.
Use uint64_t as type for all fields of structures. Changed structures: ahstat, arpstat, espstat, icmp6_ifstat, icmp6stat, in6_ifstat, ip6stat, ipcompstat, ipipstat, ipsecstat, mrt6stat, mrtstat, pfkeystat, pim6stat, pimstat, rip6stat, udpstat. Discussed with: arch@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/netstat/inet.c52
-rw-r--r--usr.bin/netstat/ipsec.c152
-rw-r--r--usr.bin/netstat/mroute.c30
3 files changed, 109 insertions, 125 deletions
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index a04cc9a..c898775 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -743,7 +743,7 @@ udp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
{
struct udpstat udpstat, zerostat;
size_t len = sizeof udpstat;
- u_long delivered;
+ uint64_t delivered;
#ifdef INET6
if (udp_done != 0)
@@ -765,19 +765,19 @@ udp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
printf("%s:\n", name);
#define p(f, m) if (udpstat.f || sflag <= 1) \
- printf(m, udpstat.f, plural(udpstat.f))
+ printf("\t%ju " m, (uintmax_t)udpstat.f, plural(udpstat.f))
#define p1a(f, m) if (udpstat.f || sflag <= 1) \
- printf(m, udpstat.f)
- p(udps_ipackets, "\t%lu datagram%s received\n");
- p1a(udps_hdrops, "\t%lu with incomplete header\n");
- p1a(udps_badlen, "\t%lu with bad data length field\n");
- p1a(udps_badsum, "\t%lu with bad checksum\n");
- p1a(udps_nosum, "\t%lu with no checksum\n");
- p1a(udps_noport, "\t%lu dropped due to no socket\n");
+ printf("\t%ju " m, (uintmax_t)udpstat.f)
+ p(udps_ipackets, "datagram%s received\n");
+ p1a(udps_hdrops, "with incomplete header\n");
+ p1a(udps_badlen, "with bad data length field\n");
+ p1a(udps_badsum, "with bad checksum\n");
+ p1a(udps_nosum, "with no checksum\n");
+ p1a(udps_noport, "dropped due to no socket\n");
p(udps_noportbcast,
- "\t%lu broadcast/multicast datagram%s undelivered\n");
- p1a(udps_fullsock, "\t%lu dropped due to full socket buffers\n");
- p1a(udpps_pcbhashmiss, "\t%lu not for hashed pcb\n");
+ "broadcast/multicast datagram%s undelivered\n");
+ p1a(udps_fullsock, "dropped due to full socket buffers\n");
+ p1a(udpps_pcbhashmiss, "not for hashed pcb\n");
delivered = udpstat.udps_ipackets -
udpstat.udps_hdrops -
udpstat.udps_badlen -
@@ -786,11 +786,11 @@ udp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
udpstat.udps_noportbcast -
udpstat.udps_fullsock;
if (delivered || sflag <= 1)
- printf("\t%lu delivered\n", delivered);
- p(udps_opackets, "\t%lu datagram%s output\n");
+ printf("\t%ju delivered\n", (uint64_t)delivered);
+ p(udps_opackets, "datagram%s output\n");
/* the next statistic is cumulative in udps_noportbcast */
p(udps_filtermcast,
- "\t%lu time%s multicast source filter matched\n");
+ "time%s multicast source filter matched\n");
#undef p
#undef p1a
}
@@ -938,18 +938,18 @@ arp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
printf("%s:\n", name);
#define p(f, m) if (arpstat.f || sflag <= 1) \
- printf(m, arpstat.f, plural(arpstat.f))
+ printf("\t%ju " m, (uintmax_t)arpstat.f, plural(arpstat.f))
#define p2(f, m) if (arpstat.f || sflag <= 1) \
- printf(m, arpstat.f, pluralies(arpstat.f))
-
- p(txrequests, "\t%lu ARP request%s sent\n");
- p2(txreplies, "\t%lu ARP repl%s sent\n");
- p(rxrequests, "\t%lu ARP request%s received\n");
- p2(rxreplies, "\t%lu ARP repl%s received\n");
- p(received, "\t%lu ARP packet%s received\n");
- p(dropped, "\t%lu total packet%s dropped due to no ARP entry\n");
- p(timeouts, "\t%lu ARP entry%s timed out\n");
- p(dupips, "\t%lu Duplicate IP%s seen\n");
+ printf("\t%ju " m, (uintmax_t)arpstat.f, pluralies(arpstat.f))
+
+ p(txrequests, "ARP request%s sent\n");
+ p2(txreplies, "ARP repl%s sent\n");
+ p(rxrequests, "ARP request%s received\n");
+ p2(rxreplies, "ARP repl%s received\n");
+ p(received, "ARP packet%s received\n");
+ p(dropped, "total packet%s dropped due to no ARP entry\n");
+ p(timeouts, "ARP entry%s timed out\n");
+ p(dupips, "Duplicate IP%s seen\n");
#undef p
#undef p2
}
diff --git a/usr.bin/netstat/ipsec.c b/usr.bin/netstat/ipsec.c
index 7b16f57..ad3c092 100644
--- a/usr.bin/netstat/ipsec.c
+++ b/usr.bin/netstat/ipsec.c
@@ -274,7 +274,7 @@ ipsec_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
}
-static void ipsec_hist_new(const u_int32_t *hist, size_t histmax,
+static void ipsec_hist_new(const uint64_t *hist, size_t histmax,
const struct val2str *name, const char *title);
static void print_ahstats(const struct ahstat *ahstat);
static void print_espstats(const struct espstat *espstat);
@@ -284,7 +284,7 @@ static void print_ipcompstats(const struct ipcompstat *ipcompstat);
* Dump IPSEC statistics structure.
*/
static void
-ipsec_hist_new(const u_int32_t *hist, size_t histmax,
+ipsec_hist_new(const uint64_t *hist, size_t histmax,
const struct val2str *name, const char *title)
{
int first;
@@ -304,10 +304,11 @@ ipsec_hist_new(const u_int32_t *hist, size_t histmax,
break;
}
if (p && p->str) {
- printf("\t\t%s: %u\n", p->str, hist[proto]);
+ printf("\t\t%s: %ju\n", p->str,
+ (uintmax_t)hist[proto]);
} else {
- printf("\t\t#%lu: %u\n", (unsigned long)proto,
- hist[proto]);
+ printf("\t\t#%lu: %ju\n", (unsigned long)proto,
+ (uintmax_t)hist[proto]);
}
}
}
@@ -315,36 +316,33 @@ ipsec_hist_new(const u_int32_t *hist, size_t histmax,
static void
print_ahstats(const struct ahstat *ahstat)
{
-#define p32(f, m) if (ahstat->f || sflag <= 1) \
- printf("\t%u" m, (unsigned int)ahstat->f, plural(ahstat->f))
-#define p64(f, m) if (ahstat->f || sflag <= 1) \
+#define p(f, m) if (ahstat->f || sflag <= 1) \
printf("\t%ju" m, (uintmax_t)ahstat->f, plural(ahstat->f))
#define hist(f, n, t) \
ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t));
- p32(ahs_hdrops, " packet%s shorter than header shows\n");
- p32(ahs_nopf, " packet%s dropped; protocol family not supported\n");
- p32(ahs_notdb, " packet%s dropped; no TDB\n");
- p32(ahs_badkcr, " packet%s dropped; bad KCR\n");
- p32(ahs_qfull, " packet%s dropped; queue full\n");
- p32(ahs_noxform, " packet%s dropped; no transform\n");
- p32(ahs_wrap, " replay counter wrap%s\n");
- p32(ahs_badauth, " packet%s dropped; bad authentication detected\n");
- p32(ahs_badauthl, " packet%s dropped; bad authentication length\n");
- p32(ahs_replay, " possible replay packet%s detected\n");
- p32(ahs_input, " packet%s in\n");
- p32(ahs_output, " packet%s out\n");
- p32(ahs_invalid, " packet%s dropped; invalid TDB\n");
- p64(ahs_ibytes, " byte%s in\n");
- p64(ahs_obytes, " byte%s out\n");
- p32(ahs_toobig, " packet%s dropped; larger than IP_MAXPACKET\n");
- p32(ahs_pdrops, " packet%s blocked due to policy\n");
- p32(ahs_crypto, " crypto processing failure%s\n");
- p32(ahs_tunnel, " tunnel sanity check failure%s\n");
+ p(ahs_hdrops, " packet%s shorter than header shows\n");
+ p(ahs_nopf, " packet%s dropped; protocol family not supported\n");
+ p(ahs_notdb, " packet%s dropped; no TDB\n");
+ p(ahs_badkcr, " packet%s dropped; bad KCR\n");
+ p(ahs_qfull, " packet%s dropped; queue full\n");
+ p(ahs_noxform, " packet%s dropped; no transform\n");
+ p(ahs_wrap, " replay counter wrap%s\n");
+ p(ahs_badauth, " packet%s dropped; bad authentication detected\n");
+ p(ahs_badauthl, " packet%s dropped; bad authentication length\n");
+ p(ahs_replay, " possible replay packet%s detected\n");
+ p(ahs_input, " packet%s in\n");
+ p(ahs_output, " packet%s out\n");
+ p(ahs_invalid, " packet%s dropped; invalid TDB\n");
+ p(ahs_ibytes, " byte%s in\n");
+ p(ahs_obytes, " byte%s out\n");
+ p(ahs_toobig, " packet%s dropped; larger than IP_MAXPACKET\n");
+ p(ahs_pdrops, " packet%s blocked due to policy\n");
+ p(ahs_crypto, " crypto processing failure%s\n");
+ p(ahs_tunnel, " tunnel sanity check failure%s\n");
hist(ahstat->ahs_hist, ipsec_ahnames, "AH output");
-#undef p32
-#undef p64
+#undef p
#undef hist
}
@@ -364,37 +362,34 @@ ah_stats(u_long off, const char *name, int family __unused, int proto __unused)
static void
print_espstats(const struct espstat *espstat)
{
-#define p32(f, m) if (espstat->f || sflag <= 1) \
- printf("\t%u" m, (unsigned int)espstat->f, plural(espstat->f))
-#define p64(f, m) if (espstat->f || sflag <= 1) \
+#define p(f, m) if (espstat->f || sflag <= 1) \
printf("\t%ju" m, (uintmax_t)espstat->f, plural(espstat->f))
#define hist(f, n, t) \
ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t));
- p32(esps_hdrops, " packet%s shorter than header shows\n");
- p32(esps_nopf, " packet%s dropped; protocol family not supported\n");
- p32(esps_notdb, " packet%s dropped; no TDB\n");
- p32(esps_badkcr, " packet%s dropped; bad KCR\n");
- p32(esps_qfull, " packet%s dropped; queue full\n");
- p32(esps_noxform, " packet%s dropped; no transform\n");
- p32(esps_badilen, " packet%s dropped; bad ilen\n");
- p32(esps_wrap, " replay counter wrap%s\n");
- p32(esps_badenc, " packet%s dropped; bad encryption detected\n");
- p32(esps_badauth, " packet%s dropped; bad authentication detected\n");
- p32(esps_replay, " possible replay packet%s detected\n");
- p32(esps_input, " packet%s in\n");
- p32(esps_output, " packet%s out\n");
- p32(esps_invalid, " packet%s dropped; invalid TDB\n");
- p64(esps_ibytes, " byte%s in\n");
- p64(esps_obytes, " byte%s out\n");
- p32(esps_toobig, " packet%s dropped; larger than IP_MAXPACKET\n");
- p32(esps_pdrops, " packet%s blocked due to policy\n");
- p32(esps_crypto, " crypto processing failure%s\n");
- p32(esps_tunnel, " tunnel sanity check failure%s\n");
+ p(esps_hdrops, " packet%s shorter than header shows\n");
+ p(esps_nopf, " packet%s dropped; protocol family not supported\n");
+ p(esps_notdb, " packet%s dropped; no TDB\n");
+ p(esps_badkcr, " packet%s dropped; bad KCR\n");
+ p(esps_qfull, " packet%s dropped; queue full\n");
+ p(esps_noxform, " packet%s dropped; no transform\n");
+ p(esps_badilen, " packet%s dropped; bad ilen\n");
+ p(esps_wrap, " replay counter wrap%s\n");
+ p(esps_badenc, " packet%s dropped; bad encryption detected\n");
+ p(esps_badauth, " packet%s dropped; bad authentication detected\n");
+ p(esps_replay, " possible replay packet%s detected\n");
+ p(esps_input, " packet%s in\n");
+ p(esps_output, " packet%s out\n");
+ p(esps_invalid, " packet%s dropped; invalid TDB\n");
+ p(esps_ibytes, " byte%s in\n");
+ p(esps_obytes, " byte%s out\n");
+ p(esps_toobig, " packet%s dropped; larger than IP_MAXPACKET\n");
+ p(esps_pdrops, " packet%s blocked due to policy\n");
+ p(esps_crypto, " crypto processing failure%s\n");
+ p(esps_tunnel, " tunnel sanity check failure%s\n");
hist(espstat->esps_hist, ipsec_espnames, "ESP output");
-#undef p32
-#undef p64
+#undef p
#undef hist
}
@@ -414,42 +409,31 @@ esp_stats(u_long off, const char *name, int family __unused, int proto __unused)
static void
print_ipcompstats(const struct ipcompstat *ipcompstat)
{
- uint32_t version;
-#define p32(f, m) if (ipcompstat->f || sflag <= 1) \
- printf("\t%u" m, (unsigned int)ipcompstat->f, plural(ipcompstat->f))
-#define p64(f, m) if (ipcompstat->f || sflag <= 1) \
+#define p(f, m) if (ipcompstat->f || sflag <= 1) \
printf("\t%ju" m, (uintmax_t)ipcompstat->f, plural(ipcompstat->f))
#define hist(f, n, t) \
ipsec_hist_new((f), sizeof(f)/sizeof(f[0]), (n), (t));
-#ifndef IPCOMPSTAT_VERSION
- version = 0;
-#else
- version = ipcompstat->version;
-#endif
- p32(ipcomps_hdrops, " packet%s shorter than header shows\n");
- p32(ipcomps_nopf, " packet%s dropped; protocol family not supported\n");
- p32(ipcomps_notdb, " packet%s dropped; no TDB\n");
- p32(ipcomps_badkcr, " packet%s dropped; bad KCR\n");
- p32(ipcomps_qfull, " packet%s dropped; queue full\n");
- p32(ipcomps_noxform, " packet%s dropped; no transform\n");
- p32(ipcomps_wrap, " replay counter wrap%s\n");
- p32(ipcomps_input, " packet%s in\n");
- p32(ipcomps_output, " packet%s out\n");
- p32(ipcomps_invalid, " packet%s dropped; invalid TDB\n");
- p64(ipcomps_ibytes, " byte%s in\n");
- p64(ipcomps_obytes, " byte%s out\n");
- p32(ipcomps_toobig, " packet%s dropped; larger than IP_MAXPACKET\n");
- p32(ipcomps_pdrops, " packet%s blocked due to policy\n");
- p32(ipcomps_crypto, " crypto processing failure%s\n");
+ p(ipcomps_hdrops, " packet%s shorter than header shows\n");
+ p(ipcomps_nopf, " packet%s dropped; protocol family not supported\n");
+ p(ipcomps_notdb, " packet%s dropped; no TDB\n");
+ p(ipcomps_badkcr, " packet%s dropped; bad KCR\n");
+ p(ipcomps_qfull, " packet%s dropped; queue full\n");
+ p(ipcomps_noxform, " packet%s dropped; no transform\n");
+ p(ipcomps_wrap, " replay counter wrap%s\n");
+ p(ipcomps_input, " packet%s in\n");
+ p(ipcomps_output, " packet%s out\n");
+ p(ipcomps_invalid, " packet%s dropped; invalid TDB\n");
+ p(ipcomps_ibytes, " byte%s in\n");
+ p(ipcomps_obytes, " byte%s out\n");
+ p(ipcomps_toobig, " packet%s dropped; larger than IP_MAXPACKET\n");
+ p(ipcomps_pdrops, " packet%s blocked due to policy\n");
+ p(ipcomps_crypto, " crypto processing failure%s\n");
hist(ipcompstat->ipcomps_hist, ipsec_compnames, "COMP output");
- if (version >= 1) {
- p32(ipcomps_threshold, " packet%s sent uncompressed; size < compr. algo. threshold\n");
- p32(ipcomps_uncompr, " packet%s sent uncompressed; compression was useless\n");
- }
+ p(ipcomps_threshold, " packet%s sent uncompressed; size < compr. algo. threshold\n");
+ p(ipcomps_uncompr, " packet%s sent uncompressed; compression was useless\n");
-#undef p32
-#undef p64
+#undef p
#undef hist
}
diff --git a/usr.bin/netstat/mroute.c b/usr.bin/netstat/mroute.c
index 4d55cb6..b8e5d6d 100644
--- a/usr.bin/netstat/mroute.c
+++ b/usr.bin/netstat/mroute.c
@@ -355,24 +355,24 @@ mrt_stats(u_long mstaddr)
printf("IPv4 multicast forwarding:\n");
#define p(f, m) if (mrtstat.f || sflag <= 1) \
- printf(m, mrtstat.f, plural(mrtstat.f))
+ printf(m, (uintmax_t)mrtstat.f, plural(mrtstat.f))
#define p2(f, m) if (mrtstat.f || sflag <= 1) \
- printf(m, mrtstat.f, plurales(mrtstat.f))
+ printf(m, (uintmax_t)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_mfc_lookups, "\t%ju multicast forwarding cache lookup%s\n");
+ p2(mrts_mfc_misses, "\t%ju multicast forwarding cache miss%s\n");
+ p(mrts_upcalls, "\t%ju upcall%s to multicast routing daemon\n");
+ p(mrts_upq_ovflw, "\t%ju 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");
+ "\t%ju upcall%s dropped due to full socket buffer\n");
+ p(mrts_cache_cleanups, "\t%ju cache cleanup%s\n");
+ p(mrts_no_route, "\t%ju datagram%s with no route for origin\n");
+ p(mrts_bad_tunnel, "\t%ju datagram%s arrived with bad tunneling\n");
+ p(mrts_cant_tunnel, "\t%ju datagram%s could not be tunneled\n");
+ p(mrts_wrong_if, "\t%ju datagram%s arrived on wrong interface\n");
+ p(mrts_drop_sel, "\t%ju datagram%s selectively dropped\n");
+ p(mrts_q_overflow, "\t%ju datagram%s dropped due to queue overflow\n");
+ p(mrts_pkt2large, "\t%ju datagram%s dropped for being too large\n");
#undef p2
#undef p
OpenPOWER on IntegriCloud