Date: Mon, 27 Jul 2009 14:47:49 GMT From: Gabor Pali <pgj@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 166623 for review Message-ID: <200907271447.n6RElnS4089856@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=166623 Change 166623 by pgj@petymeg-current on 2009/07/27 14:47:10 Add support for UDP statistics. Affected files ... .. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.h#34 edit .. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_internal.h#32 edit .. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_stat.c#2 edit .. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_util.c#38 edit Differences ... ==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.h#34 (text+ko) ==== @@ -116,6 +116,7 @@ enum stat { stat_TCP = 0, + stat_UDP, stat_MAX, stat_Invalid, }; @@ -142,6 +143,7 @@ struct stat_type; struct tcp_stat; +struct udp_stat; __BEGIN_DECLS const char *netstat_strerror(int); @@ -425,4 +427,22 @@ u_int64_t netstat_tcps_get_ecn_ect1(const struct tcp_stat *); u_int64_t netstat_tcps_get_ecn_shs(const struct tcp_stat *); u_int64_t netstat_tcps_get_ecn_rcwnd(const struct tcp_stat *); + +const struct udp_stat *netstat_get_udpstats(const struct stat_type *); + +u_int64_t netstat_udps_get_ipackets(const struct udp_stat *); +u_int64_t netstat_udps_get_hdrops(const struct udp_stat *); +u_int64_t netstat_udps_get_badsum(const struct udp_stat *); +u_int64_t netstat_udps_get_nosum(const struct udp_stat *); +u_int64_t netstat_udps_get_badlen(const struct udp_stat *); +u_int64_t netstat_udps_get_noport(const struct udp_stat *); +u_int64_t netstat_udps_get_noportbcast(const struct udp_stat *); +u_int64_t netstat_udps_get_fullsock(const struct udp_stat *); +u_int64_t netstat_udps_get_pcbcachemiss(const struct udp_stat *); +u_int64_t netstat_udps_get_pcbhashmiss(const struct udp_stat *); +u_int64_t netstat_udps_get_delivered(const struct udp_stat *); +u_int64_t netstat_udps_get_opackets(const struct udp_stat *); +u_int64_t netstat_udps_get_fastout(const struct udp_stat *); +u_int64_t netstat_udps_get_noportmcast(const struct udp_stat *); +u_int64_t netstat_udps_get_filtermcast(const struct udp_stat *); #endif /* !_NETSTAT_H_ */ ==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_internal.h#32 (text+ko) ==== @@ -38,8 +38,12 @@ #include <kvm.h> #include <net/if.h> #include <netinet/in.h> +#include <netinet/ip.h> +#include <netinet/ip_var.h> #include <netinet/in_pcb.h> #include <netinet/tcp_var.h> +#include <netinet/udp.h> +#include <netinet/udp_var.h> #include "netstat.h" @@ -281,6 +285,10 @@ struct tcpstat s; }; +struct udp_stat { + struct udpstat s; +}; + 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#2 (text+ko) ==== @@ -29,7 +29,12 @@ #include <sys/types.h> #include <sys/sysctl.h> +#include <netinet/in.h> +#include <netinet/ip.h> +#include <netinet/ip_var.h> #include <netinet/tcp_var.h> +#include <netinet/udp.h> +#include <netinet/udp_var.h> #include <err.h> #include <kvm.h> @@ -50,6 +55,7 @@ const char *kvm; } stat_info [] = { { TCPSTAT_VERSION, "net.inet.tcp.stats", "_tcpstat" }, + { UDPSTAT_VERSION, "net.inet.udp.stats", "_udpstat" }, }; int @@ -60,6 +66,7 @@ char symbuf[64]; struct stat_header head; + struct udpstat *u; int res; if (type >= stat_MAX) { @@ -109,6 +116,15 @@ } memcpy(sttp->stt_data, buffer, head.sth_len); + + if (sttp->stt_type == stat_UDP) { + u = (struct udpstat *)sttp->stt_data; + u->udps_delivered = + u->udps_ipackets - u->udps_hdrops - u->udps_badlen - + u->udps_badsum - u->udps_noport - u->udps_noportbcast - + u->udps_fullsock; + } + return (0); } ==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_util.c#38 (text+ko) ==== @@ -1794,6 +1794,105 @@ return (tsp->s.tcps_ecn_rcwnd); } +const struct udp_stat * +netstat_get_udpstats(const struct stat_type *sttp) +{ + if (sttp->stt_type == stat_UDP) { + return ((const struct udp_stat *) sttp->stt_data); + } + return (NULL); +} + +u_int64_t +netstat_udps_get_ipackets(const struct udp_stat *usp) +{ + return (usp->s.udps_ipackets); +} + +u_int64_t +netstat_udps_get_hdrops(const struct udp_stat *usp) +{ + return (usp->s.udps_hdrops); +} + +u_int64_t +netstat_udps_get_badsum(const struct udp_stat *usp) +{ + return (usp->s.udps_badsum); +} + +u_int64_t +netstat_udps_get_nosum(const struct udp_stat *usp) +{ + return (usp->s.udps_nosum); +} + +u_int64_t +netstat_udps_get_badlen(const struct udp_stat *usp) +{ + return (usp->s.udps_badlen); +} + +u_int64_t +netstat_udps_get_noport(const struct udp_stat *usp) +{ + return (usp->s.udps_noport); +} + +u_int64_t +netstat_udps_get_noportbcast(const struct udp_stat *usp) +{ + return (usp->s.udps_noportbcast); +} + +u_int64_t +netstat_udps_get_fullsock(const struct udp_stat *usp) +{ + return (usp->s.udps_fullsock); +} + +u_int64_t +netstat_udps_get_pcbcachemiss(const struct udp_stat *usp) +{ + return (usp->s.udpps_pcbcachemiss); +} + +u_int64_t +netstat_udps_get_pcbhashmiss(const struct udp_stat *usp) +{ + return (usp->s.udpps_pcbhashmiss); +} + +u_int64_t +netstat_udps_get_delivered(const struct udp_stat *usp) +{ + return (usp->s.udps_delivered); +} + +u_int64_t +netstat_udps_get_opackets(const struct udp_stat *usp) +{ + return (usp->s.udps_opackets); +} + +u_int64_t +netstat_udps_get_fastout(const struct udp_stat *usp) +{ + return (usp->s.udps_fastout); +} + +u_int64_t +netstat_udps_get_noportmcast(const struct udp_stat *usp) +{ + return (usp->s.udps_noportmcast); +} + +u_int64_t +netstat_udps_get_filtermcast(const struct udp_stat *usp) +{ + return (usp->s.udps_filtermcast); +} + const char * routename(in_addr_t in, int numeric)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907271447.n6RElnS4089856>