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