diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -1013,6 +1013,7 @@ dtrace_ip.4 \ dtrace_kinst.4 \ dtrace_lockstat.4 \ + dtrace_mib.4 \ dtrace_pid.4 \ dtrace_priv.4 \ dtrace_proc.4 \ diff --git a/share/man/man4/ath.4 b/share/man/man4/ath.4 --- a/share/man/man4/ath.4 +++ b/share/man/man4/ath.4 @@ -257,6 +257,7 @@ .Sh SEE ALSO .Xr ath_hal 4 , .Xr cardbus 4 , +.Xr dtrace_mib 4 , .Xr intro 4 , .Xr pcic 4 , .Xr wlan 4 , diff --git a/share/man/man4/ath_hal.4 b/share/man/man4/ath_hal.4 --- a/share/man/man4/ath_hal.4 +++ b/share/man/man4/ath_hal.4 @@ -123,7 +123,8 @@ .It "TP-LINK TL-WDN4800 AR9380 PCIe a/b/g/n" .El .Sh SEE ALSO -.Xr ath 4 +.Xr ath 4 , +.Xr dtrace_mib 4 .Sh HISTORY The .Nm diff --git a/share/man/man4/dtrace_mib.4 b/share/man/man4/dtrace_mib.4 new file mode 100644 --- /dev/null +++ b/share/man/man4/dtrace_mib.4 @@ -0,0 +1,130 @@ +.\" +.\" SPDX-License-Identifier: BSD-2-Clause +.\" +.\" Copyright (c) 2025 Mateusz Piotrowski <0mp@FreeBSD.org> +.\" +.Dd July 18, 2025 +.Dt DTRACE_MIB 4 +.Os +.Sh NAME +.Nm dtrace_mib +.Nd a DTrace provider for Management Information Base +.Sh SYNOPSIS +.Fn mib::count: "int count" +.Pp +To enable this provider, +place the following in the kernel configuration file: +.Bd -literal -offset indent +.Cd "options KDTRACE_MIB_SDT" +.Sh DESCRIPTION +The +.Nm mib +provider allows tracing of Management Information Base stats counters. +Currently, it instruments the following +.Ar module Ns s : +.Bl -tag -offset indent -width ipcomp -compact +.It Cm ah +.Xr ath 4 , +.\" 0MPXXX: This is probably not the right esp... +.Xr ath_hal 4 +.It Cm esp +.\" 0M0MPPXXX: This is probably not the right esp... +.Xr esp 4 +.It Cm icmp +.Xr icmp 4 +.It Cm icmp6 +.Xr icmp6 4 +.It Cm ip +.Xr ip 4 +.It Cm ip6 +.Xr ip6 4 +.It Cm ipcomp +IP Payload Compression Protocol, refer to +.Xr ipsec 4 +for more details +.It Cm ipsec +.Xr ipsec 4 +.It Cm tcp +.Xr tcp 4 +.It Cm udp +.Xr udp 4 +.El +.Pp +The +.Fn mib::count: +probes fire when the +.Ar name +counter in +.Ar modules +increases. +The first, and only, probe argument +.Vt uint64_t Va arg0 +is the +.Vt int Va count , +which is the value that the +.Ar name +counter will increase to. +.\" 0MPXXX: mib:esp:count:esps_hist has 2 arguments and both arguments are typed. +.Sh EXAMPLES +.Ss Example 1 : Tracing IP Stats Counters + +When debugging network issues one common clue is an unexpectedly +incrementing error counter. +This is helpful, in that it gives us an +idea of what might be going wrong, but often these counters may be +incremented in different functions. + +Trace all +.Nm mib +probes in the +.Xr ip 4 +module and print the current count and a stack trace: + + +.Bd -literal -offset 2n +# dtrace -n 'mib:ip:count: { printf("%d", arg0); stack(); }' +dtrace: description 'mib:ip:count: ' matched 29 probes +CPU ID FUNCTION:NAME + 7 98784 count:ips_localout 1 + kernel`ip_output+0x17a2 + kernel`udp_send+0xaca + kernel`sosend_dgram+0x315 + kernel`sousrsend+0x79 + kernel`kern_sendit+0x1be + kernel`sendit+0x1ab + kernel`sys_sendmsg+0x5b + kernel`amd64_syscall+0x169 + kernel`0xffffffff81094b8b +.Ed +.Sh SEE ALSO +.Xr dtrace 1 , +.Xr dtrace_ip 4 , +.Xr dtrace_tcp 4 , +.Xr dtrace_udp 4 , +.Xr tracing 7 , +.Xr sysctl 8 +.Rs +.%B The illumos Dynamic Tracing Guide +.%O Chapter mib Provider +.%D 2008 +.%U https://illumos.org/books/dtrace/chp-mib.html +.Re +.Sh AUTHORS +.An -nosplit +The +.Nm mib +provider was added to +.Fx +by +.An Kristof Provost Aq Mt kp@FreeBSD.org . +This manual page was written by +.An Mateusz Piotrowski Aq Mt 0mp@FreeBSD.org . +.Sh CAVEATS +The +.Nm mib +provider probes are not a stable interface. +Use +.Va arg0 +instead of +.Va args[0] +to access the first probe argument. diff --git a/share/man/man4/ifmib.4 b/share/man/man4/ifmib.4 --- a/share/man/man4/ifmib.4 +++ b/share/man/man4/ifmib.4 @@ -25,7 +25,7 @@ .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd December 26, 2020 +.Dd July 18, 2025 .Dt IFMIB 4 .Os .Sh NAME @@ -165,6 +165,7 @@ MIB for Ethernet-like networks. .Sh SEE ALSO .Xr sysctl 3 , +.Xr dtrace_mib 4 , .Xr intro 4 , .Xr ifnet 9 .\" .Xr ethermib 4 ,