Date: Wed, 29 Jul 2009 02:06:33 GMT From: Gabor Pali <pgj@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 166714 for review Message-ID: <200907290206.n6T26X36079643@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=166714 Change 166714 by pgj@petymeg-current on 2009/07/29 02:05:56 - Add (optional) support for SCTP statistics. - Introduce timestamp_type for representing timestamps. - Create a STATS_ACC() macro to ease creation of accessor functions for larger statistics structures. - Add SCTP_ACC() for even less typing. Affected files ... .. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/Makefile#14 edit .. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.h#41 edit .. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_internal.h#39 edit .. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_stat.c#9 edit .. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_util.c#45 edit Differences ... ==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/Makefile#14 (text+ko) ==== @@ -20,6 +20,8 @@ WITHOUT_MAN= yes +CFLAGS+=-DSCTP + .if ${MK_INET6_SUPPORT} != "no" CFLAGS+= -DINET6 .endif ==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.h#41 (text+ko) ==== @@ -123,6 +123,9 @@ stat_PIM, stat_IGMP, stat_DDP, +#ifdef SCTP + stat_SCTP, +#endif stat_MAX, stat_Invalid, }; @@ -147,6 +150,8 @@ struct bpf_type_list; struct bpf_type_iterator; +struct timestamp_type; + struct stat_type; struct tcp_stat; struct udp_stat; @@ -156,6 +161,9 @@ struct pim_stat; struct igmp_stat; struct ddp_stat; +#ifdef SCTP +struct sctp_stat; +#endif __BEGIN_DECLS const char *netstat_strerror(int); @@ -334,6 +342,9 @@ u_int64_t netstat_bpt_get_hlen(const struct bpf_type *); const char *netstat_bpt_get_pidname(const struct bpf_type *); +/* Timestamp: */ +u_int32_t netstat_ts_get_sec(const struct timestamp_type *); +u_int32_t netstat_ts_get_usec(const struct timestamp_type *); /* Protocol-dependent statistics: */ struct stat_type *netstat_stat_alloc(void); @@ -573,4 +584,142 @@ u_int64_t netstat_ddps_get_encap(const struct ddp_stat *); u_int64_t netstat_ddps_get_cantforward(const struct ddp_stat *); u_int64_t netstat_ddps_get_nosockspace(const struct ddp_stat *); + +#ifdef SCTP +const struct sctp_stat *netstat_get_sctpstats(const struct stat_type *); + +const struct timestamp_type *netstat_sctps_get_discontinuitytime(const struct sctp_stat *); +u_int32_t netstat_sctps_get_currestab(const struct sctp_stat *); +u_int32_t netstat_sctps_get_activeestab(const struct sctp_stat *); +u_int32_t netstat_sctps_get_restartestab(const struct sctp_stat *); +u_int32_t netstat_sctps_get_collisionestab(const struct sctp_stat *); +u_int32_t netstat_sctps_get_passiveestab(const struct sctp_stat *); +u_int32_t netstat_sctps_get_aborted(const struct sctp_stat *); +u_int32_t netstat_sctps_get_shutdown(const struct sctp_stat *); +u_int32_t netstat_sctps_get_outoftheblue(const struct sctp_stat *); +u_int32_t netstat_sctps_get_checksumerrors(const struct sctp_stat *); +u_int32_t netstat_sctps_get_outcontrolchunks(const struct sctp_stat *); +u_int32_t netstat_sctps_get_outorderchunks(const struct sctp_stat *); +u_int32_t netstat_sctps_get_outunorderchunks(const struct sctp_stat *); +u_int32_t netstat_sctps_get_incontrolchunks(const struct sctp_stat *); +u_int32_t netstat_sctps_get_inorderchunks(const struct sctp_stat *); +u_int32_t netstat_sctps_get_inunorderchunks(const struct sctp_stat *); +u_int32_t netstat_sctps_get_fragusrmsgs(const struct sctp_stat *); +u_int32_t netstat_sctps_get_reasmusrmsgs(const struct sctp_stat *); +u_int32_t netstat_sctps_get_outpackets(const struct sctp_stat *); +u_int32_t netstat_sctps_get_inpackets(const struct sctp_stat *); +u_int32_t netstat_sctps_get_recvpackets(const struct sctp_stat *); +u_int32_t netstat_sctps_get_recvdatagrams(const struct sctp_stat *); +u_int32_t netstat_sctps_get_recvpktwithdata(const struct sctp_stat *); +u_int32_t netstat_sctps_get_recvsacks(const struct sctp_stat *); +u_int32_t netstat_sctps_get_recvdata(const struct sctp_stat *); +u_int32_t netstat_sctps_get_recvdupdata(const struct sctp_stat *); +u_int32_t netstat_sctps_get_recvheartbeat(const struct sctp_stat *); +u_int32_t netstat_sctps_get_recvheartbeatack(const struct sctp_stat *); +u_int32_t netstat_sctps_get_recvecne(const struct sctp_stat *); +u_int32_t netstat_sctps_get_recvauth(const struct sctp_stat *); +u_int32_t netstat_sctps_get_recvauthmissing(const struct sctp_stat *); +u_int32_t netstat_sctps_get_recvivalhmacid(const struct sctp_stat *); +u_int32_t netstat_sctps_get_recvivalkeyid(const struct sctp_stat *); +u_int32_t netstat_sctps_get_recvauthfailed(const struct sctp_stat *); +u_int32_t netstat_sctps_get_recvexpress(const struct sctp_stat *); +u_int32_t netstat_sctps_get_recvexpressm(const struct sctp_stat *); +u_int32_t netstat_sctps_get_recvnocrc(const struct sctp_stat *); +u_int32_t netstat_sctps_get_recvswcrc(const struct sctp_stat *); +u_int32_t netstat_sctps_get_recvhwcrc(const struct sctp_stat *); +u_int32_t netstat_sctps_get_sendpackets(const struct sctp_stat *); +u_int32_t netstat_sctps_get_sendsacks(const struct sctp_stat *); +u_int32_t netstat_sctps_get_senddata(const struct sctp_stat *); +u_int32_t netstat_sctps_get_sendretransdata(const struct sctp_stat *); +u_int32_t netstat_sctps_get_sendfastretrans(const struct sctp_stat *); +u_int32_t netstat_sctps_get_sendmultfastretrans(const struct sctp_stat *); +u_int32_t netstat_sctps_get_sendheartbeat(const struct sctp_stat *); +u_int32_t netstat_sctps_get_sendecne(const struct sctp_stat *); +u_int32_t netstat_sctps_get_sendauth(const struct sctp_stat *); +u_int32_t netstat_sctps_get_senderrors(const struct sctp_stat *); +u_int32_t netstat_sctps_get_sendnocrc(const struct sctp_stat *); +u_int32_t netstat_sctps_get_sendswcrc(const struct sctp_stat *); +u_int32_t netstat_sctps_get_sendhwcrc(const struct sctp_stat *); +u_int32_t netstat_sctps_get_pdrpfmbox(const struct sctp_stat *); +u_int32_t netstat_sctps_get_pdrpfehos(const struct sctp_stat *); +u_int32_t netstat_sctps_get_pdrpmbda(const struct sctp_stat *); +u_int32_t netstat_sctps_get_pdrpmbct(const struct sctp_stat *); +u_int32_t netstat_sctps_get_pdrpbwrpt(const struct sctp_stat *); +u_int32_t netstat_sctps_get_pdrpcrupt(const struct sctp_stat *); +u_int32_t netstat_sctps_get_pdrpnedat(const struct sctp_stat *); +u_int32_t netstat_sctps_get_pdrppdbrk(const struct sctp_stat *); +u_int32_t netstat_sctps_get_pdrptsnnf(const struct sctp_stat *); +u_int32_t netstat_sctps_get_pdrpdnfnd(const struct sctp_stat *); +u_int32_t netstat_sctps_get_pdrpdiwnp(const struct sctp_stat *); +u_int32_t netstat_sctps_get_pdrpdizrw(const struct sctp_stat *); +u_int32_t netstat_sctps_get_pdrpbadd(const struct sctp_stat *); +u_int32_t netstat_sctps_get_pdrpmark(const struct sctp_stat *); +u_int32_t netstat_sctps_get_timoiterator(const struct sctp_stat *); +u_int32_t netstat_sctps_get_timodata(const struct sctp_stat *); +u_int32_t netstat_sctps_get_timowindowprobe(const struct sctp_stat *); +u_int32_t netstat_sctps_get_timoinit(const struct sctp_stat *); +u_int32_t netstat_sctps_get_timosack(const struct sctp_stat *); +u_int32_t netstat_sctps_get_timoshutdown(const struct sctp_stat *); +u_int32_t netstat_sctps_get_timoheartbeat(const struct sctp_stat *); +u_int32_t netstat_sctps_get_timocookie(const struct sctp_stat *); +u_int32_t netstat_sctps_get_timosecret(const struct sctp_stat *); +u_int32_t netstat_sctps_get_timopathmtu(const struct sctp_stat *); +u_int32_t netstat_sctps_get_timoshutdownack(const struct sctp_stat *); +u_int32_t netstat_sctps_get_timoshutdownguard(const struct sctp_stat *); +u_int32_t netstat_sctps_get_timostrmrst(const struct sctp_stat *); +u_int32_t netstat_sctps_get_timoearlyfr(const struct sctp_stat *); +u_int32_t netstat_sctps_get_timoasconf(const struct sctp_stat *); +u_int32_t netstat_sctps_get_timodelprim(const struct sctp_stat *); +u_int32_t netstat_sctps_get_timoautoclose(const struct sctp_stat *); +u_int32_t netstat_sctps_get_timoassockill(const struct sctp_stat *); +u_int32_t netstat_sctps_get_timoinpkill(const struct sctp_stat *); +u_int32_t netstat_sctps_get_earlyfrstart(const struct sctp_stat *); +u_int32_t netstat_sctps_get_earlyfrstop(const struct sctp_stat *); +u_int32_t netstat_sctps_get_earlyfrmrkretrans(const struct sctp_stat *); +u_int32_t netstat_sctps_get_earlyfrstpout(const struct sctp_stat *); +u_int32_t netstat_sctps_get_earlyfrstpidsck1(const struct sctp_stat *); +u_int32_t netstat_sctps_get_earlyfrstpidsck2(const struct sctp_stat *); +u_int32_t netstat_sctps_get_earlyfrstpidsck3(const struct sctp_stat *); +u_int32_t netstat_sctps_get_earlyfrstpidsck4(const struct sctp_stat *); +u_int32_t netstat_sctps_get_earlyfrstrid(const struct sctp_stat *); +u_int32_t netstat_sctps_get_earlyfrstrout(const struct sctp_stat *); +u_int32_t netstat_sctps_get_earlyfrstrtmr(const struct sctp_stat *); +u_int32_t netstat_sctps_get_hdrops(const struct sctp_stat *); +u_int32_t netstat_sctps_get_badsum(const struct sctp_stat *); +u_int32_t netstat_sctps_get_noport(const struct sctp_stat *); +u_int32_t netstat_sctps_get_badvtag(const struct sctp_stat *); +u_int32_t netstat_sctps_get_badsid(const struct sctp_stat *); +u_int32_t netstat_sctps_get_nomem(const struct sctp_stat *); +u_int32_t netstat_sctps_get_fastretransinrtt(const struct sctp_stat *); +u_int32_t netstat_sctps_get_markedretrans(const struct sctp_stat *); +u_int32_t netstat_sctps_get_naglesent(const struct sctp_stat *); +u_int32_t netstat_sctps_get_naglequeued(const struct sctp_stat *); +u_int32_t netstat_sctps_get_maxburstqueued(const struct sctp_stat *); +u_int32_t netstat_sctps_get_ifnomemqueued(const struct sctp_stat *); +u_int32_t netstat_sctps_get_windowprobed(const struct sctp_stat *); +u_int32_t netstat_sctps_get_lowlevelerr(const struct sctp_stat *); +u_int32_t netstat_sctps_get_lowlevelerrusr(const struct sctp_stat *); +u_int32_t netstat_sctps_get_datadropchklmt(const struct sctp_stat *); +u_int32_t netstat_sctps_get_datadroprwnd(const struct sctp_stat *); +u_int32_t netstat_sctps_get_ecnereducedcwnd(const struct sctp_stat *); +u_int32_t netstat_sctps_get_vtagexpress(const struct sctp_stat *); +u_int32_t netstat_sctps_get_vtagbogus(const struct sctp_stat *); +u_int32_t netstat_sctps_get_primary_randry(const struct sctp_stat *); +u_int32_t netstat_sctps_get_cmt_randry(const struct sctp_stat *); +u_int32_t netstat_sctps_get_slowpath_sack(const struct sctp_stat *); +u_int32_t netstat_sctps_get_wu_sacks_sent(const struct sctp_stat *); +u_int32_t netstat_sctps_get_sends_with_flags(const struct sctp_stat *); +u_int32_t netstat_sctps_get_sends_with_unord(const struct sctp_stat *); +u_int32_t netstat_sctps_get_sends_with_eof(const struct sctp_stat *); +u_int32_t netstat_sctps_get_sends_with_abort(const struct sctp_stat *); +u_int32_t netstat_sctps_get_protocol_drain_calls(const struct sctp_stat *); +u_int32_t netstat_sctps_get_protocol_drains_done(const struct sctp_stat *); +u_int32_t netstat_sctps_get_read_peeks(const struct sctp_stat *); +u_int32_t netstat_sctps_get_cached_chk(const struct sctp_stat *); +u_int32_t netstat_sctps_get_cached_strmoq(const struct sctp_stat *); +u_int32_t netstat_sctps_get_left_abandon(const struct sctp_stat *); +u_int32_t netstat_sctps_get_send_burst_avoid(const struct sctp_stat *); +u_int32_t netstat_sctps_get_send_cwnd_avoid(const struct sctp_stat *); +u_int32_t netstat_sctps_get_fwdtsn_map_over(const struct sctp_stat *); +#endif /* !SCTP */ #endif /* !_NETSTAT_H_ */ ==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_internal.h#39 (text+ko) ==== @@ -51,6 +51,9 @@ #include <netinet/igmp_var.h> #include <netatalk/at.h> #include <netatalk/ddp_var.h> +#ifdef SCTP +#include <netinet/sctp_uio.h> +#endif #include "netstat.h" @@ -320,6 +323,18 @@ struct ddpstat s; }; +#ifdef SCTP +struct sctp_stat { + struct sctpstat s; +}; +#endif + +/* Timestamp type. */ +struct timestamp_type { + u_int32_t ts_sec; + u_int32_t ts_usec; +}; + int kread_data(kvm_t *kvm, u_long kvm_pointer, void *address, size_t size); int kread_string(kvm_t *kvm, u_long kvm_pointer, char *buffer, int buflen); ==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_stat.c#9 (text+ko) ==== @@ -65,6 +65,9 @@ { PIMSTAT_VERSION, "net.inet.pim.stats", "_pimstat" }, { IGMPSTAT_VERSION, "net.inet.igmp.stats", "_igmpstat" }, { DDPSTAT_VERSION, "net.ddp.stats", "_ddpstat" }, +#ifdef SCTP + { SCTPSTAT_VERSION, "net.inet.sctp.stats", "_sctpstat" }, +#endif }; int ==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_util.c#45 (text+ko) ==== @@ -1227,6 +1227,14 @@ return (sttp->stt_error); } + +#define STATS_ACC(returns, stats, field) \ +returns \ +netstat_##stats##s_get_##field(const struct stats##_stat *a) \ +{ \ + return (a->s.stats##s_##field); \ +} + const struct tcp_stat * netstat_get_tcpstats(const struct stat_type *sttp) { @@ -2527,6 +2535,170 @@ return (dsp->s.ddps_nosockspace); } +u_int32_t +netstat_ts_get_sec(const struct timestamp_type *tsp) +{ + return (tsp->ts_sec); +} + +u_int32_t +netstat_ts_get_usec(const struct timestamp_type *tsp) +{ + return (tsp->ts_usec); +} + +#ifdef SCTP +const struct sctp_stat * +netstat_get_sctpstats(const struct stat_type *sttp) +{ + if (sttp->stt_type == stat_SCTP) + return ((const struct sctp_stat *)sttp->stt_data); + return (NULL); +} + +#define SCTP_ACC(field) \ + STATS_ACC(u_int32_t,sctp,field) + +const struct timestamp_type * +netstat_sctps_get_discontinuitytime(const struct sctp_stat *ssp) +{ + return ((const struct timestamp_type *)&ssp->s.sctps_discontinuitytime); +} + +SCTP_ACC(currestab); +SCTP_ACC(activeestab); +SCTP_ACC(restartestab); +SCTP_ACC(collisionestab); +SCTP_ACC(passiveestab); +SCTP_ACC(aborted); +SCTP_ACC(shutdown); +SCTP_ACC(outoftheblue); +SCTP_ACC(checksumerrors); +SCTP_ACC(outcontrolchunks); +SCTP_ACC(outorderchunks); +SCTP_ACC(outunorderchunks); +SCTP_ACC(incontrolchunks); +SCTP_ACC(inorderchunks); +SCTP_ACC(inunorderchunks); +SCTP_ACC(fragusrmsgs); +SCTP_ACC(reasmusrmsgs); +SCTP_ACC(outpackets); +SCTP_ACC(inpackets); +SCTP_ACC(recvpackets); +SCTP_ACC(recvdatagrams); +SCTP_ACC(recvpktwithdata); +SCTP_ACC(recvsacks); +SCTP_ACC(recvdata); +SCTP_ACC(recvdupdata); +SCTP_ACC(recvheartbeat); +SCTP_ACC(recvheartbeatack); +SCTP_ACC(recvecne); +SCTP_ACC(recvauth); +SCTP_ACC(recvauthmissing); +SCTP_ACC(recvivalhmacid); +SCTP_ACC(recvivalkeyid); +SCTP_ACC(recvauthfailed); +SCTP_ACC(recvexpress); +SCTP_ACC(recvexpressm); +SCTP_ACC(recvnocrc); +SCTP_ACC(recvswcrc); +SCTP_ACC(recvhwcrc); +SCTP_ACC(sendpackets); +SCTP_ACC(sendsacks); +SCTP_ACC(senddata); +SCTP_ACC(sendretransdata); +SCTP_ACC(sendfastretrans); +SCTP_ACC(sendmultfastretrans); +SCTP_ACC(sendheartbeat); +SCTP_ACC(sendecne); +SCTP_ACC(sendauth); +SCTP_ACC(senderrors); +SCTP_ACC(sendnocrc); +SCTP_ACC(sendswcrc); +SCTP_ACC(sendhwcrc); +SCTP_ACC(pdrpfmbox); +SCTP_ACC(pdrpfehos); +SCTP_ACC(pdrpmbda); +SCTP_ACC(pdrpmbct); +SCTP_ACC(pdrpbwrpt); +SCTP_ACC(pdrpcrupt); +SCTP_ACC(pdrpnedat); +SCTP_ACC(pdrppdbrk); +SCTP_ACC(pdrptsnnf); +SCTP_ACC(pdrpdnfnd); +SCTP_ACC(pdrpdiwnp); +SCTP_ACC(pdrpdizrw); +SCTP_ACC(pdrpbadd); +SCTP_ACC(pdrpmark); +SCTP_ACC(timoiterator); +SCTP_ACC(timodata); +SCTP_ACC(timowindowprobe); +SCTP_ACC(timoinit); +SCTP_ACC(timosack); +SCTP_ACC(timoshutdown); +SCTP_ACC(timoheartbeat); +SCTP_ACC(timocookie); +SCTP_ACC(timosecret); +SCTP_ACC(timopathmtu); +SCTP_ACC(timoshutdownack); +SCTP_ACC(timoshutdownguard); +SCTP_ACC(timostrmrst); +SCTP_ACC(timoearlyfr); +SCTP_ACC(timoasconf); +SCTP_ACC(timodelprim); +SCTP_ACC(timoautoclose); +SCTP_ACC(timoassockill); +SCTP_ACC(timoinpkill); +SCTP_ACC(earlyfrstart); +SCTP_ACC(earlyfrstop); +SCTP_ACC(earlyfrmrkretrans); +SCTP_ACC(earlyfrstpout); +SCTP_ACC(earlyfrstpidsck1); +SCTP_ACC(earlyfrstpidsck2); +SCTP_ACC(earlyfrstpidsck3); +SCTP_ACC(earlyfrstpidsck4); +SCTP_ACC(earlyfrstrid); +SCTP_ACC(earlyfrstrout); +SCTP_ACC(earlyfrstrtmr); +SCTP_ACC(hdrops); +SCTP_ACC(badsum); +SCTP_ACC(noport); +SCTP_ACC(badvtag); +SCTP_ACC(badsid); +SCTP_ACC(nomem); +SCTP_ACC(fastretransinrtt); +SCTP_ACC(markedretrans); +SCTP_ACC(naglesent); +SCTP_ACC(naglequeued); +SCTP_ACC(maxburstqueued); +SCTP_ACC(ifnomemqueued); +SCTP_ACC(windowprobed); +SCTP_ACC(lowlevelerr); +SCTP_ACC(lowlevelerrusr); +SCTP_ACC(datadropchklmt); +SCTP_ACC(datadroprwnd); +SCTP_ACC(ecnereducedcwnd); +SCTP_ACC(vtagexpress); +SCTP_ACC(vtagbogus); +SCTP_ACC(primary_randry); +SCTP_ACC(cmt_randry); +SCTP_ACC(slowpath_sack); +SCTP_ACC(wu_sacks_sent); +SCTP_ACC(sends_with_flags); +SCTP_ACC(sends_with_unord); +SCTP_ACC(sends_with_eof); +SCTP_ACC(sends_with_abort); +SCTP_ACC(protocol_drain_calls); +SCTP_ACC(protocol_drains_done); +SCTP_ACC(read_peeks); +SCTP_ACC(cached_chk); +SCTP_ACC(cached_strmoq); +SCTP_ACC(left_abandon); +SCTP_ACC(send_burst_avoid); +SCTP_ACC(send_cwnd_avoid); +SCTP_ACC(fwdtsn_map_over); +#endif /* !SCTP */ + static const char *icmpnames[ICMP_MAXTYPE + 1] = { "echo reply", /* RFC 792 */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907290206.n6T26X36079643>