PERFORCE change 166715 for review
Gabor Pali
pgj at FreeBSD.org
Wed Jul 29 02:07:36 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=166715
Change 166715 by pgj at petymeg-current on 2009/07/29 02:07:07
Convert SCTP statistics into their libnetstatified form.
Affected files ...
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/extern.h#19 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#27 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/sctp.c#3 edit
Differences ...
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/extern.h#19 (text+ko) ====
@@ -78,7 +78,7 @@
void udp_stats(const struct stat_type *);
#ifdef SCTP
void sctp_protopr(u_long, const char *, int, int);
-void sctp_stats(u_long, const char *, int, int);
+void sctp_stats(const struct stat_type *);
#endif
void ip_stats(const struct stat_type *);
void icmp_stats(const struct stat_type *);
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#27 (text+ko) ====
@@ -127,9 +127,7 @@
{ .n_name = "_ipcompstat" },
#define N_RIP6STAT 24
{ .n_name = "_rip6stat" },
-#define N_SCTPSTAT 25
- { .n_name = "_sctpstat" },
-#define N_MFCTABLESIZE 26
+#define N_MFCTABLESIZE 25
{ .n_name = "_mfctablesize" },
{ .n_name = NULL },
};
@@ -154,8 +152,8 @@
{ 0, 0, 1, NULL, udp_stats, stat_UDP,
NULL, NULL, "udp", 1, IPPROTO_UDP },
#ifdef SCTP
- { -1, N_SCTPSTAT, 1, sctp_protopr, NULL, stat_MAX,
- sctp_stats, NULL, "sctp", 1, IPPROTO_SCTP },
+ { -1, 0, 1, sctp_protopr, sctp_stats, stat_SCTP,
+ NULL, NULL, "sctp", 1, IPPROTO_SCTP },
#endif
{ 0, -1, 1, NULL, NULL, stat_MAX,
NULL, NULL, "divert", 1, IPPROTO_DIVERT },
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/sctp.c#3 (text+ko) ====
@@ -510,179 +510,159 @@
* Dump SCTP statistics structure.
*/
void
-sctp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
+sctp_stats(const struct stat_type *sttp)
{
- struct sctpstat sctpstat, zerostat;
- size_t len = sizeof(sctpstat);
+ const struct sctp_stat *s;
- if (live) {
- if (zflag)
- memset(&zerostat, 0, len);
- if (sysctlbyname("net.inet.sctp.stats", &sctpstat, &len,
- zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
- warn("sysctl: net.inet.sctp.stats");
- return;
- }
- } else
- kread(off, &sctpstat, len);
-
- printf ("%s:\n", name);
-
-#define p(f, m) if (sctpstat.f || sflag <= 1) \
- printf(m, (uintmax_t)sctpstat.f, plural(sctpstat.f))
-#define p1a(f, m) if (sctpstat.f || sflag <= 1) \
- printf(m, (uintmax_t)sctpstat.f)
-
+ s = netstat_get_sctpstats(sttp);
+#define p(f, m) if (netstat_sctps_get_##f(s) || sflag <= 1) \
+ printf(m, (uintmax_t)netstat_sctps_get_##f(s), plural(netstat_sctps_get_##f(s)))
+#define p1a(f, m) if (netstat_sctps_get_##f(s) || sflag <= 1) \
+ printf(m, (uintmax_t)netstat_sctps_get_##f(s))
/*
* input statistics
*/
- p(sctps_recvpackets, "\t%ju input packet%s\n");
- p(sctps_recvdatagrams, "\t\t%ju datagram%s\n");
- p(sctps_recvpktwithdata, "\t\t%ju packet%s that had data\n");
- p(sctps_recvsacks, "\t\t%ju input SACK chunk%s\n");
- p(sctps_recvdata, "\t\t%ju input DATA chunk%s\n");
- p(sctps_recvdupdata, "\t\t%ju duplicate DATA chunk%s\n");
- p(sctps_recvheartbeat, "\t\t%ju input HB chunk%s\n");
- p(sctps_recvheartbeatack, "\t\t%ju HB-ACK chunk%s\n");
- p(sctps_recvecne, "\t\t%ju input ECNE chunk%s\n");
- p(sctps_recvauth, "\t\t%ju input AUTH chunk%s\n");
- p(sctps_recvauthmissing, "\t\t%ju chunk%s missing AUTH\n");
- p(sctps_recvivalhmacid, "\t\t%ju invalid HMAC id%s received\n");
- p(sctps_recvivalkeyid, "\t\t%ju invalid secret id%s received\n");
- p1a(sctps_recvauthfailed, "\t\t%ju auth failed\n");
- p1a(sctps_recvexpress, "\t\t%ju fast path receives all one chunk\n");
- p1a(sctps_recvexpressm, "\t\t%ju fast path multi-part data\n");
-
+ p(recvpackets, "\t%ju input packet%s\n");
+ p(recvdatagrams, "\t\t%ju datagram%s\n");
+ p(recvpktwithdata, "\t\t%ju packet%s that had data\n");
+ p(recvsacks, "\t\t%ju input SACK chunk%s\n");
+ p(recvdata, "\t\t%ju input DATA chunk%s\n");
+ p(recvdupdata, "\t\t%ju duplicate DATA chunk%s\n");
+ p(recvheartbeat, "\t\t%ju input HB chunk%s\n");
+ p(recvheartbeatack, "\t\t%ju HB-ACK chunk%s\n");
+ p(recvecne, "\t\t%ju input ECNE chunk%s\n");
+ p(recvauth, "\t\t%ju input AUTH chunk%s\n");
+ p(recvauthmissing, "\t\t%ju chunk%s missing AUTH\n");
+ p(recvivalhmacid, "\t\t%ju invalid HMAC id%s received\n");
+ p(recvivalkeyid, "\t\t%ju invalid secret id%s received\n");
+ p1a(recvauthfailed, "\t\t%ju auth failed\n");
+ p1a(recvexpress, "\t\t%ju fast path receives all one chunk\n");
+ p1a(recvexpressm, "\t\t%ju fast path multi-part data\n");
/*
* output statistics
*/
- p(sctps_sendpackets, "\t%ju output packet%s\n");
- p(sctps_sendsacks, "\t\t%ju output SACK%s\n");
- p(sctps_senddata, "\t\t%ju output DATA chunk%s\n");
- p(sctps_sendretransdata, "\t\t%ju retransmitted DATA chunk%s\n");
- p(sctps_sendfastretrans, "\t\t%ju fast retransmitted DATA chunk%s\n");
- p(sctps_sendmultfastretrans, "\t\t%ju FR'%s that happened more "
+ p(sendpackets, "\t%ju output packet%s\n");
+ p(sendsacks, "\t\t%ju output SACK%s\n");
+ p(senddata, "\t\t%ju output DATA chunk%s\n");
+ p(sendretransdata, "\t\t%ju retransmitted DATA chunk%s\n");
+ p(sendfastretrans, "\t\t%ju fast retransmitted DATA chunk%s\n");
+ p(sendmultfastretrans, "\t\t%ju FR'%s that happened more "
"than once to same chunk\n");
- p(sctps_sendheartbeat, "\t\t%ju intput HB chunk%s\n");
- p(sctps_sendecne, "\t\t%ju output ECNE chunk%s\n");
- p(sctps_sendauth, "\t\t%ju output AUTH chunk%s\n");
- p1a(sctps_senderrors, "\t\t%ju ip_output error counter\n");
-
+ p(sendheartbeat, "\t\t%ju intput HB chunk%s\n");
+ p(sendecne, "\t\t%ju output ECNE chunk%s\n");
+ p(sendauth, "\t\t%ju output AUTH chunk%s\n");
+ p1a(senderrors, "\t\t%ju ip_output error counter\n");
/*
* PCKDROPREP statistics
*/
printf("\tPacket drop statistics:\n");
- p1a(sctps_pdrpfmbox, "\t\t%ju from middle box\n");
- p1a(sctps_pdrpfehos, "\t\t%ju from end host\n");
- p1a(sctps_pdrpmbda, "\t\t%ju with data\n");
- p1a(sctps_pdrpmbct, "\t\t%ju non-data, non-endhost\n");
- p1a(sctps_pdrpbwrpt, "\t\t%ju non-endhost, bandwidth rep only\n");
- p1a(sctps_pdrpcrupt, "\t\t%ju not enough for chunk header\n");
- p1a(sctps_pdrpnedat, "\t\t%ju not enough data to confirm\n");
- p1a(sctps_pdrppdbrk, "\t\t%ju where process_chunk_drop said break\n");
- p1a(sctps_pdrptsnnf, "\t\t%ju failed to find TSN\n");
- p1a(sctps_pdrpdnfnd, "\t\t%ju attempt reverse TSN lookup\n");
- p1a(sctps_pdrpdiwnp, "\t\t%ju e-host confirms zero-rwnd\n");
- p1a(sctps_pdrpdizrw, "\t\t%ju midbox confirms no space\n");
- p1a(sctps_pdrpbadd, "\t\t%ju data did not match TSN\n");
- p(sctps_pdrpmark, "\t\t%ju TSN'%s marked for Fast Retran\n");
-
+ p1a(pdrpfmbox, "\t\t%ju from middle box\n");
+ p1a(pdrpfehos, "\t\t%ju from end host\n");
+ p1a(pdrpmbda, "\t\t%ju with data\n");
+ p1a(pdrpmbct, "\t\t%ju non-data, non-endhost\n");
+ p1a(pdrpbwrpt, "\t\t%ju non-endhost, bandwidth rep only\n");
+ p1a(pdrpcrupt, "\t\t%ju not enough for chunk header\n");
+ p1a(pdrpnedat, "\t\t%ju not enough data to confirm\n");
+ p1a(pdrppdbrk, "\t\t%ju where process_chunk_drop said break\n");
+ p1a(pdrptsnnf, "\t\t%ju failed to find TSN\n");
+ p1a(pdrpdnfnd, "\t\t%ju attempt reverse TSN lookup\n");
+ p1a(pdrpdiwnp, "\t\t%ju e-host confirms zero-rwnd\n");
+ p1a(pdrpdizrw, "\t\t%ju midbox confirms no space\n");
+ p1a(pdrpbadd, "\t\t%ju data did not match TSN\n");
+ p(pdrpmark, "\t\t%ju TSN'%s marked for Fast Retran\n");
/*
* Timeouts
*/
printf("\tTimeouts:\n");
- p(sctps_timoiterator, "\t\t%ju iterator timer%s fired\n");
- p(sctps_timodata, "\t\t%ju T3 data time out%s\n");
- p(sctps_timowindowprobe, "\t\t%ju window probe (T3) timer%s fired\n");
- p(sctps_timoinit, "\t\t%ju INIT timer%s fired\n");
- p(sctps_timosack, "\t\t%ju sack timer%s fired\n");
- p(sctps_timoshutdown, "\t\t%ju shutdown timer%s fired\n");
- p(sctps_timoheartbeat, "\t\t%ju heartbeat timer%s fired\n");
- p1a(sctps_timocookie, "\t\t%ju a cookie timeout fired\n");
- p1a(sctps_timosecret, "\t\t%ju an endpoint changed its cookie"
+ p(timoiterator, "\t\t%ju iterator timer%s fired\n");
+ p(timodata, "\t\t%ju T3 data time out%s\n");
+ p(timowindowprobe, "\t\t%ju window probe (T3) timer%s fired\n");
+ p(timoinit, "\t\t%ju INIT timer%s fired\n");
+ p(timosack, "\t\t%ju sack timer%s fired\n");
+ p(timoshutdown, "\t\t%ju shutdown timer%s fired\n");
+ p(timoheartbeat, "\t\t%ju heartbeat timer%s fired\n");
+ p1a(timocookie, "\t\t%ju a cookie timeout fired\n");
+ p1a(timosecret, "\t\t%ju an endpoint changed its cookie"
"secret\n");
- p(sctps_timopathmtu, "\t\t%ju PMTU timer%s fired\n");
- p(sctps_timoshutdownack, "\t\t%ju shutdown ack timer%s fired\n");
- p(sctps_timoshutdownguard, "\t\t%ju shutdown guard timer%s fired\n");
- p(sctps_timostrmrst, "\t\t%ju stream reset timer%s fired\n");
- p(sctps_timoearlyfr, "\t\t%ju early FR timer%s fired\n");
- p1a(sctps_timoasconf, "\t\t%ju an asconf timer fired\n");
- p1a(sctps_timoautoclose, "\t\t%ju auto close timer fired\n");
- p(sctps_timoassockill, "\t\t%ju asoc free timer%s expired\n");
- p(sctps_timoinpkill, "\t\t%ju inp free timer%s expired\n");
-
+ p(timopathmtu, "\t\t%ju PMTU timer%s fired\n");
+ p(timoshutdownack, "\t\t%ju shutdown ack timer%s fired\n");
+ p(timoshutdownguard, "\t\t%ju shutdown guard timer%s fired\n");
+ p(timostrmrst, "\t\t%ju stream reset timer%s fired\n");
+ p(timoearlyfr, "\t\t%ju early FR timer%s fired\n");
+ p1a(timoasconf, "\t\t%ju an asconf timer fired\n");
+ p1a(timoautoclose, "\t\t%ju auto close timer fired\n");
+ p(timoassockill, "\t\t%ju asoc free timer%s expired\n");
+ p(timoinpkill, "\t\t%ju inp free timer%s expired\n");
#if 0
/*
* Early fast retransmission counters
*/
- p(sctps_earlyfrstart, "\t%ju TODO:sctps_earlyfrstart\n");
- p(sctps_earlyfrstop, "\t%ju TODO:sctps_earlyfrstop\n");
- p(sctps_earlyfrmrkretrans, "\t%ju TODO:sctps_earlyfrmrkretrans\n");
- p(sctps_earlyfrstpout, "\t%ju TODO:sctps_earlyfrstpout\n");
- p(sctps_earlyfrstpidsck1, "\t%ju TODO:sctps_earlyfrstpidsck1\n");
- p(sctps_earlyfrstpidsck2, "\t%ju TODO:sctps_earlyfrstpidsck2\n");
- p(sctps_earlyfrstpidsck3, "\t%ju TODO:sctps_earlyfrstpidsck3\n");
- p(sctps_earlyfrstpidsck4, "\t%ju TODO:sctps_earlyfrstpidsck4\n");
- p(sctps_earlyfrstrid, "\t%ju TODO:sctps_earlyfrstrid\n");
- p(sctps_earlyfrstrout, "\t%ju TODO:sctps_earlyfrstrout\n");
- p(sctps_earlyfrstrtmr, "\t%ju TODO:sctps_earlyfrstrtmr\n");
+ p(earlyfrstart, "\t%ju TODO:sctps_earlyfrstart\n");
+ p(earlyfrstop, "\t%ju TODO:sctps_earlyfrstop\n");
+ p(earlyfrmrkretrans, "\t%ju TODO:sctps_earlyfrmrkretrans\n");
+ p(earlyfrstpout, "\t%ju TODO:sctps_earlyfrstpout\n");
+ p(earlyfrstpidsck1, "\t%ju TODO:sctps_earlyfrstpidsck1\n");
+ p(earlyfrstpidsck2, "\t%ju TODO:sctps_earlyfrstpidsck2\n");
+ p(earlyfrstpidsck3, "\t%ju TODO:sctps_earlyfrstpidsck3\n");
+ p(earlyfrstpidsck4, "\t%ju TODO:sctps_earlyfrstpidsck4\n");
+ p(earlyfrstrid, "\t%ju TODO:sctps_earlyfrstrid\n");
+ p(earlyfrstrout, "\t%ju TODO:sctps_earlyfrstrout\n");
+ p(earlyfrstrtmr, "\t%ju TODO:sctps_earlyfrstrtmr\n");
#endif
-
/*
* Others
*/
- p1a(sctps_hdrops, "\t%ju packet shorter than header\n");
- p1a(sctps_badsum, "\t%ju checksum error\n");
- p1a(sctps_noport, "\t%ju no endpoint for port\n");
- p1a(sctps_badvtag, "\t%ju bad v-tag\n");
- p1a(sctps_badsid, "\t%ju bad SID\n");
- p1a(sctps_nomem, "\t%ju no memory\n");
- p1a(sctps_fastretransinrtt, "\t%ju number of multiple FR in a RTT "
+ p1a(hdrops, "\t%ju packet shorter than header\n");
+ p1a(badsum, "\t%ju checksum error\n");
+ p1a(noport, "\t%ju no endpoint for port\n");
+ p1a(badvtag, "\t%ju bad v-tag\n");
+ p1a(badsid, "\t%ju bad SID\n");
+ p1a(nomem, "\t%ju no memory\n");
+ p1a(fastretransinrtt, "\t%ju number of multiple FR in a RTT "
"window\n");
#if 0
- p(sctps_markedretrans, "\t%ju TODO:sctps_markedretrans\n");
+ p(markedretrans, "\t%ju TODO:sctps_markedretrans\n");
#endif
- p1a(sctps_naglesent, "\t%ju RFC813 allowed sending\n");
- p1a(sctps_naglequeued, "\t%ju RFC813 does not allow sending\n");
- p1a(sctps_maxburstqueued, "\t%ju times max burst prohibited sending\n");
- p1a(sctps_ifnomemqueued, "\t%ju look ahead tells us no memory in "
+ p1a(naglesent, "\t%ju RFC813 allowed sending\n");
+ p1a(naglequeued, "\t%ju RFC813 does not allow sending\n");
+ p1a(maxburstqueued, "\t%ju times max burst prohibited sending\n");
+ p1a(ifnomemqueued, "\t%ju look ahead tells us no memory in "
"interface\n");
- p(sctps_windowprobed, "\t%ju number%s of window probes sent\n");
- p(sctps_lowlevelerr, "\t%ju time%s an output error to clamp "
+ p(windowprobed, "\t%ju number%s of window probes sent\n");
+ p(lowlevelerr, "\t%ju time%s an output error to clamp "
"down on next user send\n");
- p(sctps_lowlevelerrusr, "\t%ju time%s sctp_senderrors were "
+ p(lowlevelerrusr, "\t%ju time%s sctp_senderrors were "
"caused from a user\n");
- p(sctps_datadropchklmt, "\t%ju number of in data drop%s due to "
+ p(datadropchklmt, "\t%ju number of in data drop%s due to "
"chunk limit reached\n");
- p(sctps_datadroprwnd, "\t%ju number of in data drop%s due to rwnd "
+ p(datadroprwnd, "\t%ju number of in data drop%s due to rwnd "
"limit reached\n");
- p(sctps_ecnereducedcwnd, "\t%ju time%s a ECN reduced "
+ p(ecnereducedcwnd, "\t%ju time%s a ECN reduced "
"the cwnd\n");
- p1a(sctps_vtagexpress, "\t%ju used express lookup via vtag\n");
- p1a(sctps_vtagbogus, "\t%ju collision in express lookup\n");
- p(sctps_primary_randry, "\t%ju time%s the sender ran dry "
+ p1a(vtagexpress, "\t%ju used express lookup via vtag\n");
+ p1a(vtagbogus, "\t%ju collision in express lookup\n");
+ p(primary_randry, "\t%ju time%s the sender ran dry "
"of user data on primary\n");
- p1a(sctps_cmt_randry, "\t%ju same for above\n");
- p(sctps_slowpath_sack, "\t%ju sack%s the slow way\n");
- p(sctps_wu_sacks_sent, "\t%ju window update only sack%s sent\n");
- p(sctps_sends_with_flags, "\t%ju send%s with sinfo_flags !=0\n");
- p(sctps_sends_with_unord, "\t%ju unordered send%s\n");
- p(sctps_sends_with_eof, "\t%ju send%s with EOF flag set\n");
- p(sctps_sends_with_abort, "\t%ju send%s with ABORT flag set\n");
- p(sctps_protocol_drain_calls, "\t%ju time%s protocol drain called\n");
- p(sctps_protocol_drains_done, "\t%ju time%s we did a protocol "
+ p1a(cmt_randry, "\t%ju same for above\n");
+ p(slowpath_sack, "\t%ju sack%s the slow way\n");
+ p(wu_sacks_sent, "\t%ju window update only sack%s sent\n");
+ p(sends_with_flags, "\t%ju send%s with sinfo_flags !=0\n");
+ p(sends_with_unord, "\t%ju unordered send%s\n");
+ p(sends_with_eof, "\t%ju send%s with EOF flag set\n");
+ p(sends_with_abort, "\t%ju send%s with ABORT flag set\n");
+ p(protocol_drain_calls, "\t%ju time%s protocol drain called\n");
+ p(protocol_drains_done, "\t%ju time%s we did a protocol "
"drain\n");
- p(sctps_read_peeks, "\t%ju time%s recv was called with peek\n");
- p(sctps_cached_chk, "\t%ju cached chunk%s used\n");
- p1a(sctps_cached_strmoq, "\t%ju cached stream oq's used\n");
- p(sctps_left_abandon, "\t%ju unread message%s abandonded by close\n");
- p1a(sctps_send_burst_avoid, "\t%ju send burst avoidance, already "
+ p(read_peeks, "\t%ju time%s recv was called with peek\n");
+ p(cached_chk, "\t%ju cached chunk%s used\n");
+ p1a(cached_strmoq, "\t%ju cached stream oq's used\n");
+ p(left_abandon, "\t%ju unread message%s abandonded by close\n");
+ p1a(send_burst_avoid, "\t%ju send burst avoidance, already "
"max burst inflight to net\n");
- p1a(sctps_send_cwnd_avoid, "\t%ju send cwnd full avoidance, already "
+ p1a(send_cwnd_avoid, "\t%ju send cwnd full avoidance, already "
"max burst inflight to net\n");
- p(sctps_fwdtsn_map_over, "\t%ju number of map array over-run%s via "
+ p(fwdtsn_map_over, "\t%ju number of map array over-run%s via "
"fwd-tsn's\n");
-
#undef p
#undef p1a
}
More information about the p4-projects
mailing list