xref: /freebsd/share/man/man4/dtrace_udplite.4 (revision 4b9d6057)
1.\" Copyright (c) 2015 Mark Johnston <markj@FreeBSD.org>
2.\" Copyright (c) 2018 Michael Tuexen <tuexen@FreeBSD.org>
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24.\" SUCH DAMAGE.
25.\"
26.Dd August 1, 2018
27.Dt DTRACE_UDPLITE 4
28.Os
29.Sh NAME
30.Nm dtrace_udplite
31.Nd a DTrace provider for tracing events related to the UDP-Lite protocol
32.Sh SYNOPSIS
33.Fn udplite:::receive "pktinfo_t *" "csinfo_t *" "ipinfo_t *" "udplitesinfo_t *" \
34    "udpliteinfo_t *"
35.Fn udplite:::send "pktinfo_t *" "csinfo_t *" "ipinfo_t *" "udplitesinfo_t *" \
36    "udpliteinfo_t *"
37.Sh DESCRIPTION
38The DTrace
39.Nm udplite
40provider allows users to trace events in the
41.Xr udplite 4
42protocol implementation.
43The
44.Fn udplite:::send
45probe fires whenever the kernel prepares to transmit a UDP-Lite packet, and the
46.Fn udplite:::receive
47probe fires whenever the kernel receives a UDP-Lite packet, unless
48the UDP-Lite header is incomplete,
49the destination port is 0,
50the length field is invalid,
51or the checksum is wrong.
52The arguments to these probes can be used to obtain detailed information about
53the IP and UDP-Lite headers of the corresponding packet.
54.Sh ARGUMENTS
55The
56.Vt pktinfo_t
57argument is currently unimplemented and is included for compatibility with other
58implementations of this provider.
59Its fields are:
60.Bl -tag -width "uintptr_t pkt_addr" -offset indent
61.It Vt uintptr_t pkt_addr
62Always set to 0.
63.El
64.Pp
65The
66.Vt csinfo_t
67argument is currently unimplemented and is included for compatibility with other
68implementations of this provider.
69Its fields are:
70.Bl -tag -width "uintptr_t cs_addr" -offset indent
71.It Vt uintptr_t cs_addr
72Always set to 0.
73.It Vt uint64_t cs_cid
74A pointer to the
75.Vt struct inpcb
76for this packet, or
77.Dv NULL .
78.It Vt pid_t cs_pid
79Always set to 0.
80.El
81.Pp
82The
83.Vt ipinfo_t
84argument contains IP fields common to both IPv4 and IPv6 packets.
85Its fields are:
86.Bl -tag -width "uint32_t ip_plength" -offset indent
87.It Vt uint8_t ip_ver
88IP version of the packet, 4 for IPv4 packets and 6 for IPv6 packets.
89.It Vt uint32_t ip_plength
90IP payload size.
91This does not include the size of the IP header or IPv6 option headers.
92.It Vt string ip_saddr
93IP source address.
94.It Vt string ip_daddr
95IP destination address.
96.El
97.Pp
98The
99.Vt udplitesinfo_t
100argument contains the state of the UDP-Lite connection associated with the packet.
101Its fields are:
102.Bl -tag -width "uintptr_t udplites_addr" -offset indent
103.It Vt uintptr_t udplites_addr
104Pointer to the
105.Vt struct inpcb
106containing the IP state for the associated socket.
107.It Vt uint16_t udplites_lport
108Local UDP-Lite port.
109.It Vt uint16_t udplites_rport
110Remote UDP-Lite port.
111.It Vt string udplites_laddr
112Local IPv4 or IPv6 address.
113.It Vt string udplites_raddr
114Remote IPv4 or IPv6 address.
115.El
116.Pp
117The
118.Vt udpliteinfo_t
119argument is the raw UDP-Lite header of the packet, with all fields in host order.
120Its fields are:
121.Bl -tag -width "struct udplitehdr *udplite_hdr" -offset indent
122.It Vt uint16_t udplite_sport
123Source UDP-Lite port.
124.It Vt uint16_t udplite_dport
125Destination UDP-Lite port.
126.It Vt uint16_t udplite_coverage
127Checksum coverage of the UDP-Lite header, in bytes, or 0 for full coverage.
128.It Vt uint16_t udplite_checksum
129A checksum of the UDP-Lite header and payload, or 0 if no checksum was calculated.
130.It Vt struct udplitehdr *udplite_hdr
131A pointer to the raw UDP-Lite header.
132.El
133.Sh FILES
134.Bl -tag -width "/usr/lib/dtrace/udplite.d" -compact
135.It Pa /usr/lib/dtrace/udplite.d
136DTrace type and translator definitions for the
137.Nm udplite
138provider.
139.El
140.Sh EXAMPLES
141The following script counts transmitted packets by destination port.
142.Bd -literal -offset indent
143udplite:::send
144{
145        @num[args[4]->udplite_dport] = count();
146}
147.Ed
148.Pp
149This script will print some details of each UDP-Lite packet as it is sent or received
150by the kernel:
151.Bd -literal -offset indent
152#pragma D option quiet
153#pragma D option switchrate=10Hz
154
155dtrace:::BEGIN
156{
157        printf(" %10s %36s    %-36s %6s\\n", "DELTA(us)", "SOURCE",
158            "DEST", "COV");
159        last = timestamp;
160}
161
162udplite:::send
163{
164        this->elapsed = (timestamp - last) / 1000;
165        self->dest = strjoin(strjoin(args[2]->ip_daddr, ":"),
166             lltostr(args[4]->udplite_dport));
167        printf(" %10d %30s:%-5d -> %-36s %6d\\n", this->elapsed,
168            args[2]->ip_saddr, args[4]->udplite_sport,
169            self->dest, args[4]->udplite_coverage);
170        last = timestamp;
171}
172
173udplite:::receive
174{
175        this->elapsed = (timestamp - last) / 1000;
176        self->dest = strjoin(strjoin(args[2]->ip_saddr, ":"),
177             lltostr(args[4]->udplite_sport));
178        printf(" %10d %30s:%-5d <- %-36s %6d\\n", this->elapsed,
179            args[2]->ip_daddr, args[4]->udplite_dport,
180            self->dest, args[4]->udplite_coverage);
181        last = timestamp;
182}
183.Ed
184.Sh SEE ALSO
185.Xr dtrace 1 ,
186.Xr dtrace_ip 4 ,
187.Xr dtrace_sctp 4 ,
188.Xr dtrace_tcp 4 ,
189.Xr dtrace_udp 4 ,
190.Xr udplite 4 ,
191.Xr SDT 9
192.Sh HISTORY
193The
194.Nm udplite
195provider first appeared in
196.Fx
19712.0.
198.Sh AUTHORS
199This manual page was written by
200.An Mark Johnston Aq Mt markj@FreeBSD.org
201and
202.An Michael Tuexen Aq Mt tuexen@FreeBSD.org .
203