1*4b4ad3a2SMark Johnston.\" Copyright (c) 2015 Mark Johnston <markj@FreeBSD.org> 2*4b4ad3a2SMark Johnston.\" All rights reserved. 3*4b4ad3a2SMark Johnston.\" 4*4b4ad3a2SMark Johnston.\" Redistribution and use in source and binary forms, with or without 5*4b4ad3a2SMark Johnston.\" modification, are permitted provided that the following conditions 6*4b4ad3a2SMark Johnston.\" are met: 7*4b4ad3a2SMark Johnston.\" 1. Redistributions of source code must retain the above copyright 8*4b4ad3a2SMark Johnston.\" notice, this list of conditions and the following disclaimer. 9*4b4ad3a2SMark Johnston.\" 2. Redistributions in binary form must reproduce the above copyright 10*4b4ad3a2SMark Johnston.\" notice, this list of conditions and the following disclaimer in the 11*4b4ad3a2SMark Johnston.\" documentation and/or other materials provided with the distribution. 12*4b4ad3a2SMark Johnston.\" 13*4b4ad3a2SMark Johnston.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14*4b4ad3a2SMark Johnston.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15*4b4ad3a2SMark Johnston.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16*4b4ad3a2SMark Johnston.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17*4b4ad3a2SMark Johnston.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18*4b4ad3a2SMark Johnston.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19*4b4ad3a2SMark Johnston.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20*4b4ad3a2SMark Johnston.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21*4b4ad3a2SMark Johnston.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22*4b4ad3a2SMark Johnston.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23*4b4ad3a2SMark Johnston.\" SUCH DAMAGE. 24*4b4ad3a2SMark Johnston.\" 25*4b4ad3a2SMark Johnston.\" $FreeBSD$ 26*4b4ad3a2SMark Johnston.\" 27*4b4ad3a2SMark Johnston.Dd April 18, 2015 28*4b4ad3a2SMark Johnston.Dt DTRACE_IP 4 29*4b4ad3a2SMark Johnston.Os 30*4b4ad3a2SMark Johnston.Sh NAME 31*4b4ad3a2SMark Johnston.Nm dtrace_ip 32*4b4ad3a2SMark Johnston.Nd a DTrace provider for tracing events related to the IPv4 and IPv6 protocols 33*4b4ad3a2SMark Johnston.Sh SYNOPSIS 34*4b4ad3a2SMark Johnston.Fn ip:::receive "pktinfo_t *" "csinfo_t *" "ipinfo_t *" "ifinfo_t *" \ 35*4b4ad3a2SMark Johnston "ipv4info_t *" "ipv6info_t *" 36*4b4ad3a2SMark Johnston.Fn ip:::send "pktinfo_t *" "csinfo_t *" "ipinfo_t *" "ifinfo_t *" \ 37*4b4ad3a2SMark Johnston "ipv4info_t *" "ipv6info_t *" 38*4b4ad3a2SMark Johnston.Sh DESCRIPTION 39*4b4ad3a2SMark JohnstonThe DTrace 40*4b4ad3a2SMark Johnston.Nm ip 41*4b4ad3a2SMark Johnstonprovider allows users to trace events in the 42*4b4ad3a2SMark Johnston.Xr ip 4 43*4b4ad3a2SMark Johnstonand 44*4b4ad3a2SMark Johnston.Xr ip6 4 45*4b4ad3a2SMark Johnstonprotocol implementations. 46*4b4ad3a2SMark JohnstonThe 47*4b4ad3a2SMark Johnston.Fn ip:::send 48*4b4ad3a2SMark Johnstonprobe fires whenever the kernel prepares to transmit an IP packet, and the 49*4b4ad3a2SMark Johnston.Fn ip:::receive 50*4b4ad3a2SMark Johnstonprobe fires whenever the kernel receives an IP packet. 51*4b4ad3a2SMark JohnstonThe arguments to these probes can be used to obtain detailed information about 52*4b4ad3a2SMark Johnstonthe IP headers of the corresponding packet, as well as the network interface on 53*4b4ad3a2SMark Johnstonwhich the packet was sent or received. 54*4b4ad3a2SMark JohnstonUnlike the 55*4b4ad3a2SMark Johnston.Xr dtrace_tcp 4 56*4b4ad3a2SMark Johnstonand 57*4b4ad3a2SMark Johnston.Xr dtrace_udp 4 58*4b4ad3a2SMark Johnstonproviders, 59*4b4ad3a2SMark Johnston.Nm ip 60*4b4ad3a2SMark Johnstonprovider probes are triggered by forwarded packets. 61*4b4ad3a2SMark JohnstonThat is, the probes will fire on packets that are not destined to the local 62*4b4ad3a2SMark Johnstonhost. 63*4b4ad3a2SMark Johnston.Sh ARGUMENTS 64*4b4ad3a2SMark JohnstonThe 65*4b4ad3a2SMark Johnston.Vt pktinfo_t 66*4b4ad3a2SMark Johnstonargument is currently unimplemented and is included for compatibility with other 67*4b4ad3a2SMark Johnstonimplementations of this provider. 68*4b4ad3a2SMark JohnstonIts fields are: 69*4b4ad3a2SMark Johnston.Bl -tag -width "uintptr_t pkt_addr" -offset indent 70*4b4ad3a2SMark Johnston.It Vt uintptr_t pkt_addr 71*4b4ad3a2SMark JohnstonAlways set to 0. 72*4b4ad3a2SMark Johnston.El 73*4b4ad3a2SMark Johnston.Pp 74*4b4ad3a2SMark JohnstonThe 75*4b4ad3a2SMark Johnston.Vt csinfo_t 76*4b4ad3a2SMark Johnstonargument is currently unimplemented and is included for compatibility with other 77*4b4ad3a2SMark Johnstonimplementations of this provider. 78*4b4ad3a2SMark JohnstonIts fields are: 79*4b4ad3a2SMark Johnston.Bl -tag -width "uintptr_t cs_addr" -offset indent 80*4b4ad3a2SMark Johnston.It Vt uintptr_t cs_addr 81*4b4ad3a2SMark JohnstonAlways set to 0. 82*4b4ad3a2SMark Johnston.It Vt uint64_t cs_cid 83*4b4ad3a2SMark JohnstonA pointer to the 84*4b4ad3a2SMark Johnston.Vt struct inpcb 85*4b4ad3a2SMark Johnstonfor this packet, or 86*4b4ad3a2SMark Johnston.Dv NULL . 87*4b4ad3a2SMark Johnston.It Vt pid_t cs_pid 88*4b4ad3a2SMark JohnstonAlways set to 0. 89*4b4ad3a2SMark Johnston.El 90*4b4ad3a2SMark Johnston.Pp 91*4b4ad3a2SMark JohnstonThe 92*4b4ad3a2SMark Johnston.Vt ipinfo_t 93*4b4ad3a2SMark Johnstonargument contains IP fields common to both IPv4 and IPv6 packets. 94*4b4ad3a2SMark JohnstonIts fields are: 95*4b4ad3a2SMark Johnston.Bl -tag -width "uint32_t ip_plength" -offset indent 96*4b4ad3a2SMark Johnston.It Vt uint8_t ip_ver 97*4b4ad3a2SMark JohnstonIP version of the packet, 4 for IPv4 packets and 6 for IPv6 packets. 98*4b4ad3a2SMark Johnston.It Vt uint32_t ip_plength 99*4b4ad3a2SMark JohnstonIP payload size. 100*4b4ad3a2SMark JohnstonThis does not include the size of the IP header or IPv6 option headers. 101*4b4ad3a2SMark Johnston.It Vt string ip_saddr 102*4b4ad3a2SMark JohnstonIP source address. 103*4b4ad3a2SMark Johnston.It Vt string ip_daddr 104*4b4ad3a2SMark JohnstonIP destination address. 105*4b4ad3a2SMark Johnston.El 106*4b4ad3a2SMark Johnston.Pp 107*4b4ad3a2SMark JohnstonThe 108*4b4ad3a2SMark Johnston.Vt ifinfo_t 109*4b4ad3a2SMark Johnstonargument describes the outgoing and incoming interfaces for the packet in the 110*4b4ad3a2SMark Johnston.Fn ip:::send 111*4b4ad3a2SMark Johnstonand 112*4b4ad3a2SMark Johnston.Fn ip:::receive 113*4b4ad3a2SMark Johnstonprobes respectively. 114*4b4ad3a2SMark JohnstonIts fields are: 115*4b4ad3a2SMark Johnston.Bl -tag -width "uintptr_t if_addr" -offset indent 116*4b4ad3a2SMark Johnston.It Vt string if_name 117*4b4ad3a2SMark JohnstonThe interface name. 118*4b4ad3a2SMark Johnston.It Vt int8_t if_local 119*4b4ad3a2SMark JohnstonA boolean value indicating whether or not the interface is a loopback interface. 120*4b4ad3a2SMark Johnston.It Vt uintptr_t if_addr 121*4b4ad3a2SMark JohnstonA pointer to the 122*4b4ad3a2SMark Johnston.Vt struct ifnet 123*4b4ad3a2SMark Johnstonwhich describes the interface. 124*4b4ad3a2SMark JohnstonSee the 125*4b4ad3a2SMark Johnston.Xr ifnet 9 126*4b4ad3a2SMark Johnstonmanual page. 127*4b4ad3a2SMark Johnston.El 128*4b4ad3a2SMark Johnston.Pp 129*4b4ad3a2SMark JohnstonThe 130*4b4ad3a2SMark Johnston.Vt ipv4info_t 131*4b4ad3a2SMark Johnstonargument contains the fields of the IP header for IPv4 packets. 132*4b4ad3a2SMark JohnstonThis argument is 133*4b4ad3a2SMark Johnston.Dv NULL 134*4b4ad3a2SMark Johnstonfor IPv6 packets. 135*4b4ad3a2SMark JohnstonDTrace scripts should use the 136*4b4ad3a2SMark Johnston.Fn ip_ver 137*4b4ad3a2SMark Johnstonfield in the 138*4b4ad3a2SMark Johnston.Vt ipinfo_t 139*4b4ad3a2SMark Johnstonargument to determine whether to use this argument. 140*4b4ad3a2SMark JohnstonIts fields are: 141*4b4ad3a2SMark Johnston.Bl -tag -width "uint16_t ipv4_checksum" -offset indent 142*4b4ad3a2SMark Johnston.It Vt uint8_t ipv4_ver 143*4b4ad3a2SMark JohnstonIP version. 144*4b4ad3a2SMark JohnstonThis will always be 4 for IPv4 packets. 145*4b4ad3a2SMark Johnston.It Vt uint8_t ipv4_ihl 146*4b4ad3a2SMark JohnstonThe IP header length, including options, in 32-bit words. 147*4b4ad3a2SMark Johnston.It Vt uint8_t ipv4_tos 148*4b4ad3a2SMark JohnstonIP type of service field. 149*4b4ad3a2SMark Johnston.It Vt uint16_t ipv4_length 150*4b4ad3a2SMark JohnstonThe total packet length, including the header, in bytes. 151*4b4ad3a2SMark Johnston.It Vt uint16_t ipv4_ident 152*4b4ad3a2SMark JohnstonIdentification field. 153*4b4ad3a2SMark Johnston.It Vt uint8_t ipv4_flags 154*4b4ad3a2SMark JohnstonThe IP flags. 155*4b4ad3a2SMark Johnston.It Vt uint16_t ipv4_offset 156*4b4ad3a2SMark JohnstonThe fragment offset of the packet. 157*4b4ad3a2SMark Johnston.It Vt uint8_t ipv4_ttl 158*4b4ad3a2SMark JohnstonTime to live field. 159*4b4ad3a2SMark Johnston.It Vt uint8_t ipv4_protocol 160*4b4ad3a2SMark JohnstonNext-level protocol ID. 161*4b4ad3a2SMark Johnston.It Vt string ipv4_protostr 162*4b4ad3a2SMark JohnstonA string containing the name of the encapsulated protocol. 163*4b4ad3a2SMark JohnstonThe protocol strings are defined in the 164*4b4ad3a2SMark Johnston.Va protocol 165*4b4ad3a2SMark Johnstonarray in 166*4b4ad3a2SMark Johnston.Pa /usr/lib/dtrace/ip.d 167*4b4ad3a2SMark Johnston.It Vt uint16_t ipv4_checksum 168*4b4ad3a2SMark JohnstonThe IP checksum. 169*4b4ad3a2SMark Johnston.It Vt ipaddr_t ipv4_src 170*4b4ad3a2SMark JohnstonIPv4 source address. 171*4b4ad3a2SMark Johnston.It Vt ipaddr_t ipv4_dst 172*4b4ad3a2SMark JohnstonIPv4 destination address. 173*4b4ad3a2SMark Johnston.It Vt string ipv4_saddr 174*4b4ad3a2SMark JohnstonA string representation of the source address. 175*4b4ad3a2SMark Johnston.It Vt string ipv4_daddr 176*4b4ad3a2SMark JohnstonA string representation of the destination address. 177*4b4ad3a2SMark Johnston.It Vt ipha_t *ipv4_hdr 178*4b4ad3a2SMark JohnstonA pointer to the raw IPv4 header. 179*4b4ad3a2SMark Johnston.El 180*4b4ad3a2SMark Johnston.Pp 181*4b4ad3a2SMark JohnstonThe 182*4b4ad3a2SMark Johnston.Vt ipv6info_t 183*4b4ad3a2SMark Johnstonargument contains the fields of the IP header for IPv6 packets. 184*4b4ad3a2SMark JohnstonIts fields are not set for IPv4 packets; as with the 185*4b4ad3a2SMark Johnston.Vt ipv4info_t 186*4b4ad3a2SMark Johnstonargument, the 187*4b4ad3a2SMark Johnston.Fn ip_ver 188*4b4ad3a2SMark Johnstonfield should be used to determine whether this argument is valid. 189*4b4ad3a2SMark JohnstonIts fields are: 190*4b4ad3a2SMark Johnston.Bl -tag -width "uint16_t ipv4_checksum" -offset indent 191*4b4ad3a2SMark Johnston.It Vt uint8_t ipv6_ver 192*4b4ad3a2SMark JohnstonIP version. 193*4b4ad3a2SMark JohnstonThis will always be 6 for IPv6 packets. 194*4b4ad3a2SMark Johnston.It Vt uint8_t ipv6_tclass 195*4b4ad3a2SMark JohnstonThe traffic class, used to set the differentiated services codepoint and 196*4b4ad3a2SMark Johnstonextended congestion notification flags. 197*4b4ad3a2SMark Johnston.It Vt uint32_t ipv6_flow 198*4b4ad3a2SMark JohnstonThe flow label of the packet. 199*4b4ad3a2SMark Johnston.It Vt uint16_t ipv6_plen 200*4b4ad3a2SMark JohnstonThe IP payload size, including extension headers, in bytes. 201*4b4ad3a2SMark Johnston.It Vt uint8_t ipv6_nexthdr 202*4b4ad3a2SMark JohnstonAn identifier for the type of the next header. 203*4b4ad3a2SMark Johnston.It Vt string ipv6_nextstr 204*4b4ad3a2SMark JohnstonA string representation of the type of the next header. 205*4b4ad3a2SMark Johnston.It Vt uint8_t ipv6_hlim 206*4b4ad3a2SMark JohnstonThe hop limit. 207*4b4ad3a2SMark Johnston.It Vt ip6_addr_t *ipv6_src 208*4b4ad3a2SMark JohnstonIPv6 source address. 209*4b4ad3a2SMark Johnston.It Vt ip6_addr_t *ipv6_dst 210*4b4ad3a2SMark JohnstonIPv6 destination address. 211*4b4ad3a2SMark Johnston.It Vt string ipv6_saddr 212*4b4ad3a2SMark JohnstonA string representation of the source address. 213*4b4ad3a2SMark Johnston.It Vt string ipv6_daddr 214*4b4ad3a2SMark JohnstonA string representation of the destination address. 215*4b4ad3a2SMark Johnston.It Vt ip6_t *ipv6_hdr 216*4b4ad3a2SMark JohnstonA pointer to the raw IPv6 header. 217*4b4ad3a2SMark Johnston.El 218*4b4ad3a2SMark Johnston.Sh FILES 219*4b4ad3a2SMark Johnston.Bl -tag -width "/usr/lib/dtrace/ip.d" -compact 220*4b4ad3a2SMark Johnston.It Pa /usr/lib/dtrace/ip.d 221*4b4ad3a2SMark JohnstonDTrace type and translator definitions for the 222*4b4ad3a2SMark Johnston.Nm ip 223*4b4ad3a2SMark Johnstonprovider. 224*4b4ad3a2SMark Johnston.El 225*4b4ad3a2SMark Johnston.Sh EXAMPLES 226*4b4ad3a2SMark JohnstonThe following script counts received packets by remote host address. 227*4b4ad3a2SMark Johnston.Bd -literal -offset indent 228*4b4ad3a2SMark Johnstonip:::receive 229*4b4ad3a2SMark Johnston{ 230*4b4ad3a2SMark Johnston @num[args[2]->ip_saddr] = count(); 231*4b4ad3a2SMark Johnston} 232*4b4ad3a2SMark Johnston.Ed 233*4b4ad3a2SMark Johnston.Pp 234*4b4ad3a2SMark JohnstonThis script will print some details of each IP packet as it is sent or received 235*4b4ad3a2SMark Johnstonby the kernel: 236*4b4ad3a2SMark Johnston.Bd -literal -offset indent 237*4b4ad3a2SMark Johnston#pragma D option quiet 238*4b4ad3a2SMark Johnston#pramga D option switchrate=10Hz 239*4b4ad3a2SMark Johnston 240*4b4ad3a2SMark Johnstondtrace:::BEGIN 241*4b4ad3a2SMark Johnston{ 242*4b4ad3a2SMark Johnston printf(" %10s %30s %-30s %8s %6s\n", "DELTA(us)", "SOURCE", 243*4b4ad3a2SMark Johnston "DEST", "INT", "BYTES"); 244*4b4ad3a2SMark Johnston last = timestamp; 245*4b4ad3a2SMark Johnston} 246*4b4ad3a2SMark Johnston 247*4b4ad3a2SMark Johnstonip:::send 248*4b4ad3a2SMark Johnston{ 249*4b4ad3a2SMark Johnston this->elapsed = (timestamp - last) / 1000; 250*4b4ad3a2SMark Johnston printf(" %10d %30s -> %-30s %8s %6d\n", this->elapsed, 251*4b4ad3a2SMark Johnston args[2]->ip_saddr, args[2]->ip_daddr, args[3]->if_name, 252*4b4ad3a2SMark Johnston args[2]->ip_plength); 253*4b4ad3a2SMark Johnston last = timestamp; 254*4b4ad3a2SMark Johnston} 255*4b4ad3a2SMark Johnston 256*4b4ad3a2SMark Johnstonip:::receive 257*4b4ad3a2SMark Johnston{ 258*4b4ad3a2SMark Johnston this->elapsed = (timestamp - last) / 1000; 259*4b4ad3a2SMark Johnston printf(" %10d %30s <- %-30s %8s %6d\n", this->elapsed, 260*4b4ad3a2SMark Johnston args[2]->ip_daddr, args[2]->ip_saddr, args[3]->if_name, 261*4b4ad3a2SMark Johnston args[2]->ip_plength); 262*4b4ad3a2SMark Johnston last = timestamp; 263*4b4ad3a2SMark Johnston} 264*4b4ad3a2SMark Johnston.Ed 265*4b4ad3a2SMark Johnston.Sh COMPATIBILITY 266*4b4ad3a2SMark JohnstonThis provider is compatible with the 267*4b4ad3a2SMark Johnston.Nm ip 268*4b4ad3a2SMark Johnstonproviders found in Solaris and Darwin. 269*4b4ad3a2SMark Johnston.Sh SEE ALSO 270*4b4ad3a2SMark Johnston.Xr dtrace 1 , 271*4b4ad3a2SMark Johnston.Xr dtrace_tcp 4 , 272*4b4ad3a2SMark Johnston.Xr dtrace_udp 4 , 273*4b4ad3a2SMark Johnston.Xr ip 4 , 274*4b4ad3a2SMark Johnston.Xr ip6 4 , 275*4b4ad3a2SMark Johnston.Xr ifnet 9 , 276*4b4ad3a2SMark Johnston.Xr SDT 9 277*4b4ad3a2SMark Johnston.Sh HISTORY 278*4b4ad3a2SMark JohnstonThe 279*4b4ad3a2SMark Johnston.Nm ip 280*4b4ad3a2SMark Johnstonprovider first appeared in 281*4b4ad3a2SMark Johnston.Fx 282*4b4ad3a2SMark Johnston10.0. 283*4b4ad3a2SMark Johnston.Sh AUTHORS 284*4b4ad3a2SMark JohnstonThis manual page was written by 285*4b4ad3a2SMark Johnston.An Mark Johnston Aq Mt markj@FreeBSD.org . 286