From owner-p4-projects@FreeBSD.ORG Mon Jul 27 14:47:50 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4738E1065672; Mon, 27 Jul 2009 14:47:50 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 07390106566B for ; Mon, 27 Jul 2009 14:47:50 +0000 (UTC) (envelope-from pgj@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id E8F538FC19 for ; Mon, 27 Jul 2009 14:47:49 +0000 (UTC) (envelope-from pgj@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n6RElnPD089858 for ; Mon, 27 Jul 2009 14:47:49 GMT (envelope-from pgj@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n6RElnS4089856 for perforce@freebsd.org; Mon, 27 Jul 2009 14:47:49 GMT (envelope-from pgj@FreeBSD.org) Date: Mon, 27 Jul 2009 14:47:49 GMT Message-Id: <200907271447.n6RElnS4089856@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to pgj@FreeBSD.org using -f From: Gabor Pali To: Perforce Change Reviews Cc: Subject: PERFORCE change 166623 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Jul 2009 14:47:51 -0000 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 #include #include +#include +#include #include #include +#include +#include #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 #include +#include +#include +#include #include +#include +#include #include #include @@ -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)