diff --git a/sys/conf/options b/sys/conf/options --- a/sys/conf/options +++ b/sys/conf/options @@ -145,6 +145,7 @@ IFLIB opt_iflib.h KDTRACE_HOOKS opt_global.h KDTRACE_FRAME opt_kdtrace.h +KDTRACE_NO_MIB_SDT opt_global.h KN_HASHSIZE opt_kqueue.h KSTACK_MAX_PAGES KSTACK_PAGES diff --git a/sys/netinet/icmp6.h b/sys/netinet/icmp6.h --- a/sys/netinet/icmp6.h +++ b/sys/netinet/icmp6.h @@ -572,22 +572,6 @@ * Variables related to this implementation * of the internet control message protocol version 6. */ -struct icmp6errstat { - uint64_t icp6errs_dst_unreach_noroute; - uint64_t icp6errs_dst_unreach_admin; - uint64_t icp6errs_dst_unreach_beyondscope; - uint64_t icp6errs_dst_unreach_addr; - uint64_t icp6errs_dst_unreach_noport; - uint64_t icp6errs_packet_too_big; - uint64_t icp6errs_time_exceed_transit; - uint64_t icp6errs_time_exceed_reassembly; - uint64_t icp6errs_paramprob_header; - uint64_t icp6errs_paramprob_nextheader; - uint64_t icp6errs_paramprob_option; - uint64_t icp6errs_redirect; /* we regard redirect as an error here */ - uint64_t icp6errs_unknown; -}; - struct icmp6stat { /* statistics related to icmp6 packets generated */ uint64_t icp6s_error; /* # of calls to icmp6_error */ @@ -607,25 +591,19 @@ uint64_t icp6s_reflect; uint64_t icp6s_inhist[256]; uint64_t icp6s_nd_toomanyopt; /* too many ND options */ - struct icmp6errstat icp6s_outerrhist; -#define icp6s_odst_unreach_noroute \ - icp6s_outerrhist.icp6errs_dst_unreach_noroute -#define icp6s_odst_unreach_admin icp6s_outerrhist.icp6errs_dst_unreach_admin -#define icp6s_odst_unreach_beyondscope \ - icp6s_outerrhist.icp6errs_dst_unreach_beyondscope -#define icp6s_odst_unreach_addr icp6s_outerrhist.icp6errs_dst_unreach_addr -#define icp6s_odst_unreach_noport icp6s_outerrhist.icp6errs_dst_unreach_noport -#define icp6s_opacket_too_big icp6s_outerrhist.icp6errs_packet_too_big -#define icp6s_otime_exceed_transit \ - icp6s_outerrhist.icp6errs_time_exceed_transit -#define icp6s_otime_exceed_reassembly \ - icp6s_outerrhist.icp6errs_time_exceed_reassembly -#define icp6s_oparamprob_header icp6s_outerrhist.icp6errs_paramprob_header -#define icp6s_oparamprob_nextheader \ - icp6s_outerrhist.icp6errs_paramprob_nextheader -#define icp6s_oparamprob_option icp6s_outerrhist.icp6errs_paramprob_option -#define icp6s_oredirect icp6s_outerrhist.icp6errs_redirect -#define icp6s_ounknown icp6s_outerrhist.icp6errs_unknown + uint64_t icp6s_odst_unreach_noroute; + uint64_t icp6s_odst_unreach_admin; + uint64_t icp6s_odst_unreach_beyondscope; + uint64_t icp6s_odst_unreach_addr; + uint64_t icp6s_odst_unreach_noport; + uint64_t icp6s_opacket_too_big; + uint64_t icp6s_otime_exceed_transit; + uint64_t icp6s_otime_exceed_reassembly; + uint64_t icp6s_oparamprob_header; + uint64_t icp6s_oparamprob_nextheader; + uint64_t icp6s_oparamprob_option; + uint64_t icp6s_oredirect; + uint64_t icp6s_ounknown; uint64_t icp6s_pmtuchg; /* path MTU changes */ uint64_t icp6s_nd_badopt; /* bad ND options */ uint64_t icp6s_badns; /* bad neighbor solicitation */ @@ -643,6 +621,7 @@ #ifdef _KERNEL #include +#include #ifdef SYSCTL_DECL SYSCTL_DECL(_net_inet6_icmp6); @@ -653,16 +632,28 @@ * In-kernel consumers can use these accessor macros directly to update * stats. */ -#define ICMP6STAT_ADD(name, val) \ - VNET_PCPUSTAT_ADD(struct icmp6stat, icmp6stat, name, (val)) -#define ICMP6STAT_INC(name) ICMP6STAT_ADD(name, 1) +#define ICMP6STAT_ADD(name, val) \ + do { \ + MIB_SDT_PROBE1(icmp6, count, name, (val)); \ + VNET_PCPUSTAT_ADD(struct icmp6stat, icmp6stat, name, (val)); \ + } while (0) +#define ICMP6STAT_INC(name) ICMP6STAT_ADD(name, 1) +#define ICMP6STAT_INC2(name, type) \ + do { \ + MIB_SDT_PROBE2(icmp6, count, name, 1, type); \ + VNET_PCPUSTAT_ADD(struct icmp6stat, icmp6stat, name, 1); \ + } while (0) /* * Kernel module consumers must use this accessor macro. */ void kmod_icmp6stat_inc(int statnum); -#define KMOD_ICMP6STAT_INC(name) \ - kmod_icmp6stat_inc(offsetof(struct icmp6stat, name) / sizeof(uint64_t)) +#define KMOD_ICMP6STAT_INC(name) \ + do { \ + MIB_SDT_PROBE1(icmp6, count, name, 1); \ + kmod_icmp6stat_inc( \ + offsetof(struct icmp6stat, name) / sizeof(uint64_t)); \ + } while (0) #endif /* diff --git a/sys/netinet/icmp_var.h b/sys/netinet/icmp_var.h --- a/sys/netinet/icmp_var.h +++ b/sys/netinet/icmp_var.h @@ -57,22 +57,36 @@ #ifdef _KERNEL #include +#include VNET_PCPUSTAT_DECLARE(struct icmpstat, icmpstat); /* * In-kernel consumers can use these accessor macros directly to update * stats. */ -#define ICMPSTAT_ADD(name, val) \ - VNET_PCPUSTAT_ADD(struct icmpstat, icmpstat, name, (val)) +#define ICMPSTAT_ADD(name, val) \ + do { \ + MIB_SDT_PROBE1(icmp, count, name, (val)); \ + VNET_PCPUSTAT_ADD(struct icmpstat, icmpstat, name, (val)); \ + } while (0) + #define ICMPSTAT_INC(name) ICMPSTAT_ADD(name, 1) +#define ICMPSTAT_INC2(name, type) \ + do { \ + MIB_SDT_PROBE2(icmp, count, name, 1, type); \ + VNET_PCPUSTAT_ADD(struct icmpstat, icmpstat, name[type], 1); \ + } while (0) /* * Kernel module consumers must use this accessor macro. */ void kmod_icmpstat_inc(int statnum); -#define KMOD_ICMPSTAT_INC(name) \ - kmod_icmpstat_inc(offsetof(struct icmpstat, name) / sizeof(uint64_t)) +#define KMOD_ICMPSTAT_INC(name) \ + do { \ + MIB_SDT_PROBE1(icmp, count, name, 1); \ + kmod_icmpstat_inc( \ + offsetof(struct icmpstat, name) / sizeof(uint64_t)); \ + } while (0) #endif /* diff --git a/sys/netinet/in_kdtrace.h b/sys/netinet/in_kdtrace.h --- a/sys/netinet/in_kdtrace.h +++ b/sys/netinet/in_kdtrace.h @@ -28,6 +28,8 @@ #ifndef _SYS_IN_KDTRACE_H_ #define _SYS_IN_KDTRACE_H_ +#include + #define IP_PROBE(probe, arg0, arg1, arg2, arg3, arg4, arg5) \ SDT_PROBE6(ip, , , probe, arg0, arg1, arg2, arg3, arg4, arg5) #define UDP_PROBE(probe, arg0, arg1, arg2, arg3, arg4) \ @@ -52,6 +54,283 @@ SDT_PROVIDER_DECLARE(udp); SDT_PROVIDER_DECLARE(udplite); +#ifndef KDTRACE_NO_MIB_SDT +SDT_PROVIDER_DECLARE(mib); + +SDT_PROBE_DECLARE(mib, ip, count, ips_total); +SDT_PROBE_DECLARE(mib, ip, count, ips_badsum); +SDT_PROBE_DECLARE(mib, ip, count, ips_tooshort); +SDT_PROBE_DECLARE(mib, ip, count, ips_toosmall); +SDT_PROBE_DECLARE(mib, ip, count, ips_badhlen); +SDT_PROBE_DECLARE(mib, ip, count, ips_badlen); +SDT_PROBE_DECLARE(mib, ip, count, ips_fragments); +SDT_PROBE_DECLARE(mib, ip, count, ips_fragdropped); +SDT_PROBE_DECLARE(mib, ip, count, ips_fragtimeout); +SDT_PROBE_DECLARE(mib, ip, count, ips_forward); +SDT_PROBE_DECLARE(mib, ip, count, ips_fastforward); +SDT_PROBE_DECLARE(mib, ip, count, ips_cantforward); +SDT_PROBE_DECLARE(mib, ip, count, ips_redirectsent); +SDT_PROBE_DECLARE(mib, ip, count, ips_noproto); +SDT_PROBE_DECLARE(mib, ip, count, ips_delivered); +SDT_PROBE_DECLARE(mib, ip, count, ips_localout); +SDT_PROBE_DECLARE(mib, ip, count, ips_odropped); +SDT_PROBE_DECLARE(mib, ip, count, ips_reassembled); +SDT_PROBE_DECLARE(mib, ip, count, ips_fragmented); +SDT_PROBE_DECLARE(mib, ip, count, ips_ofragments); +SDT_PROBE_DECLARE(mib, ip, count, ips_cantfrag); +SDT_PROBE_DECLARE(mib, ip, count, ips_badoptions); +SDT_PROBE_DECLARE(mib, ip, count, ips_noroute); +SDT_PROBE_DECLARE(mib, ip, count, ips_badvers); +SDT_PROBE_DECLARE(mib, ip, count, ips_rawout); +SDT_PROBE_DECLARE(mib, ip, count, ips_toolong); +SDT_PROBE_DECLARE(mib, ip, count, ips_notmember); +SDT_PROBE_DECLARE(mib, ip, count, ips_nogif); +SDT_PROBE_DECLARE(mib, ip, count, ips_badaddr); + +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_total); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_tooshort); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_toosmall); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_fragments); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_fragdropped); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_fragtimeout); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_fragoverflow); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_forward); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_cantforward); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_redirectsent); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_delivered); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_localout); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_odropped); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_reassembled); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_atomicfrags); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_fragmented); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_ofragments); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_cantfrag); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_badoptions); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_noroute); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_badvers); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_rawout); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_badscope); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_notmember); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_nxthist); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_m1); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_m2m); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_mext1); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_mext2m); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_exthdrtoolong); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_nogif); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_toomanyhdr); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_sources_none); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_sources_sameif); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_sources_otherif); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_sources_samescope); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_sources_otherscope); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_sources_deprecated); +SDT_PROBE_DECLARE(mib, ip6, count, ip6s_sources_rule); + +SDT_PROBE_DECLARE(mib, icmp, count, icps_error); +SDT_PROBE_DECLARE(mib, icmp, count, icps_oldshort); +SDT_PROBE_DECLARE(mib, icmp, count, icps_oldicmp); +SDT_PROBE_DECLARE(mib, icmp, count, icps_outhist); +SDT_PROBE_DECLARE(mib, icmp, count, icps_badcode); +SDT_PROBE_DECLARE(mib, icmp, count, icps_tooshort); +SDT_PROBE_DECLARE(mib, icmp, count, icps_checksum); +SDT_PROBE_DECLARE(mib, icmp, count, icps_badlen); +SDT_PROBE_DECLARE(mib, icmp, count, icps_reflect); +SDT_PROBE_DECLARE(mib, icmp, count, icps_inhist); +SDT_PROBE_DECLARE(mib, icmp, count, icps_bmcastecho); +SDT_PROBE_DECLARE(mib, icmp, count, icps_bmcasttstamp); +SDT_PROBE_DECLARE(mib, icmp, count, icps_badaddr); +SDT_PROBE_DECLARE(mib, icmp, count, icps_noroute); + +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_error); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_canterror); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_toofreq); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_outhist); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_badcode); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_tooshort); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_checksum); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_badlen); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_dropped); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_reflect); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_inhist); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_nd_toomanyopt); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_odst_unreach_noroute); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_odst_unreach_admin); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_odst_unreach_beyondscope); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_odst_unreach_addr); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_odst_unreach_noport); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_opacket_too_big); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_otime_exceed_transit); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_otime_exceed_reassembly); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_oparamprob_header); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_oparamprob_nextheader); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_oparamprob_option); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_oredirect); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_ounknown); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_pmtuchg); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_nd_badopt); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_badns); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_badna); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_badrs); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_badra); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_badredirect); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_overflowdefrtr); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_overflowprfx); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_overflownndp); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_overflowredirect); +SDT_PROBE_DECLARE(mib, icmp6, count, icp6s_invlhlim); + +SDT_PROBE_DECLARE(mib, udp, count, udps_ipackets); +SDT_PROBE_DECLARE(mib, udp, count, udps_hdrops); +SDT_PROBE_DECLARE(mib, udp, count, udps_badsum); +SDT_PROBE_DECLARE(mib, udp, count, udps_nosum); +SDT_PROBE_DECLARE(mib, udp, count, udps_badlen); +SDT_PROBE_DECLARE(mib, udp, count, udps_noport); +SDT_PROBE_DECLARE(mib, udp, count, udps_noportbcast); +SDT_PROBE_DECLARE(mib, udp, count, udps_fullsock); +SDT_PROBE_DECLARE(mib, udp, count, udps_pcbcachemiss); +SDT_PROBE_DECLARE(mib, udp, count, udps_pcbhashmiss); +SDT_PROBE_DECLARE(mib, udp, count, udps_opackets); +SDT_PROBE_DECLARE(mib, udp, count, udps_fastout); +SDT_PROBE_DECLARE(mib, udp, count, udps_noportmcast); +SDT_PROBE_DECLARE(mib, udp, count, udps_filtermcast); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_connattempt); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_accepts); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_connects); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_drops); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_conndrops); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_minmssdrops); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_closed); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_segstimed); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rttupdated); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_delack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_timeoutdrop); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rexmttimeo); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_persisttimeo); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_keeptimeo); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_keepprobe); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_keepdrops); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_progdrops); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndtotal); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndpack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndbyte); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndrexmitpack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndrexmitbyte); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndrexmitbad); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndacks); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndprobe); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndurg); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndwinup); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sndctrl); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvtotal); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvpack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvbyte); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvbadsum); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvbadoff); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvreassfull); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvshort); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvduppack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvdupbyte); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvpartduppack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvpartdupbyte); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvoopack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvoobyte); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvpackafterwin); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvbyteafterwin); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvafterclose); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvwinprobe); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvdupack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvacktoomuch); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvackpack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvackbyte); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_rcvwinupd); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_pawsdrop); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_predack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_preddat); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_pcbcachemiss); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_cachedrtt); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_cachedrttvar); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_cachedssthresh); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_usedrtt); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_usedrttvar); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_usedssthresh); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_persistdrop); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_badsyn); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_mturesent); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_listendrop); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_badrst); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_added); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_retransmitted); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_dupsyn); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_dropped); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_completed); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_bucketoverflow); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_cacheoverflow); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_reset); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_stale); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_aborted); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_badack); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_unreach); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_zonefail); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_sendcookie); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sc_recvcookie); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_hc_added); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_hc_bucketoverflow); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_finwait2_drops); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_recovery_episode); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_rexmits); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_rexmit_bytes); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_rcv_blocks); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_send_blocks); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_lostrexmt); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sack_sboverflow); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_ecn_rcvce); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_ecn_rcvect0); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_ecn_rcvect1); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_ecn_shs); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_ecn_rcwnd); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sig_rcvgoodsig); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sig_rcvbadsig); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sig_err_buildsig); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sig_err_sigopt); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_sig_err_nosigopt); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_pmtud_blackhole_activated); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_pmtud_blackhole_activated_min_mss); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_pmtud_blackhole_failed); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_tunneled_pkts); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_tunneled_errs); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_dsack_count); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_dsack_bytes); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_dsack_tlp_bytes); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_tw_recycles); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_tw_resets); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_tw_responds); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_ace_nect); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_ace_ect1); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_ace_ect0); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_ace_ce); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_ecn_sndect0); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_ecn_sndect1); + +SDT_PROBE_DECLARE(mib, tcp, count, tcps_tlpresends); +SDT_PROBE_DECLARE(mib, tcp, count, tcps_tlpresend_bytes); +#endif + SDT_PROBE_DECLARE(ip, , , receive); SDT_PROBE_DECLARE(ip, , , send); diff --git a/sys/netinet/in_kdtrace.c b/sys/netinet/in_kdtrace.c --- a/sys/netinet/in_kdtrace.c +++ b/sys/netinet/in_kdtrace.c @@ -30,11 +30,316 @@ #include #include +SDT_PROVIDER_DEFINE(mib); SDT_PROVIDER_DEFINE(ip); SDT_PROVIDER_DEFINE(tcp); SDT_PROVIDER_DEFINE(udp); SDT_PROVIDER_DEFINE(udplite); +#ifndef KDTRACE_NO_MIB_SDT +#define MIB_PROBE_IP(name) \ + SDT_PROBE_DEFINE1(mib, ip, count, name, \ + "int") + +MIB_PROBE_IP(ips_total); +MIB_PROBE_IP(ips_badsum); +MIB_PROBE_IP(ips_tooshort); +MIB_PROBE_IP(ips_toosmall); +MIB_PROBE_IP(ips_badhlen); +MIB_PROBE_IP(ips_badlen); +MIB_PROBE_IP(ips_fragments); +MIB_PROBE_IP(ips_fragdropped); +MIB_PROBE_IP(ips_fragtimeout); +MIB_PROBE_IP(ips_forward); +MIB_PROBE_IP(ips_fastforward); +MIB_PROBE_IP(ips_cantforward); +MIB_PROBE_IP(ips_redirectsent); +MIB_PROBE_IP(ips_noproto); +MIB_PROBE_IP(ips_delivered); +MIB_PROBE_IP(ips_localout); +MIB_PROBE_IP(ips_odropped); +MIB_PROBE_IP(ips_reassembled); +MIB_PROBE_IP(ips_fragmented); +MIB_PROBE_IP(ips_ofragments); +MIB_PROBE_IP(ips_cantfrag); +MIB_PROBE_IP(ips_badoptions); +MIB_PROBE_IP(ips_noroute); +MIB_PROBE_IP(ips_badvers); +MIB_PROBE_IP(ips_rawout); +MIB_PROBE_IP(ips_toolong); +MIB_PROBE_IP(ips_notmember); +MIB_PROBE_IP(ips_nogif); +MIB_PROBE_IP(ips_badaddr); + +#define MIB_PROBE_IP6(name) \ + SDT_PROBE_DEFINE1(mib, ip6, count, name, \ + "int") +#define MIB_PROBE2_IP6(name) \ + SDT_PROBE_DEFINE2(mib, ip6, count, name, \ + "int", "int") + +MIB_PROBE_IP6(ip6s_total); +MIB_PROBE_IP6(ip6s_tooshort); +MIB_PROBE_IP6(ip6s_toosmall); +MIB_PROBE_IP6(ip6s_fragments); +MIB_PROBE_IP6(ip6s_fragdropped); +MIB_PROBE_IP6(ip6s_fragtimeout); +MIB_PROBE_IP6(ip6s_fragoverflow); +MIB_PROBE_IP6(ip6s_forward); +MIB_PROBE_IP6(ip6s_cantforward); +MIB_PROBE_IP6(ip6s_redirectsent); +MIB_PROBE_IP6(ip6s_delivered); +MIB_PROBE_IP6(ip6s_localout); +MIB_PROBE_IP6(ip6s_odropped); +MIB_PROBE_IP6(ip6s_reassembled); +MIB_PROBE_IP6(ip6s_atomicfrags); +MIB_PROBE_IP6(ip6s_fragmented); +MIB_PROBE_IP6(ip6s_ofragments); +MIB_PROBE_IP6(ip6s_cantfrag); +MIB_PROBE_IP6(ip6s_badoptions); +MIB_PROBE_IP6(ip6s_noroute); +MIB_PROBE_IP6(ip6s_badvers); +MIB_PROBE_IP6(ip6s_rawout); +MIB_PROBE_IP6(ip6s_badscope); +MIB_PROBE_IP6(ip6s_notmember); +MIB_PROBE2_IP6(ip6s_nxthist); +MIB_PROBE_IP6(ip6s_m1); +MIB_PROBE2_IP6(ip6s_m2m); +MIB_PROBE_IP6(ip6s_mext1); +MIB_PROBE_IP6(ip6s_mext2m); +MIB_PROBE_IP6(ip6s_exthdrtoolong); +MIB_PROBE_IP6(ip6s_nogif); +MIB_PROBE_IP6(ip6s_toomanyhdr); +MIB_PROBE_IP6(ip6s_sources_none); +MIB_PROBE2_IP6(ip6s_sources_sameif); +MIB_PROBE2_IP6(ip6s_sources_otherif); +MIB_PROBE2_IP6(ip6s_sources_samescope); +MIB_PROBE2_IP6(ip6s_sources_otherscope); +MIB_PROBE2_IP6(ip6s_sources_deprecated); +MIB_PROBE2_IP6(ip6s_sources_rule); + +#define MIB_PROBE_ICMP(name) \ + SDT_PROBE_DEFINE1(mib, icmp, count, name, \ + "int") +#define MIB_PROBE2_ICMP(name) \ + SDT_PROBE_DEFINE2(mib, icmp, count, name, \ + "int", "int") + +MIB_PROBE_ICMP(icps_error); +MIB_PROBE_ICMP(icps_oldshort); +MIB_PROBE_ICMP(icps_oldicmp); +MIB_PROBE2_ICMP(icps_outhist); +MIB_PROBE_ICMP(icps_badcode); +MIB_PROBE_ICMP(icps_tooshort); +MIB_PROBE_ICMP(icps_checksum); +MIB_PROBE_ICMP(icps_badlen); +MIB_PROBE_ICMP(icps_reflect); +MIB_PROBE2_ICMP(icps_inhist); +MIB_PROBE_ICMP(icps_bmcastecho); +MIB_PROBE_ICMP(icps_bmcasttstamp); +MIB_PROBE_ICMP(icps_badaddr); +MIB_PROBE_ICMP(icps_noroute); + +#define MIB_PROBE_ICMP6(name) \ + SDT_PROBE_DEFINE1(mib, icmp6, count, name, \ + "int") +#define MIB_PROBE2_ICMP6(name) \ + SDT_PROBE_DEFINE2(mib, icmp6, count, name, \ + "int", "int") + +MIB_PROBE_ICMP6(icp6s_error); +MIB_PROBE_ICMP6(icp6s_canterror); +MIB_PROBE_ICMP6(icp6s_toofreq); +MIB_PROBE2_ICMP6(icp6s_outhist); +MIB_PROBE_ICMP6(icp6s_badcode); +MIB_PROBE_ICMP6(icp6s_tooshort); +MIB_PROBE_ICMP6(icp6s_checksum); +MIB_PROBE_ICMP6(icp6s_badlen); +MIB_PROBE_ICMP6(icp6s_dropped); +MIB_PROBE_ICMP6(icp6s_reflect); +MIB_PROBE2_ICMP6(icp6s_inhist); +MIB_PROBE_ICMP6(icp6s_nd_toomanyopt); +MIB_PROBE_ICMP6(icp6s_odst_unreach_noroute); +MIB_PROBE_ICMP6(icp6s_odst_unreach_admin); +MIB_PROBE_ICMP6(icp6s_odst_unreach_beyondscope); +MIB_PROBE_ICMP6(icp6s_odst_unreach_addr); +MIB_PROBE_ICMP6(icp6s_odst_unreach_noport); +MIB_PROBE_ICMP6(icp6s_opacket_too_big); +MIB_PROBE_ICMP6(icp6s_otime_exceed_transit); +MIB_PROBE_ICMP6(icp6s_otime_exceed_reassembly); +MIB_PROBE_ICMP6(icp6s_oparamprob_header); +MIB_PROBE_ICMP6(icp6s_oparamprob_nextheader); +MIB_PROBE_ICMP6(icp6s_oparamprob_option); +MIB_PROBE_ICMP6(icp6s_oredirect); +MIB_PROBE_ICMP6(icp6s_ounknown); +MIB_PROBE_ICMP6(icp6s_pmtuchg); +MIB_PROBE_ICMP6(icp6s_nd_badopt); +MIB_PROBE_ICMP6(icp6s_badns); +MIB_PROBE_ICMP6(icp6s_badna); +MIB_PROBE_ICMP6(icp6s_badrs); +MIB_PROBE_ICMP6(icp6s_badra); +MIB_PROBE_ICMP6(icp6s_badredirect); +MIB_PROBE_ICMP6(icp6s_overflowdefrtr); +MIB_PROBE_ICMP6(icp6s_overflowprfx); +MIB_PROBE_ICMP6(icp6s_overflownndp); +MIB_PROBE_ICMP6(icp6s_overflowredirect); +MIB_PROBE_ICMP6(icp6s_invlhlim); + +#define MIB_PROBE_UDP(name) SDT_PROBE_DEFINE1(mib, udp, count, name, "int") +MIB_PROBE_UDP(udps_ipackets); +MIB_PROBE_UDP(udps_hdrops); +MIB_PROBE_UDP(udps_badsum); +MIB_PROBE_UDP(udps_nosum); +MIB_PROBE_UDP(udps_badlen); +MIB_PROBE_UDP(udps_noport); +MIB_PROBE_UDP(udps_noportbcast); +MIB_PROBE_UDP(udps_fullsock); +MIB_PROBE_UDP(udps_pcbcachemiss); +MIB_PROBE_UDP(udps_pcbhashmiss); +MIB_PROBE_UDP(udps_opackets); +MIB_PROBE_UDP(udps_fastout); +MIB_PROBE_UDP(udps_noportmcast); +MIB_PROBE_UDP(udps_filtermcast); + +#define MIB_PROBE_TCP(name) SDT_PROBE_DEFINE1(mib, tcp, count, name, "int") + +MIB_PROBE_TCP(tcps_connattempt); +MIB_PROBE_TCP(tcps_accepts); +MIB_PROBE_TCP(tcps_connects); +MIB_PROBE_TCP(tcps_drops); +MIB_PROBE_TCP(tcps_conndrops); +MIB_PROBE_TCP(tcps_minmmsdrops); +MIB_PROBE_TCP(tcps_closed); +MIB_PROBE_TCP(tcps_segstimed); +MIB_PROBE_TCP(tcps_rttupdated); +MIB_PROBE_TCP(tcps_delack); +MIB_PROBE_TCP(tcps_timeoutdrop); +MIB_PROBE_TCP(tcps_rexmttimeo); +MIB_PROBE_TCP(tcps_persisttimeo); +MIB_PROBE_TCP(tcps_keeptimeo); +MIB_PROBE_TCP(tcps_keepprobe); +MIB_PROBE_TCP(tcps_keepdrops); +MIB_PROBE_TCP(tcps_progdrops); + +MIB_PROBE_TCP(tcps_sndtotal); +MIB_PROBE_TCP(tcps_sndpack); +MIB_PROBE_TCP(tcps_sndbyte); +MIB_PROBE_TCP(tcps_sndrexmitpack); +MIB_PROBE_TCP(tcps_sndrexmitbyte); +MIB_PROBE_TCP(tcps_sndrexmitbad); +MIB_PROBE_TCP(tcps_sndacks); +MIB_PROBE_TCP(tcps_sndprobe); +MIB_PROBE_TCP(tcps_sndurg); +MIB_PROBE_TCP(tcps_sndwinup); +MIB_PROBE_TCP(tcps_sndctrl); + +MIB_PROBE_TCP(tcps_rcvtotal); +MIB_PROBE_TCP(tcps_rcvpack); +MIB_PROBE_TCP(tcps_rcvbyte); +MIB_PROBE_TCP(tcps_rcvbadsum); +MIB_PROBE_TCP(tcps_rcvbadoff); +MIB_PROBE_TCP(tcps_rcvreassfull); +MIB_PROBE_TCP(tcps_rcvshort); +MIB_PROBE_TCP(tcps_rcvduppack); +MIB_PROBE_TCP(tcps_rcvdupbyte); +MIB_PROBE_TCP(tcps_rcvpartduppack); +MIB_PROBE_TCP(tcps_rcvpartdupbyte); +MIB_PROBE_TCP(tcps_rcvoopack); +MIB_PROBE_TCP(tcps_rcvoobyte); +MIB_PROBE_TCP(tcps_rcvpackafterwin); +MIB_PROBE_TCP(tcps_rcvbyteafterwin); +MIB_PROBE_TCP(tcps_rcvafterclose); +MIB_PROBE_TCP(tcps_rcvwinprobe); +MIB_PROBE_TCP(tcps_rcvdupack); +MIB_PROBE_TCP(tcps_rcvacktoomuch); +MIB_PROBE_TCP(tcps_rcvackpack); +MIB_PROBE_TCP(tcps_rcvackbyte); +MIB_PROBE_TCP(tcps_rcvwinupd); +MIB_PROBE_TCP(tcps_pawsdrop); +MIB_PROBE_TCP(tcps_predack); +MIB_PROBE_TCP(tcps_preddat); +MIB_PROBE_TCP(tcps_pcbackemiss); +MIB_PROBE_TCP(tcps_cachedrtt); +MIB_PROBE_TCP(tcps_cachedrttvar); +MIB_PROBE_TCP(tcps_cachedssthresh); +MIB_PROBE_TCP(tcps_usedrtt); +MIB_PROBE_TCP(tcps_usedrttvar); +MIB_PROBE_TCP(tcps_usedssthresh); +MIB_PROBE_TCP(tcps_persistdrop); +MIB_PROBE_TCP(tcps_badsyn); +MIB_PROBE_TCP(tcps_mturesent); +MIB_PROBE_TCP(tcps_listendrop); +MIB_PROBE_TCP(tcps_badrst); + +MIB_PROBE_TCP(tcps_sc_added); +MIB_PROBE_TCP(tcps_sc_retransmitted); +MIB_PROBE_TCP(tcps_sc_dupsyn); +MIB_PROBE_TCP(tcps_sc_dropped); +MIB_PROBE_TCP(tcps_sc_completed); +MIB_PROBE_TCP(tcps_sc_bucketoverflow); +MIB_PROBE_TCP(tcps_sc_cacheoverflow); +MIB_PROBE_TCP(tcps_sc_reset); +MIB_PROBE_TCP(tcps_sc_stale); +MIB_PROBE_TCP(tcps_sc_aborted); +MIB_PROBE_TCP(tcps_sc_badack); +MIB_PROBE_TCP(tcps_sc_unreach); +MIB_PROBE_TCP(tcps_sc_zonefail); +MIB_PROBE_TCP(tcps_sc_sendcookie); +MIB_PROBE_TCP(tcps_sc_recvcookie); + +MIB_PROBE_TCP(tcps_hc_added); +MIB_PROBE_TCP(tcps_hc_bucketoverflow); + +MIB_PROBE_TCP(tcps_finwait2_drops); + +MIB_PROBE_TCP(tcps_sack_recovery_episode); +MIB_PROBE_TCP(tcps_sack_rexmits); +MIB_PROBE_TCP(tcps_sack_rexmit_bytes); +MIB_PROBE_TCP(tcps_sack_rcv_blocks); +MIB_PROBE_TCP(tcps_sack_send_blocks); +MIB_PROBE_TCP(tcps_sack_lostrexmt); +MIB_PROBE_TCP(tcps_sack_sboverflow); + +MIB_PROBE_TCP(tcps_ecn_rcvce); +MIB_PROBE_TCP(tcps_ecn_rcvect0); +MIB_PROBE_TCP(tcps_ecn_rcvect1); +MIB_PROBE_TCP(tcps_ecn_shs); +MIB_PROBE_TCP(tcps_ecn_rcwnd); + +MIB_PROBE_TCP(tcps_sig_rcvgoodsig); +MIB_PROBE_TCP(tcps_sig_rcvbadsig); +MIB_PROBE_TCP(tcps_sig_err_buildsig); +MIB_PROBE_TCP(tcps_sig_err_sigopt); +MIB_PROBE_TCP(tcps_sig_err_nosigopt); + +MIB_PROBE_TCP(tcps_pmtud_blackhole_activated); +MIB_PROBE_TCP(tcps_pmtud_blackhole_activated_min_mss); +MIB_PROBE_TCP(tcps_pmtud_blackhole_failed); + +MIB_PROBE_TCP(tcps_tunneled_pkts); +MIB_PROBE_TCP(tcps_tunneled_errs); + +MIB_PROBE_TCP(tcps_dsack_count); +MIB_PROBE_TCP(tcps_dsack_bytes); +MIB_PROBE_TCP(tcps_dsack_tlp_bytes); + +MIB_PROBE_TCP(tcps_tw_recycles); +MIB_PROBE_TCP(tcps_tw_resets); +MIB_PROBE_TCP(tcps_tw_responds); + +MIB_PROBE_TCP(tcps_ace_nect); +MIB_PROBE_TCP(tcps_ace_ect1); +MIB_PROBE_TCP(tcps_ace_ect0); +MIB_PROBE_TCP(tcps_ace_ce); + +MIB_PROBE_TCP(tcps_ecn_sndect0); +MIB_PROBE_TCP(tcps_ecn_sndect1); + +MIB_PROBE_TCP(tcps_tlpresends); +MIB_PROBE_TCP(tcps_tlpresend_bytes); + +#endif + SDT_PROBE_DEFINE6_XLATE(ip, , , receive, "void *", "pktinfo_t *", "void *", "csinfo_t *", diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -344,7 +344,7 @@ */ M_SETFIB(m, M_GETFIB(n)); icp = mtod(m, struct icmp *); - ICMPSTAT_INC(icps_outhist[type]); + ICMPSTAT_INC2(icps_outhist, type); icp->icmp_type = type; if (type == ICMP_REDIRECT) icp->icmp_gwaddr.s_addr = dest; @@ -528,7 +528,7 @@ icmpgw.sin_len = sizeof(struct sockaddr_in); icmpgw.sin_family = AF_INET; - ICMPSTAT_INC(icps_inhist[icp->icmp_type]); + ICMPSTAT_INC2(icps_inhist, icp->icmp_type); code = icp->icmp_code; switch (icp->icmp_type) { case ICMP_UNREACH: @@ -663,7 +663,7 @@ } reflect: ICMPSTAT_INC(icps_reflect); - ICMPSTAT_INC(icps_outhist[icp->icmp_type]); + ICMPSTAT_INC2(icps_outhist, icp->icmp_type); icmp_reflect(m); return (IPPROTO_DONE); diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h --- a/sys/netinet/ip_var.h +++ b/sys/netinet/ip_var.h @@ -136,15 +136,19 @@ #include #include +#include VNET_PCPUSTAT_DECLARE(struct ipstat, ipstat); /* * In-kernel consumers can use these accessor macros directly to update * stats. */ -#define IPSTAT_ADD(name, val) \ - VNET_PCPUSTAT_ADD(struct ipstat, ipstat, name, (val)) -#define IPSTAT_SUB(name, val) IPSTAT_ADD(name, -(val)) +#define IPSTAT_ADD(name, val) \ + do { \ + MIB_SDT_PROBE1(ip, count, name, (val)); \ + VNET_PCPUSTAT_ADD(struct ipstat, ipstat, name, (val)); \ + } while (0) +#define IPSTAT_SUB(name, val) IPSTAT_ADD(name, -(val)) #define IPSTAT_INC(name) IPSTAT_ADD(name, 1) #define IPSTAT_DEC(name) IPSTAT_SUB(name, 1) @@ -152,11 +156,19 @@ * Kernel module consumers must use this accessor macro. */ void kmod_ipstat_inc(int statnum); -#define KMOD_IPSTAT_INC(name) \ - kmod_ipstat_inc(offsetof(struct ipstat, name) / sizeof(uint64_t)) -void kmod_ipstat_dec(int statnum); -#define KMOD_IPSTAT_DEC(name) \ - kmod_ipstat_dec(offsetof(struct ipstat, name) / sizeof(uint64_t)) +#define KMOD_IPSTAT_INC(name) \ + do { \ + MIB_SDT_PROBE1(ip, count, name, 1); \ + kmod_ipstat_inc( \ + offsetof(struct ipstat, name) / sizeof(uint64_t)); \ + } while (0) +void kmod_ipstat_dec(int statnum); +#define KMOD_IPSTAT_DEC(name) \ + do { \ + MIB_SDT_PROBE1(ip, count, name, -1); \ + kmod_ipstat_dec( \ + offsetof(struct ipstat, name) / sizeof(uint64_t)); \ + } while (0) /* flags passed to ip_output as last parameter */ #define IP_FORWARDING 0x1 /* most of ip header exists */ diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1093,22 +1093,31 @@ #define TI_UNLOCKED 1 #define TI_RLOCKED 2 #include +#include VNET_PCPUSTAT_DECLARE(struct tcpstat, tcpstat); /* tcp statistics */ /* * In-kernel consumers can use these accessor macros directly to update * stats. */ -#define TCPSTAT_ADD(name, val) \ - VNET_PCPUSTAT_ADD(struct tcpstat, tcpstat, name, (val)) +#define TCPSTAT_ADD(name, val) \ + do { \ + MIB_SDT_PROBE1(tcp, count, name, (val)); \ + VNET_PCPUSTAT_ADD(struct tcpstat, tcpstat, name, (val)); \ + } while (0) #define TCPSTAT_INC(name) TCPSTAT_ADD(name, 1) /* * Kernel module consumers must use this accessor macro. */ void kmod_tcpstat_add(int statnum, int val); -#define KMOD_TCPSTAT_ADD(name, val) \ - kmod_tcpstat_add(offsetof(struct tcpstat, name) / sizeof(uint64_t), val) +#define KMOD_TCPSTAT_ADD(name, val) \ + do { \ + MIB_SDT_PROBE1(tcp, count, name, (val)); \ + kmod_tcpstat_add(offsetof(struct tcpstat, name) / \ + sizeof(uint64_t), \ + val); \ + } while (0) #define KMOD_TCPSTAT_INC(name) KMOD_TCPSTAT_ADD(name, 1) /* diff --git a/sys/netinet/udp_var.h b/sys/netinet/udp_var.h --- a/sys/netinet/udp_var.h +++ b/sys/netinet/udp_var.h @@ -93,6 +93,7 @@ #ifdef _KERNEL #include #include +#include struct mbuf; typedef bool udp_tun_func_t(struct mbuf *, int, struct inpcb *, @@ -127,16 +128,23 @@ * In-kernel consumers can use these accessor macros directly to update * stats. */ -#define UDPSTAT_ADD(name, val) \ - VNET_PCPUSTAT_ADD(struct udpstat, udpstat, name, (val)) -#define UDPSTAT_INC(name) UDPSTAT_ADD(name, 1) +#define UDPSTAT_ADD(name, val) \ + do { \ + MIB_SDT_PROBE1(udp, count, name, (val)); \ + VNET_PCPUSTAT_ADD(struct udpstat, udpstat, name, (val)); \ + } while (0) +#define UDPSTAT_INC(name) UDPSTAT_ADD(name, 1) /* * Kernel module consumers must use this accessor macro. */ void kmod_udpstat_inc(int statnum); -#define KMOD_UDPSTAT_INC(name) \ - kmod_udpstat_inc(offsetof(struct udpstat, name) / sizeof(uint64_t)) +#define KMOD_UDPSTAT_INC(name) \ + do { \ + MIB_SDT_PROBE1(udp, count, name, 1); \ + kmod_udpstat_inc( \ + offsetof(struct udpstat, name) / sizeof(uint64_t)); \ + } while (0) SYSCTL_DECL(_net_inet_udp); diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -382,7 +382,7 @@ icmp6->icmp6_code = code; icmp6->icmp6_pptr = htonl((u_int32_t)param); - ICMP6STAT_INC(icp6s_outhist[type]); + ICMP6STAT_INC2(icp6s_outhist, type); NET_EPOCH_ENTER(et); icmp6_reflect(m, sizeof(struct ip6_hdr)); /* header order: IPv6 - ICMPv6 */ NET_EPOCH_EXIT(et); @@ -507,7 +507,7 @@ goto freeit; } - ICMP6STAT_INC(icp6s_inhist[icmp6->icmp6_type]); + ICMP6STAT_INC2(icp6s_inhist, icmp6->icmp6_type); icmp6_ifstat_inc(ifp, ifs6_in_msg); if (icmp6->icmp6_type < ICMP6_INFOMSG_MASK) icmp6_ifstat_inc(ifp, ifs6_in_error); @@ -612,7 +612,7 @@ nicmp6->icmp6_type = ICMP6_ECHO_REPLY; nicmp6->icmp6_code = 0; ICMP6STAT_INC(icp6s_reflect); - ICMP6STAT_INC(icp6s_outhist[ICMP6_ECHO_REPLY]); + ICMP6STAT_INC2(icp6s_outhist, ICMP6_ECHO_REPLY); icmp6_reflect(n, noff); } break; @@ -744,7 +744,7 @@ } if (n) { ICMP6STAT_INC(icp6s_reflect); - ICMP6STAT_INC(icp6s_outhist[ICMP6_WRUREPLY]); + ICMP6STAT_INC2(icp6s_outhist, ICMP6_WRUREPLY); icmp6_reflect(n, noff); } break; @@ -2648,7 +2648,7 @@ icmp6_ifstat_inc(outif, ifs6_out_msg); icmp6_ifstat_inc(outif, ifs6_out_redirect); } - ICMP6STAT_INC(icp6s_outhist[ND_REDIRECT]); + ICMP6STAT_INC2(icp6s_outhist, ND_REDIRECT); return; diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c --- a/sys/netinet6/in6_src.c +++ b/sys/netinet6/in6_src.c @@ -152,7 +152,7 @@ * an entry to the caller for later use. */ #define REPLACE(r) do {\ - IP6STAT_INC(ip6s_sources_rule[(r)]); \ + IP6STAT_INC2(ip6s_sources_rule, (r)); \ /* { \ char ip6buf[INET6_ADDRSTRLEN], ip6b[INET6_ADDRSTRLEN]; \ printf("in6_selectsrc: replace %s with %s by %d\n", ia_best ? ip6_sprintf(ip6buf, &ia_best->ia_addr.sin6_addr) : "none", ip6_sprintf(ip6b, &ia->ia_addr.sin6_addr), (r)); \ @@ -167,7 +167,7 @@ goto next; /* XXX: we can't use 'continue' here */ \ } while(0) #define BREAK(r) do { \ - IP6STAT_INC(ip6s_sources_rule[(r)]); \ + IP6STAT_INC2(ip6s_sources_rule, (r)); \ goto out; /* XXX: we can't use 'break' here */ \ } while(0) @@ -523,15 +523,15 @@ bcopy(&tmp, srcp, sizeof(*srcp)); if (ia->ia_ifp == ifp) - IP6STAT_INC(ip6s_sources_sameif[best_scope]); + IP6STAT_INC2(ip6s_sources_sameif, best_scope); else - IP6STAT_INC(ip6s_sources_otherif[best_scope]); + IP6STAT_INC2(ip6s_sources_otherif, best_scope); if (dst_scope == best_scope) - IP6STAT_INC(ip6s_sources_samescope[best_scope]); + IP6STAT_INC2(ip6s_sources_samescope, best_scope); else - IP6STAT_INC(ip6s_sources_otherscope[best_scope]); + IP6STAT_INC2(ip6s_sources_otherscope, best_scope); if (IFA6_IS_DEPRECATED(ia)) - IP6STAT_INC(ip6s_sources_deprecated[best_scope]); + IP6STAT_INC2(ip6s_sources_deprecated, best_scope); IN6_IFADDR_RUNLOCK(&in6_ifa_tracker); return (0); } diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -573,7 +573,7 @@ int ifindex = ifp->if_index; if (ifindex >= IP6S_M2MMAX) ifindex = 0; - IP6STAT_INC(ip6s_m2m[ifindex]); + IP6STAT_INC2(ip6s_m2m, ifindex); } else IP6STAT_INC(ip6s_m1); } @@ -617,7 +617,7 @@ goto bad; } - IP6STAT_INC(ip6s_nxthist[ip6->ip6_nxt]); + IP6STAT_INC2(ip6s_nxthist, ip6->ip6_nxt); IP_PROBE(receive, NULL, NULL, ip6, rcvif, NULL, ip6); /* diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h --- a/sys/netinet6/ip6_var.h +++ b/sys/netinet6/ip6_var.h @@ -263,13 +263,22 @@ #ifdef _KERNEL #include +#include VNET_PCPUSTAT_DECLARE(struct ip6stat, ip6stat); -#define IP6STAT_ADD(name, val) \ - VNET_PCPUSTAT_ADD(struct ip6stat, ip6stat, name, (val)) -#define IP6STAT_SUB(name, val) IP6STAT_ADD(name, -(val)) +#define IP6STAT_ADD(name, val) \ + do { \ + MIB_SDT_PROBE1(ip6, count, name, (val)); \ + VNET_PCPUSTAT_ADD(struct ip6stat, ip6stat, name, (val)); \ + } while (0) +#define IP6STAT_SUB(name, val) IP6STAT_ADD(name, -(val)) #define IP6STAT_INC(name) IP6STAT_ADD(name, 1) -#define IP6STAT_DEC(name) IP6STAT_SUB(name, 1) +#define IP6STAT_INC2(name, type) \ + do { \ + MIB_SDT_PROBE2(ip6, count, name, 1, type); \ + VNET_PCPUSTAT_ADD(struct ip6stat, ip6stat, name, 1); \ + } while (0) +#define IP6STAT_DEC(name) IP6STAT_SUB(name, 1) #endif #ifdef _KERNEL diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c --- a/sys/netinet6/mld6.c +++ b/sys/netinet6/mld6.c @@ -3133,7 +3133,7 @@ CTR3(KTR_MLD, "%s: ip6_output(%p) = %d", __func__, m0, error); goto out; } - ICMP6STAT_INC(icp6s_outhist[type]); + ICMP6STAT_INC2(icp6s_outhist, type); if (oifp != NULL) { icmp6_ifstat_inc(oifp, ifs6_out_msg); switch (type) { diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c --- a/sys/netinet6/nd6_nbr.c +++ b/sys/netinet6/nd6_nbr.c @@ -623,7 +623,7 @@ &im6o, NULL, NULL); icmp6_ifstat_inc(ifp, ifs6_out_msg); icmp6_ifstat_inc(ifp, ifs6_out_neighborsolicit); - ICMP6STAT_INC(icp6s_outhist[ND_NEIGHBOR_SOLICIT]); + ICMP6STAT_INC2(icp6s_outhist, ND_NEIGHBOR_SOLICIT); return; @@ -1116,7 +1116,7 @@ ip6_output(m, NULL, NULL, 0, &im6o, NULL, NULL); icmp6_ifstat_inc(ifp, ifs6_out_msg); icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert); - ICMP6STAT_INC(icp6s_outhist[ND_NEIGHBOR_ADVERT]); + ICMP6STAT_INC2(icp6s_outhist, ND_NEIGHBOR_ADVERT); return; diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -535,7 +535,7 @@ if (inp->inp_ip_p == IPPROTO_ICMPV6) { if (oifp) icmp6_ifoutstat_inc(oifp, type, code); - ICMP6STAT_INC(icp6s_outhist[type]); + ICMP6STAT_INC2(icp6s_outhist, type); } else RIP6STAT_INC(rip6s_opackets); diff --git a/sys/sys/sdt.h b/sys/sys/sdt.h --- a/sys/sys/sdt.h +++ b/sys/sys/sdt.h @@ -115,6 +115,9 @@ #define SDT_PROBE7(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5, \ arg6) +#define MIB_SDT_PROBE1(...) +#define MIB_SDT_PROBE2(...) + #define SDT_PROBE_DEFINE0_XLATE(prov, mod, func, name) #define SDT_PROBE_DEFINE1_XLATE(prov, mod, func, name, arg0, xarg0) #define SDT_PROBE_DEFINE2_XLATE(prov, mod, func, name, arg0, xarg0, \ @@ -342,6 +345,14 @@ (uintptr_t)arg6); \ } while (0) +#ifndef KDTRACE_NO_MIB_SDT +#define MIB_SDT_PROBE1(...) SDT_PROBE1(mib, __VA_ARGS__) +#define MIB_SDT_PROBE2(...) SDT_PROBE2(mib, __VA_ARGS__) +#else +#define MIB_SDT_PROBE1(...) +#define MIB_SDT_PROBE2(...) +#endif + #define DTRACE_PROBE_IMPL_START(name, arg0, arg1, arg2, arg3, arg4) do { \ static SDT_PROBE_DEFINE(sdt, , , name); \ SDT_PROBE(sdt, , , name, arg0, arg1, arg2, arg3, arg4);