summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2013-04-12 20:48:55 +0000
committersjg <sjg@FreeBSD.org>2013-04-12 20:48:55 +0000
commit97d8b9495668afa398ab17c8c5f7e223b5fd2e89 (patch)
tree54038c9ac32a45f8741dcc23fb9a8ffc0e15ff89 /usr.bin/netstat
parent5ee3bfdb338e7c80af29a67f4425c4be24c7b866 (diff)
parent086d73aef6d0ab7d21daa2076fdc8d25961f9b05 (diff)
downloadFreeBSD-src-97d8b9495668afa398ab17c8c5f7e223b5fd2e89.zip
FreeBSD-src-97d8b9495668afa398ab17c8c5f7e223b5fd2e89.tar.gz
sync from head
Diffstat (limited to 'usr.bin/netstat')
-rw-r--r--usr.bin/netstat/inet.c274
-rw-r--r--usr.bin/netstat/inet6.c2
-rw-r--r--usr.bin/netstat/main.c83
-rw-r--r--usr.bin/netstat/netisr.c6
-rw-r--r--usr.bin/netstat/netstat.18
-rw-r--r--usr.bin/netstat/netstat.h1
-rw-r--r--usr.bin/netstat/sctp.c6
-rw-r--r--usr.bin/netstat/unix.c1
8 files changed, 216 insertions, 165 deletions
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index 8094e5b..a04cc9a 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -89,7 +89,7 @@ static int udp_done, tcp_done, sdp_done;
#endif /* INET6 */
static int
-pcblist_sysctl(int proto, const char *name, char **bufp, int istcp)
+pcblist_sysctl(int proto, const char *name, char **bufp, int istcp __unused)
{
const char *mibvar;
char *buf;
@@ -603,120 +603,131 @@ tcp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
warn("sysctl: net.inet.tcp.stats");
return;
}
- } else
- kread(off, &tcpstat, len);
+ } else {
+ u_long tcpstat_p[sizeof(struct tcpstat)/sizeof(uint64_t)];
+
+ kread(off, &tcpstat_p, sizeof(tcpstat_p));
+ kread_counters(tcpstat_p, (uint64_t *)&tcpstat,
+ sizeof(struct tcpstat)/sizeof(uint64_t));
+ }
printf ("%s:\n", name);
-#define p(f, m) if (tcpstat.f || sflag <= 1) \
- printf(m, tcpstat.f, plural(tcpstat.f))
-#define p1a(f, m) if (tcpstat.f || sflag <= 1) \
- printf(m, tcpstat.f)
-#define p2(f1, f2, m) if (tcpstat.f1 || tcpstat.f2 || sflag <= 1) \
- printf(m, tcpstat.f1, plural(tcpstat.f1), tcpstat.f2, plural(tcpstat.f2))
-#define p2a(f1, f2, m) if (tcpstat.f1 || tcpstat.f2 || sflag <= 1) \
- printf(m, tcpstat.f1, plural(tcpstat.f1), tcpstat.f2)
-#define p3(f, m) if (tcpstat.f || sflag <= 1) \
- printf(m, tcpstat.f, pluralies(tcpstat.f))
-
- p(tcps_sndtotal, "\t%lu packet%s sent\n");
- p2(tcps_sndpack,tcps_sndbyte, "\t\t%lu data packet%s (%lu byte%s)\n");
+#define p(f, m) if (tcpstat.f || sflag <= 1) \
+ printf(m, (uintmax_t )tcpstat.f, plural(tcpstat.f))
+
+#define p1a(f, m) if (tcpstat.f || sflag <= 1) \
+ printf(m, (uintmax_t )tcpstat.f)
+
+#define p2(f1, f2, m) if (tcpstat.f1 || tcpstat.f2 || sflag <= 1) \
+ printf(m, (uintmax_t )tcpstat.f1, plural(tcpstat.f1), \
+ (uintmax_t )tcpstat.f2, plural(tcpstat.f2))
+
+#define p2a(f1, f2, m) if (tcpstat.f1 || tcpstat.f2 || sflag <= 1) \
+ printf(m, (uintmax_t )tcpstat.f1, plural(tcpstat.f1), \
+ (uintmax_t )tcpstat.f2)
+
+#define p3(f, m) if (tcpstat.f || sflag <= 1) \
+ printf(m, (uintmax_t )tcpstat.f, pluralies(tcpstat.f))
+
+ p(tcps_sndtotal, "\t%ju packet%s sent\n");
+ p2(tcps_sndpack,tcps_sndbyte, "\t\t%ju data packet%s (%ju byte%s)\n");
p2(tcps_sndrexmitpack, tcps_sndrexmitbyte,
- "\t\t%lu data packet%s (%lu byte%s) retransmitted\n");
+ "\t\t%ju data packet%s (%ju byte%s) retransmitted\n");
p(tcps_sndrexmitbad,
- "\t\t%lu data packet%s unnecessarily retransmitted\n");
- p(tcps_mturesent, "\t\t%lu resend%s initiated by MTU discovery\n");
+ "\t\t%ju data packet%s unnecessarily retransmitted\n");
+ p(tcps_mturesent, "\t\t%ju resend%s initiated by MTU discovery\n");
p2a(tcps_sndacks, tcps_delack,
- "\t\t%lu ack-only packet%s (%lu delayed)\n");
- p(tcps_sndurg, "\t\t%lu URG only packet%s\n");
- p(tcps_sndprobe, "\t\t%lu window probe packet%s\n");
- p(tcps_sndwinup, "\t\t%lu window update packet%s\n");
- p(tcps_sndctrl, "\t\t%lu control packet%s\n");
- p(tcps_rcvtotal, "\t%lu packet%s received\n");
+ "\t\t%ju ack-only packet%s (%ju delayed)\n");
+ p(tcps_sndurg, "\t\t%ju URG only packet%s\n");
+ p(tcps_sndprobe, "\t\t%ju window probe packet%s\n");
+ p(tcps_sndwinup, "\t\t%ju window update packet%s\n");
+ p(tcps_sndctrl, "\t\t%ju control packet%s\n");
+ p(tcps_rcvtotal, "\t%ju packet%s received\n");
p2(tcps_rcvackpack, tcps_rcvackbyte,
- "\t\t%lu ack%s (for %lu byte%s)\n");
- p(tcps_rcvdupack, "\t\t%lu duplicate ack%s\n");
- p(tcps_rcvacktoomuch, "\t\t%lu ack%s for unsent data\n");
+ "\t\t%ju ack%s (for %ju byte%s)\n");
+ p(tcps_rcvdupack, "\t\t%ju duplicate ack%s\n");
+ p(tcps_rcvacktoomuch, "\t\t%ju ack%s for unsent data\n");
p2(tcps_rcvpack, tcps_rcvbyte,
- "\t\t%lu packet%s (%lu byte%s) received in-sequence\n");
+ "\t\t%ju packet%s (%ju byte%s) received in-sequence\n");
p2(tcps_rcvduppack, tcps_rcvdupbyte,
- "\t\t%lu completely duplicate packet%s (%lu byte%s)\n");
- p(tcps_pawsdrop, "\t\t%lu old duplicate packet%s\n");
+ "\t\t%ju completely duplicate packet%s (%ju byte%s)\n");
+ p(tcps_pawsdrop, "\t\t%ju old duplicate packet%s\n");
p2(tcps_rcvpartduppack, tcps_rcvpartdupbyte,
- "\t\t%lu packet%s with some dup. data (%lu byte%s duped)\n");
+ "\t\t%ju packet%s with some dup. data (%ju byte%s duped)\n");
p2(tcps_rcvoopack, tcps_rcvoobyte,
- "\t\t%lu out-of-order packet%s (%lu byte%s)\n");
+ "\t\t%ju out-of-order packet%s (%ju byte%s)\n");
p2(tcps_rcvpackafterwin, tcps_rcvbyteafterwin,
- "\t\t%lu packet%s (%lu byte%s) of data after window\n");
- p(tcps_rcvwinprobe, "\t\t%lu window probe%s\n");
- p(tcps_rcvwinupd, "\t\t%lu window update packet%s\n");
- p(tcps_rcvafterclose, "\t\t%lu packet%s received after close\n");
- p(tcps_rcvbadsum, "\t\t%lu discarded for bad checksum%s\n");
- p(tcps_rcvbadoff, "\t\t%lu discarded for bad header offset field%s\n");
- p1a(tcps_rcvshort, "\t\t%lu discarded because packet too short\n");
- p1a(tcps_rcvmemdrop, "\t\t%lu discarded due to memory problems\n");
- p(tcps_connattempt, "\t%lu connection request%s\n");
- p(tcps_accepts, "\t%lu connection accept%s\n");
- p(tcps_badsyn, "\t%lu bad connection attempt%s\n");
- p(tcps_listendrop, "\t%lu listen queue overflow%s\n");
- p(tcps_badrst, "\t%lu ignored RSTs in the window%s\n");
- p(tcps_connects, "\t%lu connection%s established (including accepts)\n");
+ "\t\t%ju packet%s (%ju byte%s) of data after window\n");
+ p(tcps_rcvwinprobe, "\t\t%ju window probe%s\n");
+ p(tcps_rcvwinupd, "\t\t%ju window update packet%s\n");
+ p(tcps_rcvafterclose, "\t\t%ju packet%s received after close\n");
+ p(tcps_rcvbadsum, "\t\t%ju discarded for bad checksum%s\n");
+ p(tcps_rcvbadoff, "\t\t%ju discarded for bad header offset field%s\n");
+ p1a(tcps_rcvshort, "\t\t%ju discarded because packet too short\n");
+ p1a(tcps_rcvmemdrop, "\t\t%ju discarded due to memory problems\n");
+ p(tcps_connattempt, "\t%ju connection request%s\n");
+ p(tcps_accepts, "\t%ju connection accept%s\n");
+ p(tcps_badsyn, "\t%ju bad connection attempt%s\n");
+ p(tcps_listendrop, "\t%ju listen queue overflow%s\n");
+ p(tcps_badrst, "\t%ju ignored RSTs in the window%s\n");
+ p(tcps_connects, "\t%ju connection%s established (including accepts)\n");
p2(tcps_closed, tcps_drops,
- "\t%lu connection%s closed (including %lu drop%s)\n");
- p(tcps_cachedrtt, "\t\t%lu connection%s updated cached RTT on close\n");
+ "\t%ju connection%s closed (including %ju drop%s)\n");
+ p(tcps_cachedrtt, "\t\t%ju connection%s updated cached RTT on close\n");
p(tcps_cachedrttvar,
- "\t\t%lu connection%s updated cached RTT variance on close\n");
+ "\t\t%ju connection%s updated cached RTT variance on close\n");
p(tcps_cachedssthresh,
- "\t\t%lu connection%s updated cached ssthresh on close\n");
- p(tcps_conndrops, "\t%lu embryonic connection%s dropped\n");
+ "\t\t%ju connection%s updated cached ssthresh on close\n");
+ p(tcps_conndrops, "\t%ju embryonic connection%s dropped\n");
p2(tcps_rttupdated, tcps_segstimed,
- "\t%lu segment%s updated rtt (of %lu attempt%s)\n");
- p(tcps_rexmttimeo, "\t%lu retransmit timeout%s\n");
- p(tcps_timeoutdrop, "\t\t%lu connection%s dropped by rexmit timeout\n");
- p(tcps_persisttimeo, "\t%lu persist timeout%s\n");
- p(tcps_persistdrop, "\t\t%lu connection%s dropped by persist timeout\n");
+ "\t%ju segment%s updated rtt (of %ju attempt%s)\n");
+ p(tcps_rexmttimeo, "\t%ju retransmit timeout%s\n");
+ p(tcps_timeoutdrop, "\t\t%ju connection%s dropped by rexmit timeout\n");
+ p(tcps_persisttimeo, "\t%ju persist timeout%s\n");
+ p(tcps_persistdrop, "\t\t%ju connection%s dropped by persist timeout\n");
p(tcps_finwait2_drops,
- "\t%lu Connection%s (fin_wait_2) dropped because of timeout\n");
- p(tcps_keeptimeo, "\t%lu keepalive timeout%s\n");
- p(tcps_keepprobe, "\t\t%lu keepalive probe%s sent\n");
- p(tcps_keepdrops, "\t\t%lu connection%s dropped by keepalive\n");
- p(tcps_predack, "\t%lu correct ACK header prediction%s\n");
- p(tcps_preddat, "\t%lu correct data packet header prediction%s\n");
-
- p3(tcps_sc_added, "\t%lu syncache entr%s added\n");
- p1a(tcps_sc_retransmitted, "\t\t%lu retransmitted\n");
- p1a(tcps_sc_dupsyn, "\t\t%lu dupsyn\n");
- p1a(tcps_sc_dropped, "\t\t%lu dropped\n");
- p1a(tcps_sc_completed, "\t\t%lu completed\n");
- p1a(tcps_sc_bucketoverflow, "\t\t%lu bucket overflow\n");
- p1a(tcps_sc_cacheoverflow, "\t\t%lu cache overflow\n");
- p1a(tcps_sc_reset, "\t\t%lu reset\n");
- p1a(tcps_sc_stale, "\t\t%lu stale\n");
- p1a(tcps_sc_aborted, "\t\t%lu aborted\n");
- p1a(tcps_sc_badack, "\t\t%lu badack\n");
- p1a(tcps_sc_unreach, "\t\t%lu unreach\n");
- p(tcps_sc_zonefail, "\t\t%lu zone failure%s\n");
- p(tcps_sc_sendcookie, "\t%lu cookie%s sent\n");
- p(tcps_sc_recvcookie, "\t%lu cookie%s received\n");
-
- p3(tcps_hc_added, "\t%lu hostcache entr%s added\n");
- p1a(tcps_hc_bucketoverflow, "\t\t%lu bucket overflow\n");
-
- p(tcps_sack_recovery_episode, "\t%lu SACK recovery episode%s\n");
+ "\t%ju Connection%s (fin_wait_2) dropped because of timeout\n");
+ p(tcps_keeptimeo, "\t%ju keepalive timeout%s\n");
+ p(tcps_keepprobe, "\t\t%ju keepalive probe%s sent\n");
+ p(tcps_keepdrops, "\t\t%ju connection%s dropped by keepalive\n");
+ p(tcps_predack, "\t%ju correct ACK header prediction%s\n");
+ p(tcps_preddat, "\t%ju correct data packet header prediction%s\n");
+
+ p3(tcps_sc_added, "\t%ju syncache entr%s added\n");
+ p1a(tcps_sc_retransmitted, "\t\t%ju retransmitted\n");
+ p1a(tcps_sc_dupsyn, "\t\t%ju dupsyn\n");
+ p1a(tcps_sc_dropped, "\t\t%ju dropped\n");
+ p1a(tcps_sc_completed, "\t\t%ju completed\n");
+ p1a(tcps_sc_bucketoverflow, "\t\t%ju bucket overflow\n");
+ p1a(tcps_sc_cacheoverflow, "\t\t%ju cache overflow\n");
+ p1a(tcps_sc_reset, "\t\t%ju reset\n");
+ p1a(tcps_sc_stale, "\t\t%ju stale\n");
+ p1a(tcps_sc_aborted, "\t\t%ju aborted\n");
+ p1a(tcps_sc_badack, "\t\t%ju badack\n");
+ p1a(tcps_sc_unreach, "\t\t%ju unreach\n");
+ p(tcps_sc_zonefail, "\t\t%ju zone failure%s\n");
+ p(tcps_sc_sendcookie, "\t%ju cookie%s sent\n");
+ p(tcps_sc_recvcookie, "\t%ju cookie%s received\n");
+
+ p3(tcps_hc_added, "\t%ju hostcache entr%s added\n");
+ p1a(tcps_hc_bucketoverflow, "\t\t%ju bucket overflow\n");
+
+ p(tcps_sack_recovery_episode, "\t%ju SACK recovery episode%s\n");
p(tcps_sack_rexmits,
- "\t%lu segment rexmit%s in SACK recovery episodes\n");
+ "\t%ju segment rexmit%s in SACK recovery episodes\n");
p(tcps_sack_rexmit_bytes,
- "\t%lu byte rexmit%s in SACK recovery episodes\n");
+ "\t%ju byte rexmit%s in SACK recovery episodes\n");
p(tcps_sack_rcv_blocks,
- "\t%lu SACK option%s (SACK blocks) received\n");
- p(tcps_sack_send_blocks, "\t%lu SACK option%s (SACK blocks) sent\n");
- p1a(tcps_sack_sboverflow, "\t%lu SACK scoreboard overflow\n");
-
- p(tcps_ecn_ce, "\t%lu packet%s with ECN CE bit set\n");
- p(tcps_ecn_ect0, "\t%lu packet%s with ECN ECT(0) bit set\n");
- p(tcps_ecn_ect1, "\t%lu packet%s with ECN ECT(1) bit set\n");
- p(tcps_ecn_shs, "\t%lu successful ECN handshake%s\n");
- p(tcps_ecn_rcwnd, "\t%lu time%s ECN reduced the congestion window\n");
+ "\t%ju SACK option%s (SACK blocks) received\n");
+ p(tcps_sack_send_blocks, "\t%ju SACK option%s (SACK blocks) sent\n");
+ p1a(tcps_sack_sboverflow, "\t%ju SACK scoreboard overflow\n");
+
+ p(tcps_ecn_ce, "\t%ju packet%s with ECN CE bit set\n");
+ p(tcps_ecn_ect0, "\t%ju packet%s with ECN ECT(0) bit set\n");
+ p(tcps_ecn_ect1, "\t%ju packet%s with ECN ECT(1) bit set\n");
+ p(tcps_ecn_shs, "\t%ju successful ECN handshake%s\n");
+ p(tcps_ecn_rcwnd, "\t%ju time%s ECN reduced the congestion window\n");
#undef p
#undef p1a
#undef p2
@@ -852,49 +863,54 @@ ip_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
warn("sysctl: net.inet.ip.stats");
return;
}
- } else
- kread(off, &ipstat, len);
+ } else {
+ u_long ipstat_p[sizeof(struct ipstat)/sizeof(uint64_t)];
+
+ kread(off, &ipstat_p, sizeof(ipstat_p));
+ kread_counters(ipstat_p, (uint64_t *)&ipstat,
+ sizeof(struct ipstat)/sizeof(uint64_t));
+ }
printf("%s:\n", name);
#define p(f, m) if (ipstat.f || sflag <= 1) \
- printf(m, ipstat.f, plural(ipstat.f))
+ printf(m, (uintmax_t )ipstat.f, plural(ipstat.f))
#define p1a(f, m) if (ipstat.f || sflag <= 1) \
- printf(m, ipstat.f)
-
- p(ips_total, "\t%lu total packet%s received\n");
- p(ips_badsum, "\t%lu bad header checksum%s\n");
- p1a(ips_toosmall, "\t%lu with size smaller than minimum\n");
- p1a(ips_tooshort, "\t%lu with data size < data length\n");
- p1a(ips_toolong, "\t%lu with ip length > max ip packet size\n");
- p1a(ips_badhlen, "\t%lu with header length < data size\n");
- p1a(ips_badlen, "\t%lu with data length < header length\n");
- p1a(ips_badoptions, "\t%lu with bad options\n");
- p1a(ips_badvers, "\t%lu with incorrect version number\n");
- p(ips_fragments, "\t%lu fragment%s received\n");
- p(ips_fragdropped, "\t%lu fragment%s dropped (dup or out of space)\n");
- p(ips_fragtimeout, "\t%lu fragment%s dropped after timeout\n");
- p(ips_reassembled, "\t%lu packet%s reassembled ok\n");
- p(ips_delivered, "\t%lu packet%s for this host\n");
- p(ips_noproto, "\t%lu packet%s for unknown/unsupported protocol\n");
- p(ips_forward, "\t%lu packet%s forwarded");
- p(ips_fastforward, " (%lu packet%s fast forwarded)");
+ printf(m, (uintmax_t )ipstat.f)
+
+ p(ips_total, "\t%ju total packet%s received\n");
+ p(ips_badsum, "\t%ju bad header checksum%s\n");
+ p1a(ips_toosmall, "\t%ju with size smaller than minimum\n");
+ p1a(ips_tooshort, "\t%ju with data size < data length\n");
+ p1a(ips_toolong, "\t%ju with ip length > max ip packet size\n");
+ p1a(ips_badhlen, "\t%ju with header length < data size\n");
+ p1a(ips_badlen, "\t%ju with data length < header length\n");
+ p1a(ips_badoptions, "\t%ju with bad options\n");
+ p1a(ips_badvers, "\t%ju with incorrect version number\n");
+ p(ips_fragments, "\t%ju fragment%s received\n");
+ p(ips_fragdropped, "\t%ju fragment%s dropped (dup or out of space)\n");
+ p(ips_fragtimeout, "\t%ju fragment%s dropped after timeout\n");
+ p(ips_reassembled, "\t%ju packet%s reassembled ok\n");
+ p(ips_delivered, "\t%ju packet%s for this host\n");
+ p(ips_noproto, "\t%ju packet%s for unknown/unsupported protocol\n");
+ p(ips_forward, "\t%ju packet%s forwarded");
+ p(ips_fastforward, " (%ju packet%s fast forwarded)");
if (ipstat.ips_forward || sflag <= 1)
putchar('\n');
- p(ips_cantforward, "\t%lu packet%s not forwardable\n");
+ p(ips_cantforward, "\t%ju packet%s not forwardable\n");
p(ips_notmember,
- "\t%lu packet%s received for unknown multicast group\n");
- p(ips_redirectsent, "\t%lu redirect%s sent\n");
- p(ips_localout, "\t%lu packet%s sent from this host\n");
- p(ips_rawout, "\t%lu packet%s sent with fabricated ip header\n");
+ "\t%ju packet%s received for unknown multicast group\n");
+ p(ips_redirectsent, "\t%ju redirect%s sent\n");
+ p(ips_localout, "\t%ju packet%s sent from this host\n");
+ p(ips_rawout, "\t%ju packet%s sent with fabricated ip header\n");
p(ips_odropped,
- "\t%lu output packet%s dropped due to no bufs, etc.\n");
- p(ips_noroute, "\t%lu output packet%s discarded due to no route\n");
- p(ips_fragmented, "\t%lu output datagram%s fragmented\n");
- p(ips_ofragments, "\t%lu fragment%s created\n");
- p(ips_cantfrag, "\t%lu datagram%s that can't be fragmented\n");
- p(ips_nogif, "\t%lu tunneling packet%s that can't find gif\n");
- p(ips_badaddr, "\t%lu datagram%s with bad address in header\n");
+ "\t%ju output packet%s dropped due to no bufs, etc.\n");
+ p(ips_noroute, "\t%ju output packet%s discarded due to no route\n");
+ p(ips_fragmented, "\t%ju output datagram%s fragmented\n");
+ p(ips_ofragments, "\t%ju fragment%s created\n");
+ p(ips_cantfrag, "\t%ju datagram%s that can't be fragmented\n");
+ p(ips_nogif, "\t%ju tunneling packet%s that can't find gif\n");
+ p(ips_badaddr, "\t%ju datagram%s with bad address in header\n");
#undef p
#undef p1a
}
diff --git a/usr.bin/netstat/inet6.c b/usr.bin/netstat/inet6.c
index 1a19fa5..9f51d06 100644
--- a/usr.bin/netstat/inet6.c
+++ b/usr.bin/netstat/inet6.c
@@ -335,7 +335,7 @@ static const char *ip6nh[] = {
"#255",
};
-static char *srcrule_str[] = {
+static const char *srcrule_str[] = {
"first candidate",
"same address",
"appropriate scope",
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c
index 09c0096..ce4ff95 100644
--- a/usr.bin/netstat/main.c
+++ b/usr.bin/netstat/main.c
@@ -147,11 +147,11 @@ static struct nlist nl[] = {
#define N_IPCOMPSTAT 37
{ .n_name = "_ipcompstat" },
#define N_TCPSTAT 38
- { .n_name = "_tcpstat" },
+ { .n_name = "_tcpstatp" },
#define N_UDPSTAT 39
{ .n_name = "_udpstat" },
#define N_IPSTAT 40
- { .n_name = "_ipstat" },
+ { .n_name = "_ipstatp" },
#define N_ICMPSTAT 41
{ .n_name = "_icmpstat" },
#define N_IGMPSTAT 42
@@ -640,9 +640,7 @@ main(int argc, char *argv[])
* is not in the namelist, ignore this one.
*/
static void
-printproto(tp, name)
- struct protox *tp;
- const char *name;
+printproto(struct protox *tp, const char *name)
{
void (*pr)(u_long, const char *, int, int);
u_long off;
@@ -698,37 +696,50 @@ printproto(tp, name)
(*pr)(off, name, af, tp->pr_protocol);
}
+static int
+kvmd_init(void)
+{
+ char errbuf[_POSIX2_LINE_MAX];
+
+ if (kvmd != NULL)
+ return (0);
+
+ kvmd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf);
+ setgid(getgid());
+
+ if (kvmd == NULL) {
+ warnx("kvm not available: %s", errbuf);
+ return (-1);
+ }
+
+ if (kvm_nlist(kvmd, nl) < 0) {
+ if (nlistf)
+ errx(1, "%s: kvm_nlist: %s", nlistf,
+ kvm_geterr(kvmd));
+ else
+ errx(1, "kvm_nlist: %s", kvm_geterr(kvmd));
+ }
+
+ if (nl[0].n_type == 0) {
+ if (nlistf)
+ errx(1, "%s: no namelist", nlistf);
+ else
+ errx(1, "no namelist");
+ }
+
+ return (0);
+}
+
/*
* Read kernel memory, return 0 on success.
*/
int
kread(u_long addr, void *buf, size_t size)
{
- char errbuf[_POSIX2_LINE_MAX];
- if (kvmd == NULL) {
- kvmd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf);
- setgid(getgid());
- if (kvmd != NULL) {
- if (kvm_nlist(kvmd, nl) < 0) {
- if (nlistf)
- errx(1, "%s: kvm_nlist: %s", nlistf,
- kvm_geterr(kvmd));
- else
- errx(1, "kvm_nlist: %s", kvm_geterr(kvmd));
- }
+ if (kvmd_init() < 0)
+ return (-1);
- if (nl[0].n_type == 0) {
- if (nlistf)
- errx(1, "%s: no namelist", nlistf);
- else
- errx(1, "no namelist");
- }
- } else {
- warnx("kvm not available: %s", errbuf);
- return(-1);
- }
- }
if (!buf)
return (0);
if (kvm_read(kvmd, addr, buf, size) != (ssize_t)size) {
@@ -738,6 +749,22 @@ kread(u_long addr, void *buf, size_t size)
return (0);
}
+/*
+ * Read an array of N counters in kernel memory into array of N uint64_t's.
+ */
+int
+kread_counters(u_long *addr, uint64_t *rval, size_t count)
+{
+
+ if (kvmd_init() < 0)
+ return (-1);
+
+ for (u_int i = 0; i < count; i++, addr++, rval++)
+ *rval = kvm_counter_u64_fetch(kvmd, *addr);
+
+ return (0);
+}
+
const char *
plural(uintmax_t n)
{
diff --git a/usr.bin/netstat/netisr.c b/usr.bin/netstat/netisr.c
index cc05c38..6c945c3 100644
--- a/usr.bin/netstat/netisr.c
+++ b/usr.bin/netstat/netisr.c
@@ -76,12 +76,12 @@ static u_int *nws_array;
static u_int maxprot;
static void
-netisr_dispatch_policy_to_string(u_int dispatch_policy, char *buf,
+netisr_dispatch_policy_to_string(u_int policy, char *buf,
size_t buflen)
{
const char *str;
- switch (dispatch_policy) {
+ switch (policy) {
case NETISR_DISPATCH_DEFAULT:
str = "default";
break;
@@ -102,7 +102,7 @@ netisr_dispatch_policy_to_string(u_int dispatch_policy, char *buf,
}
static void
-netisr_load_kvm_uint(kvm_t *kd, char *name, u_int *p)
+netisr_load_kvm_uint(kvm_t *kd, const char *name, u_int *p)
{
struct nlist nl[] = {
{ .n_name = name },
diff --git a/usr.bin/netstat/netstat.1 b/usr.bin/netstat/netstat.1
index 90f4067..c52340a 100644
--- a/usr.bin/netstat/netstat.1
+++ b/usr.bin/netstat/netstat.1
@@ -28,7 +28,7 @@
.\" @(#)netstat.1 8.8 (Berkeley) 4/18/94
.\" $FreeBSD$
.\"
-.Dd February 22, 2010
+.Dd March 10, 2013
.Dt NETSTAT 1
.Os
.Sh NAME
@@ -301,6 +301,12 @@ is repeated, counters with a value of zero are suppressed.
Show
.Xr netisr 9
statistics.
+The flags field shows available ISR handlers:
+.Bl -column ".Li W" ".Dv NETISR_SNP_FLAGS_DRAINEDCPU"
+.It Li C Ta Dv NETISR_SNP_FLAGS_M2CPUID Ta "Able to map mbuf to cpu id"
+.It Li D Ta Dv NETISR_SNP_FLAGS_DRAINEDCPU Ta "Has queue drain handler"
+.It Li F Ta Dv NETISR_SNP_FLAGS_M2FLOW Ta "Able to map mbuf to flow id"
+.El
.El
.Pp
Some options have the general meaning:
diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h
index 9b545d8..32bea79 100644
--- a/usr.bin/netstat/netstat.h
+++ b/usr.bin/netstat/netstat.h
@@ -60,6 +60,7 @@ extern int af; /* address family */
extern int live; /* true if we are examining a live system */
int kread(u_long addr, void *buf, size_t size);
+int kread_counters(u_long *addr, uint64_t *rval, size_t count);
const char *plural(uintmax_t);
const char *plurales(uintmax_t);
const char *pluralies(uintmax_t);
diff --git a/usr.bin/netstat/sctp.c b/usr.bin/netstat/sctp.c
index 2f67b0c..a2ef7d568 100644
--- a/usr.bin/netstat/sctp.c
+++ b/usr.bin/netstat/sctp.c
@@ -77,7 +77,7 @@ static void sctp_statesprint(uint32_t state);
#define NETSTAT_SCTP_STATES_SHUTDOWN_ACK_SENT 0x8
#define NETSTAT_SCTP_STATES_SHUTDOWN_PENDING 0x9
-char *sctpstates[] = {
+const char *sctpstates[] = {
"CLOSED",
"BOUND",
"LISTEN",
@@ -393,7 +393,7 @@ sctp_process_inpcb(struct xsctp_inpcb *xinpcb,
{
int indent = 0, xladdr_total = 0, is_listening = 0;
static int first = 1;
- char *tname, *pname;
+ const char *tname, *pname;
struct xsctp_tcb *xstcb;
struct xsctp_laddr *xladdr;
size_t offset_laddr;
@@ -527,7 +527,7 @@ retry:
*/
void
sctp_protopr(u_long off __unused,
- const char *name, int af1, int proto)
+ const char *name __unused, int af1 __unused, int proto)
{
char *buf;
const char *mibvar = "net.inet.sctp.assoclist";
diff --git a/usr.bin/netstat/unix.c b/usr.bin/netstat/unix.c
index 9a643c2..027e812 100644
--- a/usr.bin/netstat/unix.c
+++ b/usr.bin/netstat/unix.c
@@ -199,6 +199,7 @@ unixpr(u_long count_off, u_long gencnt_off, u_long dhead_off, u_long shead_off,
struct xunpcb *xunp;
u_long head_off;
+ buf = NULL;
for (type = SOCK_STREAM; type <= SOCK_SEQPACKET; type++) {
if (live)
ret = pcblist_sysctl(type, &buf);
OpenPOWER on IntegriCloud