Date: Fri, 31 Jul 2009 20:24:56 GMT From: Gabor Pali <pgj@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 166869 for review Message-ID: <200907312024.n6VKOuKZ070850@repoman.freebsd.org>
index | next in thread | raw e-mail
http://perforce.freebsd.org/chv.cgi?CH=166869 Change 166869 by pgj@petymeg-current on 2009/07/31 20:24:29 Add support for IP6 statistics. Affected files ... .. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.h#54 edit .. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_internal.h#51 edit .. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_stat.c#21 edit .. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_util.c#59 edit Differences ... ==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.h#54 (text+ko) ==== @@ -99,6 +99,10 @@ #define NETSTAT_IPSEC_AH_HIST_MAX 256 #define NETSTAT_IPSEC_IPCOMP_HIST_MAX 256 +/* IP6: */ +#define NETSTAT_IP6_NHIST_MAX 256 +#define NETSTAT_IP6_MBUF_MAX 32 +#define NETSTAT_IP6_IF_MAX 16 /* Enum for TCP states: */ enum tcp_state { @@ -152,6 +156,7 @@ stat_SCTP, #endif #ifdef INET6 + stat_IP6, stat_ICMP6, stat_PIM6, stat_RIP6, @@ -207,6 +212,7 @@ struct sctp_stat; #endif #ifdef INET6 +struct ip6_stat; struct icmp6_stat; struct pim6_stat; struct rip6_stat; @@ -785,6 +791,49 @@ #endif /* !SCTP */ #ifdef INET6 +const struct ip6_stat *netstat_get_ip6stats(const struct stat_type *); +const char *netstat_ip6_nhist_name(int); +const char *netstat_ip6_srcrule_name(int); + +u_int64_t netstat_ip6s_get_total(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_tooshort(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_toosmall(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_fragments(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_fragdropped(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_fragtimeout(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_fragoverflow(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_forward(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_cantforward(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_redirectsent(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_delivered(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_localout(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_odropped(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_reassembled(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_fragmented(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_ofragments(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_cantfrag(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_badoptions(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_noroute(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_badvers(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_rawout(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_badscope(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_notmember(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_nxthist(const struct ip6_stat *, int); +u_int64_t netstat_ip6s_get_m1(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_m2m(const struct ip6_stat *, int); +u_int64_t netstat_ip6s_get_mext1(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_mext2m(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_exthdrtoolong(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_nogif(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_toomanyhdr(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_sources_none(const struct ip6_stat *); +u_int64_t netstat_ip6s_get_sources_sameif(const struct ip6_stat *, int); +u_int64_t netstat_ip6s_get_sources_otherif(const struct ip6_stat *, int); +u_int64_t netstat_ip6s_get_sources_samescope(const struct ip6_stat *, int); +u_int64_t netstat_ip6s_get_sources_otherscope(const struct ip6_stat *, int); +u_int64_t netstat_ip6s_get_sources_deprecated(const struct ip6_stat *, int); +u_int64_t netstat_ip6s_get_sources_rule(const struct ip6_stat *, int); + const struct icmp6_stat *netstat_get_icmp6stats(const struct stat_type *); u_int64_t netstat_icmp6s_get_error(const struct icmp6_stat *); ==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_internal.h#51 (text+ko) ==== @@ -55,6 +55,7 @@ #include <netinet/sctp_uio.h> #endif #ifdef INET6 +#include <netinet6/ip6_var.h> #include <netinet/icmp6.h> #include <netinet6/pim6_var.h> #include <netinet6/raw_ip6.h> @@ -348,6 +349,10 @@ #endif #ifdef INET6 +struct ip6_stat { + struct ip6stat s; +}; + struct icmp6_stat { struct icmp6stat s; }; ==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_stat.c#21 (text+ko) ==== @@ -77,6 +77,7 @@ { SCTPSTAT_VERSION, "net.inet.sctp.stats", "_sctpstat" }, #endif #ifdef INET6 + { IP6STAT_VERSION, "net.inet6.ip6.stats", "_ip6stat" }, { ICMP6STAT_VERSION, "net.inet6.icmp6.stats", "_icmp6stat" }, { PIM6STAT_VERSION, "net.inet6.pim.stats", "_pim6stat" }, { RIP6STAT_VERSION, "net.inet6.ip6.rip6stats", "_rip6stat" }, ==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_util.c#59 (text+ko) ==== @@ -1692,6 +1692,54 @@ #endif /* !SCTP */ #ifdef INET6 +#define IP6_ACC(field) \ + STATS_ACCX(u_int64_t,ip6,field,ip6s_##field) + +#define IP6_ACCA(field,size) \ + STATS_ACCXA(u_int64_t,ip6,field,ip6s_##field,size) + +STATS_GET(ip6,IP6); +IP6_ACC(total); +IP6_ACC(tooshort); +IP6_ACC(toosmall); +IP6_ACC(fragments); +IP6_ACC(fragdropped); +IP6_ACC(fragtimeout); +IP6_ACC(fragoverflow); +IP6_ACC(forward); +IP6_ACC(cantforward); +IP6_ACC(redirectsent); +IP6_ACC(delivered); +IP6_ACC(localout); +IP6_ACC(odropped); +IP6_ACC(reassembled); +IP6_ACC(fragmented); +IP6_ACC(ofragments); +IP6_ACC(cantfrag); +IP6_ACC(badoptions); +IP6_ACC(noroute); +IP6_ACC(badvers); +IP6_ACC(rawout); +IP6_ACC(badscope); +IP6_ACC(notmember); +IP6_ACCA(nxthist,NETSTAT_IP6_NHIST_MAX); +IP6_ACC(m1); +IP6_ACCA(m2m,NETSTAT_IP6_MBUF_MAX); +IP6_ACC(mext1); +IP6_ACC(mext2m); +IP6_ACC(exthdrtoolong); +IP6_ACC(nogif); +IP6_ACC(toomanyhdr); +IP6_ACC(sources_none); +IP6_ACCA(sources_sameif,NETSTAT_IP6_IF_MAX); +IP6_ACCA(sources_otherif,NETSTAT_IP6_IF_MAX); +IP6_ACCA(sources_samescope,NETSTAT_IP6_IF_MAX); +IP6_ACCA(sources_otherscope,NETSTAT_IP6_IF_MAX); +IP6_ACCA(sources_deprecated,NETSTAT_IP6_IF_MAX); +IP6_ACCA(sources_rule,NETSTAT_IP6_IF_MAX); +#undef IP6_ACC +#undef IP6_ACCA + #define ICMP6_ACC(field) \ STATS_ACCX(u_int64_t,icmp6,field,icp6s_##field) @@ -2486,6 +2534,301 @@ return (resolve_val2str_name(proto, ipsec_ipcompnames)); } +static const char *ip6nh[] = { + "hop by hop", + "ICMP", + "IGMP", + "#3", + "IP", + "#5", + "TCP", + "#7", + "#8", + "#9", + "#10", + "#11", + "#12", + "#13", + "#14", + "#15", + "#16", + "UDP", + "#18", + "#19", + "#20", + "#21", + "IDP", + "#23", + "#24", + "#25", + "#26", + "#27", + "#28", + "TP", + "#30", + "#31", + "#32", + "#33", + "#34", + "#35", + "#36", + "#37", + "#38", + "#39", + "#40", + "IP6", + "#42", + "routing", + "fragment", + "#45", + "#46", + "#47", + "#48", + "#49", + "ESP", + "AH", + "#52", + "#53", + "#54", + "#55", + "#56", + "#57", + "ICMP6", + "no next header", + "destination option", + "#61", + "mobility", + "#63", + "#64", + "#65", + "#66", + "#67", + "#68", + "#69", + "#70", + "#71", + "#72", + "#73", + "#74", + "#75", + "#76", + "#77", + "#78", + "#79", + "ISOIP", + "#81", + "#82", + "#83", + "#84", + "#85", + "#86", + "#87", + "#88", + "OSPF", + "#80", + "#91", + "#92", + "#93", + "#94", + "#95", + "#96", + "Ethernet", + "#98", + "#99", + "#100", + "#101", + "#102", + "PIM", + "#104", + "#105", + "#106", + "#107", + "#108", + "#109", + "#110", + "#111", + "#112", + "#113", + "#114", + "#115", + "#116", + "#117", + "#118", + "#119", + "#120", + "#121", + "#122", + "#123", + "#124", + "#125", + "#126", + "#127", + "#128", + "#129", + "#130", + "#131", + "#132", + "#133", + "#134", + "#135", + "#136", + "#137", + "#138", + "#139", + "#140", + "#141", + "#142", + "#143", + "#144", + "#145", + "#146", + "#147", + "#148", + "#149", + "#150", + "#151", + "#152", + "#153", + "#154", + "#155", + "#156", + "#157", + "#158", + "#159", + "#160", + "#161", + "#162", + "#163", + "#164", + "#165", + "#166", + "#167", + "#168", + "#169", + "#170", + "#171", + "#172", + "#173", + "#174", + "#175", + "#176", + "#177", + "#178", + "#179", + "#180", + "#181", + "#182", + "#183", + "#184", + "#185", + "#186", + "#187", + "#188", + "#189", + "#180", + "#191", + "#192", + "#193", + "#194", + "#195", + "#196", + "#197", + "#198", + "#199", + "#200", + "#201", + "#202", + "#203", + "#204", + "#205", + "#206", + "#207", + "#208", + "#209", + "#210", + "#211", + "#212", + "#213", + "#214", + "#215", + "#216", + "#217", + "#218", + "#219", + "#220", + "#221", + "#222", + "#223", + "#224", + "#225", + "#226", + "#227", + "#228", + "#229", + "#230", + "#231", + "#232", + "#233", + "#234", + "#235", + "#236", + "#237", + "#238", + "#239", + "#240", + "#241", + "#242", + "#243", + "#244", + "#245", + "#246", + "#247", + "#248", + "#249", + "#250", + "#251", + "#252", + "#253", + "#254", + "#255", +}; + +const char * +netstat_ip6_nhist_name(int i) +{ + if (0 <= i && i < SizeOf(ip6nh)) + return (ip6nh[i]); + return (NULL); +} + +static const char *srcrule[] = { + "first candidate", + "same address", + "appropriate scope", + "deprecated address", + "home address", + "outgoing interface", + "matching label", + "public/temporary address", + "alive interface", + "preferred interface", + "rule #10", + "rule #11", + "rule #12", + "rule #13", + "longest match", + "rule #15", +}; + + +const char * +netstat_ip6_srcrule_name(int i) +{ + if (0 <= i && i < SizeOf(srcrule)) + return (srcrule[i]); + return (NULL); +} + const char * routename(in_addr_t in, int numeric) {help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907312024.n6VKOuKZ070850>
