14b4ad3a2SMark Johnston.\" Copyright (c) 2015 Mark Johnston <markj@FreeBSD.org> 24b4ad3a2SMark Johnston.\" All rights reserved. 34b4ad3a2SMark Johnston.\" 44b4ad3a2SMark Johnston.\" Redistribution and use in source and binary forms, with or without 54b4ad3a2SMark Johnston.\" modification, are permitted provided that the following conditions 64b4ad3a2SMark Johnston.\" are met: 74b4ad3a2SMark Johnston.\" 1. Redistributions of source code must retain the above copyright 84b4ad3a2SMark Johnston.\" notice, this list of conditions and the following disclaimer. 94b4ad3a2SMark Johnston.\" 2. Redistributions in binary form must reproduce the above copyright 104b4ad3a2SMark Johnston.\" notice, this list of conditions and the following disclaimer in the 114b4ad3a2SMark Johnston.\" documentation and/or other materials provided with the distribution. 124b4ad3a2SMark Johnston.\" 134b4ad3a2SMark Johnston.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 144b4ad3a2SMark Johnston.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 154b4ad3a2SMark Johnston.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 164b4ad3a2SMark Johnston.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 174b4ad3a2SMark Johnston.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 184b4ad3a2SMark Johnston.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 194b4ad3a2SMark Johnston.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 204b4ad3a2SMark Johnston.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 214b4ad3a2SMark Johnston.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 224b4ad3a2SMark Johnston.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 234b4ad3a2SMark Johnston.\" SUCH DAMAGE. 244b4ad3a2SMark Johnston.\" 25c50c3318SMark Johnston.Dd September 14, 2015 264b4ad3a2SMark Johnston.Dt DTRACE_IP 4 274b4ad3a2SMark Johnston.Os 284b4ad3a2SMark Johnston.Sh NAME 294b4ad3a2SMark Johnston.Nm dtrace_ip 304b4ad3a2SMark Johnston.Nd a DTrace provider for tracing events related to the IPv4 and IPv6 protocols 314b4ad3a2SMark Johnston.Sh SYNOPSIS 324b4ad3a2SMark Johnston.Fn ip:::receive "pktinfo_t *" "csinfo_t *" "ipinfo_t *" "ifinfo_t *" \ 334b4ad3a2SMark Johnston "ipv4info_t *" "ipv6info_t *" 344b4ad3a2SMark Johnston.Fn ip:::send "pktinfo_t *" "csinfo_t *" "ipinfo_t *" "ifinfo_t *" \ 354b4ad3a2SMark Johnston "ipv4info_t *" "ipv6info_t *" 364b4ad3a2SMark Johnston.Sh DESCRIPTION 374b4ad3a2SMark JohnstonThe DTrace 384b4ad3a2SMark Johnston.Nm ip 394b4ad3a2SMark Johnstonprovider allows users to trace events in the 404b4ad3a2SMark Johnston.Xr ip 4 414b4ad3a2SMark Johnstonand 424b4ad3a2SMark Johnston.Xr ip6 4 434b4ad3a2SMark Johnstonprotocol implementations. 444b4ad3a2SMark JohnstonThe 454b4ad3a2SMark Johnston.Fn ip:::send 464b4ad3a2SMark Johnstonprobe fires whenever the kernel prepares to transmit an IP packet, and the 474b4ad3a2SMark Johnston.Fn ip:::receive 484b4ad3a2SMark Johnstonprobe fires whenever the kernel receives an IP packet. 494b4ad3a2SMark JohnstonThe arguments to these probes can be used to obtain detailed information about 504b4ad3a2SMark Johnstonthe IP headers of the corresponding packet, as well as the network interface on 514b4ad3a2SMark Johnstonwhich the packet was sent or received. 524b4ad3a2SMark JohnstonUnlike the 534b4ad3a2SMark Johnston.Xr dtrace_tcp 4 544b4ad3a2SMark Johnstonand 554b4ad3a2SMark Johnston.Xr dtrace_udp 4 564b4ad3a2SMark Johnstonproviders, 574b4ad3a2SMark Johnston.Nm ip 584b4ad3a2SMark Johnstonprovider probes are triggered by forwarded packets. 594b4ad3a2SMark JohnstonThat is, the probes will fire on packets that are not destined to the local 604b4ad3a2SMark Johnstonhost. 614b4ad3a2SMark Johnston.Sh ARGUMENTS 624b4ad3a2SMark JohnstonThe 634b4ad3a2SMark Johnston.Vt pktinfo_t 644b4ad3a2SMark Johnstonargument is currently unimplemented and is included for compatibility with other 654b4ad3a2SMark Johnstonimplementations of this provider. 664b4ad3a2SMark JohnstonIts fields are: 674b4ad3a2SMark Johnston.Bl -tag -width "uintptr_t pkt_addr" -offset indent 684b4ad3a2SMark Johnston.It Vt uintptr_t pkt_addr 694b4ad3a2SMark JohnstonAlways set to 0. 704b4ad3a2SMark Johnston.El 714b4ad3a2SMark Johnston.Pp 724b4ad3a2SMark JohnstonThe 734b4ad3a2SMark Johnston.Vt csinfo_t 744b4ad3a2SMark Johnstonargument is currently unimplemented and is included for compatibility with other 754b4ad3a2SMark Johnstonimplementations of this provider. 764b4ad3a2SMark JohnstonIts fields are: 774b4ad3a2SMark Johnston.Bl -tag -width "uintptr_t cs_addr" -offset indent 784b4ad3a2SMark Johnston.It Vt uintptr_t cs_addr 794b4ad3a2SMark JohnstonAlways set to 0. 804b4ad3a2SMark Johnston.It Vt uint64_t cs_cid 814b4ad3a2SMark JohnstonA pointer to the 824b4ad3a2SMark Johnston.Vt struct inpcb 834b4ad3a2SMark Johnstonfor this packet, or 844b4ad3a2SMark Johnston.Dv NULL . 854b4ad3a2SMark Johnston.It Vt pid_t cs_pid 864b4ad3a2SMark JohnstonAlways set to 0. 874b4ad3a2SMark Johnston.El 884b4ad3a2SMark Johnston.Pp 894b4ad3a2SMark JohnstonThe 904b4ad3a2SMark Johnston.Vt ipinfo_t 914b4ad3a2SMark Johnstonargument contains IP fields common to both IPv4 and IPv6 packets. 924b4ad3a2SMark JohnstonIts fields are: 934b4ad3a2SMark Johnston.Bl -tag -width "uint32_t ip_plength" -offset indent 944b4ad3a2SMark Johnston.It Vt uint8_t ip_ver 954b4ad3a2SMark JohnstonIP version of the packet, 4 for IPv4 packets and 6 for IPv6 packets. 964b4ad3a2SMark Johnston.It Vt uint32_t ip_plength 974b4ad3a2SMark JohnstonIP payload size. 984b4ad3a2SMark JohnstonThis does not include the size of the IP header or IPv6 option headers. 994b4ad3a2SMark Johnston.It Vt string ip_saddr 1004b4ad3a2SMark JohnstonIP source address. 1014b4ad3a2SMark Johnston.It Vt string ip_daddr 1024b4ad3a2SMark JohnstonIP destination address. 1034b4ad3a2SMark Johnston.El 1044b4ad3a2SMark Johnston.Pp 1054b4ad3a2SMark JohnstonThe 1064b4ad3a2SMark Johnston.Vt ifinfo_t 1074b4ad3a2SMark Johnstonargument describes the outgoing and incoming interfaces for the packet in the 1084b4ad3a2SMark Johnston.Fn ip:::send 1094b4ad3a2SMark Johnstonand 1104b4ad3a2SMark Johnston.Fn ip:::receive 1114b4ad3a2SMark Johnstonprobes respectively. 1124b4ad3a2SMark JohnstonIts fields are: 1134b4ad3a2SMark Johnston.Bl -tag -width "uintptr_t if_addr" -offset indent 1144b4ad3a2SMark Johnston.It Vt string if_name 1154b4ad3a2SMark JohnstonThe interface name. 1164b4ad3a2SMark Johnston.It Vt int8_t if_local 1174b4ad3a2SMark JohnstonA boolean value indicating whether or not the interface is a loopback interface. 1184b4ad3a2SMark Johnston.It Vt uintptr_t if_addr 1194b4ad3a2SMark JohnstonA pointer to the 1204b4ad3a2SMark Johnston.Vt struct ifnet 1214b4ad3a2SMark Johnstonwhich describes the interface. 1224b4ad3a2SMark JohnstonSee the 1234b4ad3a2SMark Johnston.Xr ifnet 9 1244b4ad3a2SMark Johnstonmanual page. 1254b4ad3a2SMark Johnston.El 1264b4ad3a2SMark Johnston.Pp 1274b4ad3a2SMark JohnstonThe 1284b4ad3a2SMark Johnston.Vt ipv4info_t 1294b4ad3a2SMark Johnstonargument contains the fields of the IP header for IPv4 packets. 1304b4ad3a2SMark JohnstonThis argument is 1314b4ad3a2SMark Johnston.Dv NULL 1324b4ad3a2SMark Johnstonfor IPv6 packets. 1334b4ad3a2SMark JohnstonDTrace scripts should use the 1344b4ad3a2SMark Johnston.Fn ip_ver 1354b4ad3a2SMark Johnstonfield in the 1364b4ad3a2SMark Johnston.Vt ipinfo_t 1374b4ad3a2SMark Johnstonargument to determine whether to use this argument. 1384b4ad3a2SMark JohnstonIts fields are: 1394b4ad3a2SMark Johnston.Bl -tag -width "uint16_t ipv4_checksum" -offset indent 1404b4ad3a2SMark Johnston.It Vt uint8_t ipv4_ver 1414b4ad3a2SMark JohnstonIP version. 1424b4ad3a2SMark JohnstonThis will always be 4 for IPv4 packets. 1434b4ad3a2SMark Johnston.It Vt uint8_t ipv4_ihl 1444b4ad3a2SMark JohnstonThe IP header length, including options, in 32-bit words. 1454b4ad3a2SMark Johnston.It Vt uint8_t ipv4_tos 1464b4ad3a2SMark JohnstonIP type of service field. 1474b4ad3a2SMark Johnston.It Vt uint16_t ipv4_length 1484b4ad3a2SMark JohnstonThe total packet length, including the header, in bytes. 1494b4ad3a2SMark Johnston.It Vt uint16_t ipv4_ident 1504b4ad3a2SMark JohnstonIdentification field. 1514b4ad3a2SMark Johnston.It Vt uint8_t ipv4_flags 1524b4ad3a2SMark JohnstonThe IP flags. 1534b4ad3a2SMark Johnston.It Vt uint16_t ipv4_offset 1544b4ad3a2SMark JohnstonThe fragment offset of the packet. 1554b4ad3a2SMark Johnston.It Vt uint8_t ipv4_ttl 1564b4ad3a2SMark JohnstonTime to live field. 1574b4ad3a2SMark Johnston.It Vt uint8_t ipv4_protocol 1584b4ad3a2SMark JohnstonNext-level protocol ID. 1594b4ad3a2SMark Johnston.It Vt string ipv4_protostr 1604b4ad3a2SMark JohnstonA string containing the name of the encapsulated protocol. 1614b4ad3a2SMark JohnstonThe protocol strings are defined in the 1624b4ad3a2SMark Johnston.Va protocol 1634b4ad3a2SMark Johnstonarray in 1644b4ad3a2SMark Johnston.Pa /usr/lib/dtrace/ip.d 1654b4ad3a2SMark Johnston.It Vt uint16_t ipv4_checksum 1664b4ad3a2SMark JohnstonThe IP checksum. 1674b4ad3a2SMark Johnston.It Vt ipaddr_t ipv4_src 1684b4ad3a2SMark JohnstonIPv4 source address. 1694b4ad3a2SMark Johnston.It Vt ipaddr_t ipv4_dst 1704b4ad3a2SMark JohnstonIPv4 destination address. 1714b4ad3a2SMark Johnston.It Vt string ipv4_saddr 1724b4ad3a2SMark JohnstonA string representation of the source address. 1734b4ad3a2SMark Johnston.It Vt string ipv4_daddr 1744b4ad3a2SMark JohnstonA string representation of the destination address. 1754b4ad3a2SMark Johnston.It Vt ipha_t *ipv4_hdr 1764b4ad3a2SMark JohnstonA pointer to the raw IPv4 header. 1774b4ad3a2SMark Johnston.El 1784b4ad3a2SMark Johnston.Pp 1794b4ad3a2SMark JohnstonThe 1804b4ad3a2SMark Johnston.Vt ipv6info_t 1814b4ad3a2SMark Johnstonargument contains the fields of the IP header for IPv6 packets. 1824b4ad3a2SMark JohnstonIts fields are not set for IPv4 packets; as with the 1834b4ad3a2SMark Johnston.Vt ipv4info_t 1844b4ad3a2SMark Johnstonargument, the 1854b4ad3a2SMark Johnston.Fn ip_ver 1864b4ad3a2SMark Johnstonfield should be used to determine whether this argument is valid. 1874b4ad3a2SMark JohnstonIts fields are: 1884b4ad3a2SMark Johnston.Bl -tag -width "uint16_t ipv4_checksum" -offset indent 1894b4ad3a2SMark Johnston.It Vt uint8_t ipv6_ver 1904b4ad3a2SMark JohnstonIP version. 1914b4ad3a2SMark JohnstonThis will always be 6 for IPv6 packets. 1924b4ad3a2SMark Johnston.It Vt uint8_t ipv6_tclass 1934b4ad3a2SMark JohnstonThe traffic class, used to set the differentiated services codepoint and 1944b4ad3a2SMark Johnstonextended congestion notification flags. 1954b4ad3a2SMark Johnston.It Vt uint32_t ipv6_flow 1964b4ad3a2SMark JohnstonThe flow label of the packet. 1974b4ad3a2SMark Johnston.It Vt uint16_t ipv6_plen 1984b4ad3a2SMark JohnstonThe IP payload size, including extension headers, in bytes. 1994b4ad3a2SMark Johnston.It Vt uint8_t ipv6_nexthdr 2004b4ad3a2SMark JohnstonAn identifier for the type of the next header. 2014b4ad3a2SMark Johnston.It Vt string ipv6_nextstr 2024b4ad3a2SMark JohnstonA string representation of the type of the next header. 2034b4ad3a2SMark Johnston.It Vt uint8_t ipv6_hlim 2044b4ad3a2SMark JohnstonThe hop limit. 2054b4ad3a2SMark Johnston.It Vt ip6_addr_t *ipv6_src 2064b4ad3a2SMark JohnstonIPv6 source address. 2074b4ad3a2SMark Johnston.It Vt ip6_addr_t *ipv6_dst 2084b4ad3a2SMark JohnstonIPv6 destination address. 2094b4ad3a2SMark Johnston.It Vt string ipv6_saddr 2104b4ad3a2SMark JohnstonA string representation of the source address. 2114b4ad3a2SMark Johnston.It Vt string ipv6_daddr 2124b4ad3a2SMark JohnstonA string representation of the destination address. 213c50c3318SMark Johnston.It Vt struct ip6_hdr *ipv6_hdr 2144b4ad3a2SMark JohnstonA pointer to the raw IPv6 header. 2154b4ad3a2SMark Johnston.El 2164b4ad3a2SMark Johnston.Sh FILES 2174b4ad3a2SMark Johnston.Bl -tag -width "/usr/lib/dtrace/ip.d" -compact 2184b4ad3a2SMark Johnston.It Pa /usr/lib/dtrace/ip.d 2194b4ad3a2SMark JohnstonDTrace type and translator definitions for the 2204b4ad3a2SMark Johnston.Nm ip 2214b4ad3a2SMark Johnstonprovider. 2224b4ad3a2SMark Johnston.El 2234b4ad3a2SMark Johnston.Sh EXAMPLES 2244b4ad3a2SMark JohnstonThe following script counts received packets by remote host address. 2254b4ad3a2SMark Johnston.Bd -literal -offset indent 2264b4ad3a2SMark Johnstonip:::receive 2274b4ad3a2SMark Johnston{ 2284b4ad3a2SMark Johnston @num[args[2]->ip_saddr] = count(); 2294b4ad3a2SMark Johnston} 2304b4ad3a2SMark Johnston.Ed 2314b4ad3a2SMark Johnston.Pp 2324b4ad3a2SMark JohnstonThis script will print some details of each IP packet as it is sent or received 2334b4ad3a2SMark Johnstonby the kernel: 2344b4ad3a2SMark Johnston.Bd -literal -offset indent 2354b4ad3a2SMark Johnston#pragma D option quiet 236*9893b9b1SMark Johnston#pragma D option switchrate=10Hz 2374b4ad3a2SMark Johnston 2384b4ad3a2SMark Johnstondtrace:::BEGIN 2394b4ad3a2SMark Johnston{ 240af1e9f5aSChristian Brueffer printf(" %10s %30s %-30s %8s %6s\\n", "DELTA(us)", "SOURCE", 2414b4ad3a2SMark Johnston "DEST", "INT", "BYTES"); 2424b4ad3a2SMark Johnston last = timestamp; 2434b4ad3a2SMark Johnston} 2444b4ad3a2SMark Johnston 2454b4ad3a2SMark Johnstonip:::send 2464b4ad3a2SMark Johnston{ 2474b4ad3a2SMark Johnston this->elapsed = (timestamp - last) / 1000; 248af1e9f5aSChristian Brueffer printf(" %10d %30s -> %-30s %8s %6d\\n", this->elapsed, 2494b4ad3a2SMark Johnston args[2]->ip_saddr, args[2]->ip_daddr, args[3]->if_name, 2504b4ad3a2SMark Johnston args[2]->ip_plength); 2514b4ad3a2SMark Johnston last = timestamp; 2524b4ad3a2SMark Johnston} 2534b4ad3a2SMark Johnston 2544b4ad3a2SMark Johnstonip:::receive 2554b4ad3a2SMark Johnston{ 2564b4ad3a2SMark Johnston this->elapsed = (timestamp - last) / 1000; 257af1e9f5aSChristian Brueffer printf(" %10d %30s <- %-30s %8s %6d\\n", this->elapsed, 2584b4ad3a2SMark Johnston args[2]->ip_daddr, args[2]->ip_saddr, args[3]->if_name, 2594b4ad3a2SMark Johnston args[2]->ip_plength); 2604b4ad3a2SMark Johnston last = timestamp; 2614b4ad3a2SMark Johnston} 2624b4ad3a2SMark Johnston.Ed 2634b4ad3a2SMark Johnston.Sh COMPATIBILITY 2644b4ad3a2SMark JohnstonThis provider is compatible with the 2654b4ad3a2SMark Johnston.Nm ip 2664b4ad3a2SMark Johnstonproviders found in Solaris and Darwin. 2674b4ad3a2SMark Johnston.Sh SEE ALSO 2684b4ad3a2SMark Johnston.Xr dtrace 1 , 2694b4ad3a2SMark Johnston.Xr dtrace_tcp 4 , 2704b4ad3a2SMark Johnston.Xr dtrace_udp 4 , 2714b4ad3a2SMark Johnston.Xr ip 4 , 2724b4ad3a2SMark Johnston.Xr ip6 4 , 2734b4ad3a2SMark Johnston.Xr ifnet 9 , 2744b4ad3a2SMark Johnston.Xr SDT 9 2754b4ad3a2SMark Johnston.Sh HISTORY 2764b4ad3a2SMark JohnstonThe 2774b4ad3a2SMark Johnston.Nm ip 2784b4ad3a2SMark Johnstonprovider first appeared in 2794b4ad3a2SMark Johnston.Fx 2804b4ad3a2SMark Johnston10.0. 2814b4ad3a2SMark Johnston.Sh AUTHORS 2824b4ad3a2SMark JohnstonThis manual page was written by 2834b4ad3a2SMark Johnston.An Mark Johnston Aq Mt markj@FreeBSD.org . 284