Index: head/contrib/traceroute/traceroute.8 =================================================================== --- head/contrib/traceroute/traceroute.8 (revision 368045) +++ head/contrib/traceroute/traceroute.8 (revision 368046) @@ -1,398 +1,397 @@ .\" Copyright (c) 1989, 1995, 1996, 1997, 1999, 2000 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms are permitted .\" provided that the above copyright notice and this paragraph are .\" duplicated in all such forms and that any documentation, .\" advertising materials, and other materials related to such .\" distribution and use acknowledge that the software was developed .\" by the University of California, Berkeley. The name of the .\" University may not be used to endorse or promote products derived .\" from this software without specific prior written permission. .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED .\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. .\" .\" $Id: traceroute.8,v 1.19 2000/09/21 08:44:19 leres Exp $ .\" $FreeBSD$ .\" -.Dd June 20, 2019 +.Dd November 25, 2020 .Dt TRACEROUTE 8 .Os .Sh NAME .Nm traceroute .Nd "print the route packets take to network host" .Sh SYNOPSIS .Nm .Bk -words .Op Fl adDeFISnrvx .Op Fl f Ar first_ttl .Op Fl g Ar gateway .Op Fl M Ar first_ttl .Op Fl m Ar max_ttl .Op Fl P Ar proto .Op Fl p Ar port .Op Fl q Ar nprobes .Op Fl s Ar src_addr .Op Fl t Ar tos .Op Fl w Ar waittime .Op Fl A Ar as_server .Op Fl z Ar pausemsecs .Ar host .Op Ar packetlen .Ek .Sh DESCRIPTION The Internet is a large and complex aggregation of network hardware, connected together by gateways. Tracking the route one's packets follow (or finding the miscreant gateway that's discarding your packets) can be difficult. .Nm utilizes the IP protocol `time to live' field and attempts to elicit an ICMP TIME_EXCEEDED response from each gateway along the path to some host. .Pp The only mandatory parameter is the destination host name or IP number. The default probe datagram length is 40 bytes, but this may be increased by specifying a packet length (in bytes) after the destination host name. .Pp Other options are: .Bl -tag -width Ds .It Fl a Turn on AS# lookups for each hop encountered. .It Fl A Ar as_server Turn on AS# lookups and use the given server instead of the default. .It Fl e Firewall evasion mode. Use fixed destination ports for UDP, UDP-Lite, TCP and SCTP probes. The destination port does NOT increment with each packet sent. .It Fl f Ar first_ttl Set the initial time-to-live used in the first outgoing probe packet. .It Fl F Set the "don't fragment" bit. .It Fl d Enable socket level debugging. .It Fl D When an ICMP response to our probe datagram is received, print the differences between the transmitted packet and the packet quoted by the ICMP response. A key showing the location of fields within the transmitted packet is printed, followed by the original packet in hex, followed by the quoted packet in hex. Bytes that are unchanged in the quoted packet are shown as underscores. Note, the IP checksum and the TTL of the quoted packet are not expected to match. By default, only one probe per hop is sent with this option. .It Fl g Ar gateway Specify a loose source route gateway (8 maximum). .It Fl i Ar iface Specify a network interface to obtain the source IP address for outgoing probe packets. This is normally only useful on a multi-homed host. (See the .Fl s flag for another way to do this.) .It Fl I Use ICMP ECHO instead of UDP datagrams. (A synonym for "-P icmp"). .It Fl M Ar first_ttl Set the initial time-to-live value used in outgoing probe packets. The default is 1, i.e., start with the first hop. .It Fl m Ar max_ttl Set the max time-to-live (max number of hops) used in outgoing probe packets. The default is the value of the .Va net.inet.ip.ttl .Xr sysctl 8 (the same default used for TCP connections). .It Fl n Print hop addresses numerically rather than symbolically and numerically (saves a nameserver address-to-name lookup for each gateway found on the path). .It Fl P Ar proto Send packets of specified IP protocol. The currently supported protocols are: UDP, UDP-Lite, TCP, SCTP, GRE and ICMP. Other protocols may also be specified (either by name or by number), though .Nm does not implement any special knowledge of their packet formats. This option is useful for determining which router along a path may be blocking packets based on IP protocol number. But see BUGS below. .It Fl p Ar port Protocol specific. For UDP, UDP-Lite, TCP and SCTP, sets the base .Ar port number used in probes (default is 33434). Traceroute hopes that nothing is listening on UDP ports (or UDP-Lite ports if used by .Nm and supported by the peer) .Em port + 1 to .Em port + (max_ttl - first_ttl + 1) * nprobes at the destination host (so an ICMP PORT_UNREACHABLE message will be returned to terminate the route tracing). If something is listening on a port in the default range, this option can be used to pick an unused port range. .It Fl q Ar nprobes Set the number of probes per hop (default is 3, unless .Fl D is specified, when it is 1). .It Fl r Bypass the normal routing tables and send directly to a host on an attached network. If the host is not on a directly-attached network, an error is returned. This option can be used to ping a local host through an interface that has no route through it (e.g., after the interface was dropped by .Xr routed 8 . .It Fl s Ar src_addr Use the following IP address (which usually is given as an IP number, not a hostname) as the source address in outgoing probe packets. On multi-homed hosts (those with more than one IP address), this option can be used to force the source address to be something other than the IP address of the interface the probe packet is sent on. If the IP address is not one of this machine's interface addresses, an error is returned and nothing is sent. (See the .Fl i flag for another way to do this.) .It Fl S Print a summary of how many probes were not answered for each hop. .It Fl t Ar tos Set the .Em type-of-service in probe packets to the following value (default zero). The value must be a decimal integer in the range 0 to 255. This option can be used to see if different types-of-service result in different paths. (If you are not running 4.4bsd, this may be academic since the normal network services like telnet and ftp don't let you control the TOS). Not all values of TOS are legal or meaningful \- see the IP spec for definitions. Useful values are probably .Fl t Ar 16 (low delay) and .Fl t Ar 8 (high throughput). .It Fl v Verbose output. Received ICMP packets other than .Dv TIME_EXCEEDED and .Dv UNREACHABLE Ns s are listed. .It Fl w Ar waittime Set the time (in seconds) to wait for a response to a probe (default 5 sec.). .It Fl x Toggle ip checksums. Normally, this prevents traceroute from calculating ip checksums. In some cases, the operating system can overwrite parts of the outgoing packet but not recalculate the checksum (so in some cases the default is to not calculate checksums and using .Fl x causes them to be calculated). Note that checksums are usually required for the last hop when using ICMP ECHO probes .Pq Fl I . So they are always calculated when using ICMP. .It Fl z Ar pausemsecs Set the time (in milliseconds) to pause between probes (default 0). Some systems such as Solaris and routers such as Ciscos rate limit icmp messages. A good value to use with this this is 500 (e.g. 1/2 second). .El .Pp This program attempts to trace the route an IP packet would follow to some internet host by launching UDP probe packets with a small ttl (time to live) then listening for an ICMP "time exceeded" reply from a gateway. We start our probes with a ttl of one and increase by one until we get an ICMP "port unreachable" (which means we got to "host") or hit a max (which defaults to the amount of hops specified by the .Va net.inet.ip.ttl .Xr sysctl 8 and can be changed with the .Fl m flag). Three probes (change with .Fl q flag) are sent at each ttl setting and a line is printed showing the ttl, address of the gateway and round trip time of each probe. If the probe answers come from different gateways, the address of each responding system will be printed. If there is no response within a 5 sec. timeout interval (changed with the .Fl w flag), a "*" is printed for that probe. .Pp We don't want the destination host to process the UDP probe packets so the destination port is set to an unlikely value (if some clod on the destination is using that value, it can be changed with the .Fl p flag). .Pp A sample use and output might be: .Bd -literal -offset 4n % traceroute nis.nsf.net. traceroute to nis.nsf.net (35.1.1.48), 64 hops max, 38 byte packet 1 helios.ee.lbl.gov (128.3.112.1) 19 ms 19 ms 0 ms 2 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 39 ms 19 ms 3 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 39 ms 19 ms 4 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 39 ms 40 ms 39 ms 5 ccn-nerif22.Berkeley.EDU (128.32.168.22) 39 ms 39 ms 39 ms 6 128.32.197.4 (128.32.197.4) 40 ms 59 ms 59 ms 7 131.119.2.5 (131.119.2.5) 59 ms 59 ms 59 ms 8 129.140.70.13 (129.140.70.13) 99 ms 99 ms 80 ms 9 129.140.71.6 (129.140.71.6) 139 ms 239 ms 319 ms 10 129.140.81.7 (129.140.81.7) 220 ms 199 ms 199 ms 11 nic.merit.edu (35.1.1.48) 239 ms 239 ms 239 ms .Ed .Pp Note that lines 2 & 3 are the same. This is due to a buggy kernel on the 2nd hop system \- lilac-dmc.Berkeley.EDU \- that forwards packets with a zero ttl (a bug in the distributed version of 4.3BSD). Note that you have to guess what path the packets are taking cross-country since the NSFNet (129.140) doesn't supply address-to-name translations for its NSSes. .Pp A more interesting example is: .Bd -literal -offset 4n % traceroute allspice.lcs.mit.edu. traceroute to allspice.lcs.mit.edu (18.26.0.115), 64 hops max 1 helios.ee.lbl.gov (128.3.112.1) 0 ms 0 ms 0 ms 2 lilac-dmc.Berkeley.EDU (128.32.216.1) 19 ms 19 ms 19 ms 3 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 19 ms 19 ms 4 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 19 ms 39 ms 39 ms 5 ccn-nerif22.Berkeley.EDU (128.32.168.22) 20 ms 39 ms 39 ms 6 128.32.197.4 (128.32.197.4) 59 ms 119 ms 39 ms 7 131.119.2.5 (131.119.2.5) 59 ms 59 ms 39 ms 8 129.140.70.13 (129.140.70.13) 80 ms 79 ms 99 ms 9 129.140.71.6 (129.140.71.6) 139 ms 139 ms 159 ms 10 129.140.81.7 (129.140.81.7) 199 ms 180 ms 300 ms 11 129.140.72.17 (129.140.72.17) 300 ms 239 ms 239 ms 12 * * * 13 128.121.54.72 (128.121.54.72) 259 ms 499 ms 279 ms 14 * * * 15 * * * 16 * * * 17 * * * 18 ALLSPICE.LCS.MIT.EDU (18.26.0.115) 339 ms 279 ms 279 ms .Ed .Pp Note that the gateways 12, 14, 15, 16 & 17 hops away either don't send ICMP "time exceeded" messages or send them with a ttl too small to reach us. 14 \- 17 are running the MIT C Gateway code that doesn't send "time exceeded"s. God only knows what's going on with 12. .Pp The silent gateway 12 in the above may be the result of a bug in the 4.[23]BSD network code (and its derivatives): 4.x (x <= 3) sends an unreachable message using whatever ttl remains in the original datagram. Since, for gateways, the remaining ttl is zero, the ICMP "time exceeded" is guaranteed to not make it back to us. The behavior of this bug is slightly more interesting when it appears on the destination system: .Bd -literal -offset 4n 1 helios.ee.lbl.gov (128.3.112.1) 0 ms 0 ms 0 ms 2 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 19 ms 39 ms 3 lilac-dmc.Berkeley.EDU (128.32.216.1) 19 ms 39 ms 19 ms 4 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 39 ms 40 ms 19 ms 5 ccn-nerif35.Berkeley.EDU (128.32.168.35) 39 ms 39 ms 39 ms 6 csgw.Berkeley.EDU (128.32.133.254) 39 ms 59 ms 39 ms 7 * * * 8 * * * 9 * * * 10 * * * 11 * * * 12 * * * 13 rip.Berkeley.EDU (128.32.131.22) 59 ms ! 39 ms ! 39 ms ! .Ed .Pp Notice that there are 12 "gateways" (13 is the final destination) and exactly the last half of them are "missing". What's really happening is that rip (a Sun-3 running Sun OS3.5) is using the ttl from our arriving datagram as the ttl in its ICMP reply. So, the reply will time out on the return path (with no notice sent to anyone since ICMP's aren't sent for ICMP's) until we probe with a ttl that's at least twice the path length. I.e., rip is really only 7 hops away. A reply that returns with a ttl of 1 is a clue this problem exists. Traceroute prints a "!" after the time if the ttl is <= 1. Since vendors ship a lot of obsolete .Pf ( Tn DEC Ns \'s Ultrix, Sun 3.x) or non-standard .Pq Tn HP-UX software, expect to see this problem frequently and/or take care picking the target host of your probes. .Pp Other possible annotations after the time are: .Bl -hang -offset indent -width 12n .It Sy !H Host unreachable. .It Sy !N Network unreachable. .It Sy !P Protocol unreachable. .It Sy !S Source route failed. .It Sy !F\- Fragmentation needed. The RFC1191 Path MTU Discovery value is displayed. .It Sy !U Destination network unknown. .It Sy !W Destination host unknown. .It Sy !I Source host is isolated. .It Sy !A Communication with destination network administratively prohibited. .It Sy !Z Communication with destination host administratively prohibited. .It Sy !Q For this ToS the destination network is unreachable. .It Sy !T For this ToS the destination host is unreachable. .It Sy !X Communication administratively prohibited. .It Sy !V Host precedence violation. .It Sy !C Precedence cutoff in effect. .It Sy ! ICMP unreachable code . .El .Pp These are defined by RFC1812 (which supersedes RFC1716). If almost all the probes result in some kind of unreachable, .Nm will give up and exit. .Pp This program is intended for use in network testing, measurement and management. It should be used primarily for manual fault isolation. Because of the load it could impose on the network, it is unwise to use .Nm during normal operations or from automated scripts. .Sh SEE ALSO .Xr netstat 1 , .Xr ping 8 , -.Xr ping6 8 , .Xr traceroute6 8 . .Sh AUTHORS Implemented by Van Jacobson from a suggestion by Steve Deering. Debugged by a cast of thousands with particularly cogent suggestions or fixes from C. Philip Wood, Tim Seaver and Ken Adelman. .Sh BUGS When using protocols other than UDP, functionality is reduced. In particular, the last packet will often appear to be lost, because even though it reaches the destination host, there's no way to know that because no ICMP message is sent back. In the TCP case, .Nm should listen for a RST from the destination host (or an intermediate router that's filtering packets), but this is not implemented yet. .Pp The AS number capability reports information that may sometimes be inaccurate due to discrepancies between the contents of the routing database server and the current state of the Internet. Index: head/share/man/man4/inet6.4 =================================================================== --- head/share/man/man4/inet6.4 (revision 368045) +++ head/share/man/man4/inet6.4 (revision 368046) @@ -1,460 +1,460 @@ .\" $KAME: inet6.4,v 1.21 2001/04/05 01:00:18 itojun Exp $ .\" .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the project nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" -.Dd August 14, 2018 +.Dd November 25, 2020 .Dt INET6 4 .Os .Sh NAME .Nm inet6 .Nd Internet protocol version 6 family .Sh SYNOPSIS .In sys/types.h .In netinet/in.h .Sh DESCRIPTION The .Nm family is an updated version of .Xr inet 4 family. While .Xr inet 4 implements Internet Protocol version 4, .Nm implements Internet Protocol version 6. .Pp .Nm is a collection of protocols layered atop the .Em Internet Protocol version 6 .Pq Tn IPv6 transport layer, and utilizing the IPv6 address format. The .Nm family provides protocol support for the .Dv SOCK_STREAM , SOCK_DGRAM , and .Dv SOCK_RAW socket types; the .Dv SOCK_RAW interface provides access to the .Tn IPv6 protocol. .Sh ADDRESSING IPv6 addresses are 16 byte quantities, stored in network standard byteorder. The include file .In netinet/in.h defines this address as a discriminated union. .Pp Sockets bound to the .Nm family utilize the following addressing structure: .Bd -literal -offset indent struct sockaddr_in6 { uint8_t sin6_len; sa_family_t sin6_family; in_port_t sin6_port; uint32_t sin6_flowinfo; struct in6_addr sin6_addr; uint32_t sin6_scope_id; }; .Ed .Pp Sockets may be created with the local address .Dq Dv :: (which is equal to IPv6 address .Dv 0:0:0:0:0:0:0:0 ) to affect .Dq wildcard matching on incoming messages. .Pp The IPv6 specification defines scoped addresses, like link-local or site-local addresses. A scoped address is ambiguous to the kernel, if it is specified without a scope identifier. To manipulate scoped addresses properly from the userland, programs must use the advanced API defined in RFC2292. A compact description of the advanced API is available in .Xr ip6 4 . If a scoped address is specified without an explicit scope, the kernel may raise an error. Note that scoped addresses are not for daily use at this moment, both from a specification and an implementation point of view. .Pp The KAME implementation supports an extended numeric IPv6 address notation for link-local addresses, like .Dq Li fe80::1%de0 to specify .Do .Li fe80::1 on .Li de0 interface .Dc . This notation is supported by .Xr getaddrinfo 3 and .Xr getnameinfo 3 . Some of normal userland programs, such as .Xr telnet 1 or .Xr ftp 1 , are able to use this notation. With special programs like -.Xr ping6 8 , +.Xr ping 8 , you can specify the outgoing interface by an extra command line option to disambiguate scoped addresses. .Pp Scoped addresses are handled specially in the kernel. In kernel structures like routing tables or interface structures, a scoped address will have its interface index embedded into the address. Therefore, the address in some kernel structures is not the same as that on the wire. The embedded index will become visible through a .Dv PF_ROUTE socket, kernel memory accesses via .Xr kvm 3 and on some other occasions. HOWEVER, users should never use the embedded form. For details please consult .Pa IMPLEMENTATION supplied with KAME kit. .Sh PROTOCOLS The .Nm family is comprised of the .Tn IPv6 network protocol, Internet Control Message Protocol version 6 .Pq Tn ICMPv6 , Transmission Control Protocol .Pq Tn TCP , and User Datagram Protocol .Pq Tn UDP . .Tn TCP is used to support the .Dv SOCK_STREAM abstraction while .Tn UDP is used to support the .Dv SOCK_DGRAM abstraction. Note that .Tn TCP and .Tn UDP are common to .Xr inet 4 and .Nm . A raw interface to .Tn IPv6 is available by creating an Internet socket of type .Dv SOCK_RAW . The .Tn ICMPv6 message protocol is accessible from a raw socket. .Ss MIB Variables A number of variables are implemented in the net.inet6 branch of the .Xr sysctl 3 MIB. In addition to the variables supported by the transport protocols (for which the respective manual pages may be consulted), the following general variables are defined: .Bl -tag -width IPV6CTL_MAXFRAGPACKETS .It Dv IPV6CTL_FORWARDING .Pq ip6.forwarding Boolean: enable/disable forwarding of .Tn IPv6 packets. Also, identify if the node is acting as a router. Defaults to off. .It Dv IPV6CTL_SENDREDIRECTS .Pq ip6.redirect Boolean: enable/disable sending of .Tn ICMPv6 redirects in response to unforwardable .Tn IPv6 packets. This option is ignored unless the node is routing .Tn IPv6 packets, and should normally be enabled on all systems. Defaults to on. .It Dv IPV6CTL_DEFHLIM .Pq ip6.hlim Integer: default hop limit value to use for outgoing .Tn IPv6 packets. This value applies to all the transport protocols on top of .Tn IPv6 . There are APIs to override the value. .It Dv IPV6CTL_MAXFRAGS .Pq ip6.maxfrags Integer: maximum number of fragments the host will accept and simultaneously hold across all reassembly queues in all VNETs. If set to 0, fragment reassembly is disabled. If set to -1, this limit is not applied. This limit is recalculated when the number of mbuf clusters is changed. This is a global limit. .It Dv IPV6CTL_MAXFRAGPACKETS .Pq ip6.maxfragpackets Integer: maximum number of fragmented packets the node will accept and simultaneously hold in the reassembly queue for a particular VNET. 0 means that the node will not accept any fragmented packets for that VNET. -1 means that the node will not apply this limit for that VNET. This limit is recalculated when the number of mbuf clusters is changed. This is a per-VNET limit. .It Dv IPV6CTL_MAXFRAGBUCKETSIZE .Pq ip6.maxfragbucketsize Integer: maximum number of reassembly queues per bucket. Fragmented packets are hashed to buckets. Each bucket has a list of reassembly queues. The system must compare the incoming packets to the existing reassembly queues in the bucket to find a matching reassembly queue. To preserve system resources, the system limits the number of reassembly queues allowed in each bucket. This limit is recalculated when the number of mbuf clusters is changed or when the value of .Va ip6.maxfragpackets changes. This is a per-VNET limit. .It Dv IPV6CTL_MAXFRAGSPERPACKET .Pq ip6.maxfragsperpacket Integer: maximum number of fragments the host will accept and hold in the ressembly queue for a packet. This is a per-VNET limit. .It Dv IPV6CTL_ACCEPT_RTADV .Pq ip6.accept_rtadv Boolean: the default value of a per-interface flag to enable/disable receiving of .Tn ICMPv6 router advertisement packets, and autoconfiguration of address prefixes and default routers. The node must be a host (not a router) for the option to be meaningful. Defaults to off. .It Dv IPV6CTL_AUTO_LINKLOCAL .Pq ip6.auto_linklocal Boolean: the default value of a per-interface flag to enable/disable performing automatic link-local address configuration. Defaults to on. .It Dv IPV6CTL_LOG_INTERVAL .Pq ip6.log_interval Integer: default interval between .Tn IPv6 packet forwarding engine log output (in seconds). .It Dv IPV6CTL_HDRNESTLIMIT .Pq ip6.hdrnestlimit Integer: default number of the maximum .Tn IPv6 extension headers permitted on incoming .Tn IPv6 packets. If set to 0, the node will accept as many extension headers as possible. .It Dv IPV6CTL_DAD_COUNT .Pq ip6.dad_count Integer: default number of .Tn IPv6 DAD .Pq duplicated address detection probe packets. The packets will be generated when .Tn IPv6 interface addresses are configured. .It Dv IPV6CTL_AUTO_FLOWLABEL .Pq ip6.auto_flowlabel Boolean: enable/disable automatic filling of .Tn IPv6 flowlabel field, for outstanding connected transport protocol packets. The field might be used by intermediate routers to identify packet flows. Defaults to on. .It Dv IPV6CTL_DEFMCASTHLIM .Pq ip6.defmcasthlim Integer: default hop limit value for an .Tn IPv6 multicast packet sourced by the node. This value applies to all the transport protocols on top of .Tn IPv6 . There are APIs to override the value as documented in .Xr ip6 4 . .It Dv IPV6CTL_GIF_HLIM .Pq ip6.gifhlim Integer: default maximum hop limit value for an .Tn IPv6 packet generated by .Xr gif 4 tunnel interface. .It Dv IPV6CTL_KAME_VERSION .Pq ip6.kame_version String: identifies the version of KAME .Tn IPv6 stack implemented in the kernel. .It Dv IPV6CTL_USE_DEPRECATED .Pq ip6.use_deprecated Boolean: enable/disable use of deprecated address, specified in RFC2462 5.5.4. Defaults to on. .It Dv IPV6CTL_RR_PRUNE .Pq ip6.rr_prune Integer: default interval between .Tn IPv6 router renumbering prefix babysitting, in seconds. .It Dv IPV6CTL_V6ONLY .Pq ip6.v6only Boolean: enable/disable the prohibited use of .Tn IPv4 mapped address on .Dv AF_INET6 sockets. Defaults to on. .El .Ss Interaction between IPv4/v6 sockets By default, .Fx does not route IPv4 traffic to .Dv AF_INET6 sockets. The default behavior intentionally violates RFC2553 for security reasons. Listen to two sockets if you want to accept both IPv4 and IPv6 traffic. IPv4 traffic may be routed with certain per-socket/per-node configuration, however, it is not recommended to do so. Consult .Xr ip6 4 for details. .Pp The behavior of .Dv AF_INET6 TCP/UDP socket is documented in RFC2553. Basically, it says this: .Bl -bullet -compact .It A specific bind on an .Dv AF_INET6 socket .Xr ( bind 2 with an address specified) should accept IPv6 traffic to that address only. .It If you perform a wildcard bind on an .Dv AF_INET6 socket .Xr ( bind 2 to IPv6 address .Li :: ) , and there is no wildcard bind .Dv AF_INET socket on that TCP/UDP port, IPv6 traffic as well as IPv4 traffic should be routed to that .Dv AF_INET6 socket. IPv4 traffic should be seen as if it came from an IPv6 address like .Li ::ffff:10.1.1.1 . This is called an IPv4 mapped address. .It If there are both a wildcard bind .Dv AF_INET socket and a wildcard bind .Dv AF_INET6 socket on one TCP/UDP port, they should behave separately. IPv4 traffic should be routed to the .Dv AF_INET socket and IPv6 should be routed to the .Dv AF_INET6 socket. .El .Pp However, RFC2553 does not define the ordering constraint between calls to .Xr bind 2 , nor how IPv4 TCP/UDP port numbers and IPv6 TCP/UDP port numbers relate to each other (should they be integrated or separated). Implemented behavior is very different from kernel to kernel. Therefore, it is unwise to rely too much upon the behavior of .Dv AF_INET6 wildcard bind sockets. It is recommended to listen to two sockets, one for .Dv AF_INET and another for .Dv AF_INET6 , when you would like to accept both IPv4 and IPv6 traffic. .Pp It should also be noted that malicious parties can take advantage of the complexity presented above, and are able to bypass access control, if the target node routes IPv4 traffic to .Dv AF_INET6 socket. Users are advised to take care handling connections from IPv4 mapped address to .Dv AF_INET6 sockets. .Sh SEE ALSO .Xr ioctl 2 , .Xr socket 2 , .Xr sysctl 3 , .Xr icmp6 4 , .Xr intro 4 , .Xr ip6 4 , .Xr tcp 4 , .Xr udp 4 .Sh STANDARDS .Rs .%A Tatsuya Jinmei .%A Atsushi Onoe .%T "An Extension of Format for IPv6 Scoped Addresses" .%R internet draft .%D June 2000 .%N draft-ietf-ipngwg-scopedaddr-format-02.txt .%O work in progress material .Re .Sh HISTORY The .Nm protocol interfaces are defined in RFC2553 and RFC2292. The implementation described herein appeared in the WIDE/KAME project. .Sh BUGS The IPv6 support is subject to change as the Internet protocols develop. Users should not depend on details of the current implementation, but rather the services exported. .Pp Users are suggested to implement .Dq version independent code as much as possible, as you will need to support both .Xr inet 4 and .Nm . Index: head/tests/sys/netinet/carp.sh =================================================================== --- head/tests/sys/netinet/carp.sh (revision 368045) +++ head/tests/sys/netinet/carp.sh (revision 368046) @@ -1,152 +1,152 @@ # $FreeBSD$ # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2020 Kristof Provost # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. . $(atf_get_srcdir)/../common/vnet.subr is_master() { jail=$1 itf=$2 jexec ${jail} ifconfig ${itf} | grep carp | grep MASTER } wait_for_carp() { jail1=$1 itf1=$2 jail2=$3 itf2=$4 while [ -z "$(is_master ${jail1} ${itf1})" ] && [ -z "$(is_master ${jail2} ${itf2})" ]; do sleep 1 done } atf_test_case "basic_v4" "cleanup" basic_v4_head() { atf_set descr 'Basic CARP test (IPv4)' atf_set require.user root } basic_v4_body() { if ! kldstat -q -m carp; then atf_skip "This test requires carp" fi vnet_init bridge=$(vnet_mkbridge) epair_one=$(vnet_mkepair) epair_two=$(vnet_mkepair) vnet_mkjail carp_basic_v4_one ${bridge} ${epair_one}a ${epair_two}a vnet_mkjail carp_basic_v4_two ${epair_one}b vnet_mkjail carp_basic_v4_three ${epair_two}b jexec carp_basic_v4_one ifconfig ${bridge} 192.0.2.4/29 up jexec carp_basic_v4_one ifconfig ${bridge} addm ${epair_one}a \ addm ${epair_two}a jexec carp_basic_v4_one ifconfig ${epair_one}a up jexec carp_basic_v4_one ifconfig ${epair_two}a up jexec carp_basic_v4_two ifconfig ${epair_one}b 192.0.2.202/29 up jexec carp_basic_v4_two ifconfig ${epair_one}b add vhid 1 192.0.2.1/29 jexec carp_basic_v4_three ifconfig ${epair_two}b 192.0.2.203/29 up jexec carp_basic_v4_three ifconfig ${epair_two}b add vhid 1 \ 192.0.2.1/29 wait_for_carp carp_basic_v4_two ${epair_one}b \ carp_basic_v4_three ${epair_two}b atf_check -s exit:0 -o ignore jexec carp_basic_v4_one \ ping -c 3 192.0.2.1 } basic_v4_cleanup() { vnet_cleanup } atf_test_case "basic_v6" "cleanup" basic_v6_head() { atf_set descr 'Basic CARP test (IPv6)' atf_set require.user root } basic_v6_body() { if ! kldstat -q -m carp; then atf_skip "This test requires carp" fi vnet_init bridge=$(vnet_mkbridge) epair_one=$(vnet_mkepair) epair_two=$(vnet_mkepair) vnet_mkjail carp_basic_v6_one ${bridge} ${epair_one}a ${epair_two}a vnet_mkjail carp_basic_v6_two ${epair_one}b vnet_mkjail carp_basic_v6_three ${epair_two}b jexec carp_basic_v6_one ifconfig ${bridge} inet6 2001:db8::0:4/64 up \ no_dad jexec carp_basic_v6_one ifconfig ${bridge} addm ${epair_one}a \ addm ${epair_two}a jexec carp_basic_v6_one ifconfig ${epair_one}a up jexec carp_basic_v6_one ifconfig ${epair_two}a up jexec carp_basic_v6_two ifconfig ${epair_one}b inet6 \ 2001:db8::1:2/64 up no_dad jexec carp_basic_v6_two ifconfig ${epair_one}b inet6 add vhid 1 \ 2001:db8::0:1/64 jexec carp_basic_v6_three ifconfig ${epair_two}b inet6 2001:db8::1:3/64 up no_dad jexec carp_basic_v6_three ifconfig ${epair_two}b inet6 add vhid 1 \ 2001:db8::0:1/64 wait_for_carp carp_basic_v6_two ${epair_one}b \ carp_basic_v6_three ${epair_two}b atf_check -s exit:0 -o ignore jexec carp_basic_v6_one \ - ping6 -c 3 2001:db8::0:1 + ping -6 -c 3 2001:db8::0:1 } basic_v6_cleanup() { vnet_cleanup } atf_init_test_cases() { atf_add_test_case "basic_v4" atf_add_test_case "basic_v6" } Index: head/tests/sys/netinet6/exthdr.sh =================================================================== --- head/tests/sys/netinet6/exthdr.sh (revision 368045) +++ head/tests/sys/netinet6/exthdr.sh (revision 368046) @@ -1,126 +1,126 @@ # $FreeBSD$ #- # SPDX-License-Identifier: BSD-2-Clause # # Copyright (c) 2019 Netflix, Inc. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # . $(atf_get_srcdir)/../common/vnet.subr atf_test_case "exthdr" "cleanup" exthdr_head() { atf_set descr 'Test IPv6 extension header code paths' atf_set require.user root atf_set require.progs scapy } exthdr_body() { ids=65533 id=`printf "%x" ${ids}` if [ $$ -gt 65535 ]; then xl=`printf "%x" $(($$ - 65535))` yl="1" else xl=`printf "%x" $$` yl="" fi vnet_init ip6a="2001:db8:6666:0000:${yl}:${id}:1:${xl}" ip6b="2001:db8:6666:0000:${yl}:${id}:2:${xl}" epair=$(vnet_mkepair) ifconfig ${epair}a up ifconfig ${epair}a inet6 ${ip6a}/64 jname="v6t-${id}-${yl}-${xl}" vnet_mkjail ${jname} ${epair}b jexec ${jname} ifconfig ${epair}b up jexec ${jname} ifconfig ${epair}b inet6 ${ip6b}/64 # Let IPv6 ND do its thing. #ping6 -q -c 1 ff02::1%${epair}a #ping6 -q -c 1 ${ip6b} sleep 3 # Clear statistics. jexec ${jname} netstat -z -s > /dev/null # Run extension header tests. pyname=$(atf_get ident) pyname=${pyname%*_[0-9]} - atf_check -o ignore -s exit:0 ping6 -c 3 -q -o ${ip6b} + atf_check -o ignore -s exit:0 ping -6 -c 3 -q -o ${ip6b} atf_check -s exit:0 $(atf_get_srcdir)/${pyname}.py \ --sendif ${epair}a --recvif ${epair}a \ --src ${ip6a} --to ${ip6b} atf_check -s exit:0 $(atf_get_srcdir)/${pyname}.py \ --sendif ${epair}a --recvif ${epair}a \ --src ${ip6a} --to ${ip6b} \ --hbh atf_check -s exit:0 $(atf_get_srcdir)/${pyname}.py \ --sendif ${epair}a --recvif ${epair}a \ --src ${ip6a} --to ${ip6b} \ --rh atf_check -s exit:0 $(atf_get_srcdir)/${pyname}.py \ --sendif ${epair}a --recvif ${epair}a \ --src ${ip6a} --to ${ip6b} \ --frag6 atf_check -s exit:0 $(atf_get_srcdir)/${pyname}.py \ --sendif ${epair}a --recvif ${epair}a \ --src ${ip6a} --to ${ip6b} \ --dest atf_check -s exit:0 $(atf_get_srcdir)/${pyname}.py \ --sendif ${epair}a --recvif ${epair}a \ --src ${ip6a} --to ${ip6b} \ --hbh --dest atf_check -s exit:1 $(atf_get_srcdir)/${pyname}.py \ --sendif ${epair}a --recvif ${epair}a \ --src ${ip6a} --to ${ip6b} \ --dest --hbhbad } exthdr_cleanup() { vnet_cleanup } atf_init_test_cases() { atf_add_test_case "exthdr" } # end Index: head/tests/sys/netinet6/lpm6.sh =================================================================== --- head/tests/sys/netinet6/lpm6.sh (revision 368045) +++ head/tests/sys/netinet6/lpm6.sh (revision 368046) @@ -1,199 +1,199 @@ #!/usr/bin/env atf-sh #- # SPDX-License-Identifier: BSD-2-Clause # # Copyright (c) 2020 Alexander V. Chernikov # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # . $(atf_get_srcdir)/../common/vnet.subr setup_networking() { jname="$1" lo_dst="$2" epair0="$3" epair1="$4" vnet_mkjail ${jname}a ${epair0}a ${epair1}a ${lo_src} # enable link-local IPv6 jexec ${jname}a ndp -i ${epair0}a -- -disabled jexec ${jname}a ifconfig ${epair0}a up jexec ${jname}a ndp -i ${epair1}a -- -disabled jexec ${jname}a ifconfig ${epair1}a up jexec ${jname}a ifconfig ${lo_src} up vnet_mkjail ${jname}b ${epair0}b ${epair1}b ${lo_dst} jexec ${jname}b ndp -i ${epair0}b -- -disabled jexec ${jname}b ifconfig ${epair0}b up jexec ${jname}b ndp -i ${epair1}b -- -disabled jexec ${jname}b ifconfig ${epair1}b up jexec ${jname}b ifconfig ${lo_dst} up # wait for DAD to complete while [ `jexec ${jname}b ifconfig | grep inet6 | grep -c tentative` != "0" ]; do sleep 0.1 done while [ `jexec ${jname}a ifconfig | grep inet6 | grep -c tentative` != "0" ]; do sleep 0.1 done } atf_test_case "lpm6_test1_success" "cleanup" lpm6_test1_success_head() { atf_set descr 'Test IPv6 LPM for the host routes' atf_set require.user root } lpm6_test1_success_body() { vnet_init net_dst="2001:db8:" jname="v6t-lpm6_test1_success" epair0=$(vnet_mkepair) epair1=$(vnet_mkepair) lo_dst=$(vnet_mkloopback) setup_networking ${jname} ${lo_dst} ${epair0} ${epair1} jexec ${jname}b ifconfig ${lo_dst} inet6 ${net_dst}:2:0/128 jexec ${jname}b ifconfig ${lo_dst} inet6 ${net_dst}:2:1/128 # Add routes # A -> towards B via epair0a LL ll=`jexec ${jname}b ifconfig ${epair0}b inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'` jexec ${jname}a route add -6 -host ${net_dst}:2:0 ${ll}%${epair0}a # A -> towards B via epair1a LL ll=`jexec ${jname}b ifconfig ${epair1}b inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'` jexec ${jname}a route add -6 -host ${net_dst}:2:1 ${ll}%${epair1}a count=20 valid_message="${count} packets transmitted, ${count} packets received" # Check that ${net_dst}:2:0 goes via epair0 - atf_check -o match:"${valid_message}" jexec ${jname}a ping6 -f -nc${count} ${net_dst}:2:0 + atf_check -o match:"${valid_message}" jexec ${jname}a ping -6 -f -nc${count} ${net_dst}:2:0 pkt_0=`jexec ${jname}a netstat -Wf link -I ${epair0}a | head | awk '$1!~/^Name/{print$8}'` pkt_1=`jexec ${jname}a netstat -Wf link -I ${epair1}a | head | awk '$1!~/^Name/{print$8}'` if [ ${pkt_0} -le ${count} ]; then echo "LPM failure: 1: ${pkt_0} (should be ${count}) 2: ${pkt_1}" exit 1 fi # Check that ${net_dst}:2:1 goes via epair1 - atf_check -o match:"${valid_message}" jexec ${jname}a ping6 -f -nc${count} ${net_dst}:2:1 + atf_check -o match:"${valid_message}" jexec ${jname}a ping -6 -f -nc${count} ${net_dst}:2:1 pkt_0=`jexec ${jname}a netstat -Wf link -I ${epair0}a | head | awk '$1!~/^Name/{print$8}'` pkt_1=`jexec ${jname}a netstat -Wf link -I ${epair1}a | head | awk '$1!~/^Name/{print$8}'` if [ ${pkt_1} -le ${count} ]; then echo "LPM failure: 1: ${pkt_0} 2: ${pkt_1} (should be ${count})" exit 1 fi echo "RAW BALANCING: 1: ${pkt_0} 2: ${pkt_1}" } lpm6_test1_success_cleanup() { vnet_cleanup } atf_test_case "lpm6_test2_success" "cleanup" lpm6_test2_success_head() { atf_set descr 'Test IPv6 LPM for /126 and /127' atf_set require.user root } lpm6_test2_success_body() { vnet_init net_dst="2001:db8:" jname="v6t-lpm6_test2_success" epair0=$(vnet_mkepair) epair1=$(vnet_mkepair) lo_dst=$(vnet_mkloopback) setup_networking ${jname} ${lo_dst} ${epair0} ${epair1} jexec ${jname}b ifconfig ${lo_dst} inet6 ${net_dst}:2:0/128 jexec ${jname}b ifconfig ${lo_dst} inet6 ${net_dst}:2:2/128 # Add routes # A -> towards B via epair0a LL ll=`jexec ${jname}b ifconfig ${epair0}b inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'` jexec ${jname}a route add -6 -net ${net_dst}:2:0/126 ${ll}%${epair0}a # A -> towards B via epair1a LL ll=`jexec ${jname}b ifconfig ${epair1}b inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'` jexec ${jname}a route add -6 -net ${net_dst}:2:0/127 ${ll}%${epair1}a count=20 valid_message="${count} packets transmitted, ${count} packets received" # Check that ${net_dst}:2:0 goes via epair1 - atf_check -o match:"${valid_message}" jexec ${jname}a ping6 -f -nc${count} ${net_dst}:2:0 + atf_check -o match:"${valid_message}" jexec ${jname}a ping -6 -f -nc${count} ${net_dst}:2:0 pkt_0=`jexec ${jname}a netstat -Wf link -I ${epair0}a | head | awk '$1!~/^Name/{print$8}'` pkt_1=`jexec ${jname}a netstat -Wf link -I ${epair1}a | head | awk '$1!~/^Name/{print$8}'` if [ ${pkt_1} -le ${count} ]; then echo "LPM failure: 1: ${pkt_0} 2: ${pkt_1} (should be ${count})" exit 1 fi # Check that ${net_dst}:2:2 goes via epair0 - atf_check -o match:"${valid_message}" jexec ${jname}a ping6 -f -nc${count} ${net_dst}:2:2 + atf_check -o match:"${valid_message}" jexec ${jname}a ping -6 -f -nc${count} ${net_dst}:2:2 pkt_0=`jexec ${jname}a netstat -Wf link -I ${epair0}a | head | awk '$1!~/^Name/{print$8}'` pkt_1=`jexec ${jname}a netstat -Wf link -I ${epair1}a | head | awk '$1!~/^Name/{print$8}'` if [ ${pkt_0} -le ${count} ]; then echo "LPM failure: 1: ${pkt_0} (should be ${count}) 2: ${pkt_1}" exit 1 fi echo "RAW BALANCING: 1: ${pkt_0} 2: ${pkt_1}" } lpm6_test2_success_cleanup() { vnet_cleanup } atf_init_test_cases() { atf_add_test_case "lpm6_test1_success" atf_add_test_case "lpm6_test2_success" } # end Index: head/tests/sys/netinet6/output6.sh =================================================================== --- head/tests/sys/netinet6/output6.sh (revision 368045) +++ head/tests/sys/netinet6/output6.sh (revision 368046) @@ -1,664 +1,664 @@ #!/usr/bin/env atf-sh #- # SPDX-License-Identifier: BSD-2-Clause # # Copyright (c) 2020 Alexander V. Chernikov # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # . $(atf_get_srcdir)/../common/vnet.subr atf_test_case "output6_tcp_setup_success" "cleanup" output6_tcp_setup_success_head() { atf_set descr 'Test valid IPv6 TCP output' atf_set require.user root } output6_tcp_setup_success_body() { vnet_init net_src="2001:db8:0:0:1::" net_dst="2001:db8:0:0:1::" ip_src="${net_src}1" ip_dst=${net_dst}4242 plen=64 text="testtesttst" port=4242 script_name=`dirname $0`/../common/net_receiver.py script_name=`realpath ${script_name}` jname="v6t-output6_tcp_setup_success" epair=$(vnet_mkepair) vnet_mkjail ${jname}a ${epair}a jexec ${jname}a ifconfig ${epair}a up jexec ${jname}a ifconfig ${epair}a inet6 ${ip_src}/${plen} vnet_mkjail ${jname}b ${epair}b jexec ${jname}b ifconfig ${epair}b up jexec ${jname}b ifconfig ${epair}b inet6 ${ip_dst}/${plen} # wait for DAD to complete while [ `jexec ${jname}b ifconfig ${epair}b inet6 | grep -c tentative` != "0" ]; do sleep 0.1 done while [ `jexec ${jname}a ifconfig ${epair}a inet6 | grep -c tentative` != "0" ]; do sleep 0.1 done # run listener args="--family inet6 --ports ${port} --match_str ${text}" echo jexec ${jname}b ${script_name} ${args} jexec ${jname}b ${script_name} --test_name "test_listen_tcp" ${args} & cmd_pid=$! # wait for the script init counter=0 while [ `jexec ${jname}b sockstat -6qlp ${port} | wc -l` != "1" ]; do sleep 0.01 counter=$((counter+1)) if [ ${counter} -ge 50 ]; then break; fi done if [ `jexec ${jname}b sockstat -6qlp ${port} | wc -l` != "1" ]; then echo "App setup failed" exit 1 fi # run sender echo -n "${text}" | jexec ${jname}a nc -N ${ip_dst} ${port} exit_code=$? if [ $exit_code -ne 0 ]; then atf_fail "sender exit code $exit_code" ; fi wait ${cmd_pid} exit_code=$? if [ $exit_code -ne 0 ]; then atf_fail "receiver exit code $exit_code" ; fi } output6_tcp_setup_success_cleanup() { vnet_cleanup } atf_test_case "output6_udp_setup_success" "cleanup" output6_udp_setup_success_head() { atf_set descr 'Test valid IPv6 UDP output' atf_set require.user root } output6_udp_setup_success_body() { vnet_init net_src="2001:db8:0:0:1::" net_dst="2001:db8:0:0:1::" ip_src="${net_src}1" ip_dst=${net_dst}4242 plen=64 text="testtesttst" port=4242 script_name=`dirname $0`/../common/net_receiver.py script_name=`realpath ${script_name}` jname="v6t-output6_udp_setup_success" epair=$(vnet_mkepair) vnet_mkjail ${jname}a ${epair}a jexec ${jname}a ifconfig ${epair}a up jexec ${jname}a ifconfig ${epair}a inet6 ${ip_src}/${plen} vnet_mkjail ${jname}b ${epair}b jexec ${jname}b ifconfig ${epair}b up jexec ${jname}b ifconfig ${epair}b inet6 ${ip_dst}/${plen} # wait for DAD to complete while [ `jexec ${jname}b ifconfig ${epair}b inet6 | grep -c tentative` != "0" ]; do sleep 0.1 done while [ `jexec ${jname}a ifconfig ${epair}a inet6 | grep -c tentative` != "0" ]; do sleep 0.1 done # run listener args="--family inet6 --ports ${port} --match_str ${text}" echo jexec ${jname}b ${script_name} ${args} jexec ${jname}b ${script_name} --test_name "test_listen_udp" ${args} & cmd_pid=$! # wait for the script init counter=0 while [ `jexec ${jname}b sockstat -6qlp ${port} | wc -l` != "1" ]; do sleep 0.1 counterc=$((counter+1)) if [ ${counter} -ge 50 ]; then break; fi done if [ `jexec ${jname}b sockstat -6qlp ${port} | wc -l` != "1" ]; then echo "App setup failed" exit 1 fi # run sender # TODO: switch from nc to some alternative to avoid 1-second delay echo -n "${text}" | jexec ${jname}a nc -uNw1 ${ip_dst} ${port} exit_code=$? if [ $exit_code -ne 0 ]; then atf_fail "sender exit code $exit_code" ; fi wait ${cmd_pid} exit_code=$? if [ $exit_code -ne 0 ]; then atf_fail "receiver exit code $exit_code" ; fi } output6_udp_setup_success_cleanup() { vnet_cleanup } atf_test_case "output6_raw_success" "cleanup" output6_raw_success_head() { atf_set descr 'Test valid IPv6 raw output' atf_set require.user root } output6_raw_success_body() { vnet_init net_src="2001:db8:0:0:1::" net_dst="2001:db8:0:0:1::" ip_src="${net_src}1" ip_dst=${net_dst}4242 plen=64 script_name=`dirname $0`/../common/net_receiver.py script_name=`realpath ${script_name}` jname="v6t-output6_raw_success" epair=$(vnet_mkepair) vnet_mkjail ${jname}a ${epair}a jexec ${jname}a ifconfig ${epair}a up jexec ${jname}a ifconfig ${epair}a inet6 ${ip_src}/${plen} vnet_mkjail ${jname}b ${epair}b jexec ${jname}b ifconfig ${epair}b up jexec ${jname}b ifconfig ${epair}b inet6 ${ip_dst}/${plen} # wait for DAD to complete while [ `jexec ${jname}b ifconfig ${epair}b inet6 | grep -c tentative` != "0" ]; do sleep 0.1 done while [ `jexec ${jname}a ifconfig ${epair}a inet6 | grep -c tentative` != "0" ]; do sleep 0.1 done - atf_check -o match:'1 packets transmitted, 1 packets received' jexec ${jname}a ping6 -nc1 ${ip_dst} + atf_check -o match:'1 packets transmitted, 1 packets received' jexec ${jname}a ping -6 -nc1 ${ip_dst} } output6_raw_success_cleanup() { vnet_cleanup } # Multipath tests are done the following way: # epair0/LL # jailA lo/GU < > lo/GU jailB # epair1/LL # jailA has 2 routes towards /64 prefix on jailB loopback, via 2 epairs # jailB has 1 route towards /64 prefix on jailA loopback, via epair0 # # jailA initiates connections/sends packets towards IPs on jailB loopback. # Script then compares amount of packets sent via epair0 and epair1 mpath_check() { if [ `sysctl -iW net.route.multipath | wc -l` != "1" ]; then atf_skip "This test requires ROUTE_MPATH enabled" fi } mpath_enable() { jexec $1 sysctl net.route.multipath=1 if [ $? != 0 ]; then atf_fail "Setting multipath in jail $1 failed". fi } atf_test_case "output6_tcp_flowid_mpath_success" "cleanup" output6_tcp_flowid_mpath_success_head() { atf_set descr 'Test valid IPv6 TCP output flowid generation' atf_set require.user root } output6_tcp_flowid_mpath_success_body() { vnet_init mpath_check net_src="2001:db8:0:1" net_dst="2001:db8:0:2" ip_src="${net_src}::1" ip_dst="${net_dst}::1" plen=64 text="testtesttst" script_name=`dirname $0`/../common/net_receiver.py script_name=`realpath ${script_name}` jname="v6t-output6_tcp_flowid_mpath_success" epair0=$(vnet_mkepair) epair1=$(vnet_mkepair) lo_src=$(vnet_mkloopback) lo_dst=$(vnet_mkloopback) vnet_mkjail ${jname}a ${epair0}a ${epair1}a ${lo_src} mpath_enable ${jname}a jls -N # enable link-local IPv6 jexec ${jname}a ndp -i ${epair0}a -- -disabled jexec ${jname}a ifconfig ${epair0}a up jexec ${jname}a ndp -i ${epair1}a -- -disabled jexec ${jname}a ifconfig ${epair1}a up jexec ${jname}a ifconfig ${lo_src} up vnet_mkjail ${jname}b ${epair0}b ${epair1}b ${lo_dst} jls -N jexec ${jname}b ndp -i ${epair0}b -- -disabled jexec ${jname}b ifconfig ${epair0}b up jexec ${jname}b ndp -i ${epair1}b -- -disabled jexec ${jname}b ifconfig ${epair1}b up jexec ${jname}b ifconfig ${lo_dst} up # DST ips/ports to test ips="d3:c4:eb:40 2b:ff:dd:52 b1:d4:44:0e 41:2c:4d:43 66:4a:b4:be 8b:da:ac:f7 ca:d1:c4:f0 b1:31:da:d7 0c:ac:45:7a 44:9c:ce:71" ports="53540 49743 43067 9131 16734 5150 14379 40292 20634 51302 3387 24387 9282 14275 42103 26881 42461 29520 45714 11096" jexec ${jname}a ifconfig ${lo_src} inet6 ${ip_src}/128 jexec ${jname}b ifconfig ${lo_dst} inet6 ${ip_dst}/128 for i in ${ips}; do jexec ${jname}b ifconfig ${lo_dst} inet6 ${net_dst}:${i}/128 done # wait for DAD to complete while [ `jexec ${jname}b ifconfig | grep inet6 | grep -c tentative` != "0" ]; do sleep 0.1 done while [ `jexec ${jname}a ifconfig | grep inet6 | grep -c tentative` != "0" ]; do sleep 0.1 done # Add routes # A -> towards B via epair0a LL ll=`jexec ${jname}b ifconfig ${epair0}b inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'` jexec ${jname}a route add -6 -net ${net_dst}::/${plen} ${ll}%${epair0}a # A -> towards B via epair1a LL ll=`jexec ${jname}b ifconfig ${epair1}b inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'` jexec ${jname}a route add -6 -net ${net_dst}::/${plen} ${ll}%${epair1}a # B towards A via epair0b LL ll=`jexec ${jname}a ifconfig ${epair1}a inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'` jexec ${jname}b route add -6 -net ${net_src}::/${plen} ${ll}%${epair1}b # Base setup verification - atf_check -o match:'1 packets transmitted, 1 packets received' jexec ${jname}a ping6 -c1 ${ip_dst} + atf_check -o match:'1 packets transmitted, 1 packets received' jexec ${jname}a ping -6 -c1 ${ip_dst} # run listener num_ports=`echo ${ports} | wc -w` num_ips=`echo ${ips} | wc -w` count_examples=$((num_ports*num_ips)) listener_ports=`echo ${ports} | tr ' ' '\n' | sort -n | tr '\n' ',' | sed -e 's?,$??'` args="--family inet6 --ports ${listener_ports} --count ${count_examples} --match_str ${text}" echo jexec ${jname}b ${script_name} ${args} jexec ${jname}b ${script_name} --test_name "test_listen_tcp" ${args} & cmd_pid=$! # wait for the app init counter=0 init=0 while [ ${counter} -le 50 ]; do _ports=`jexec ${jname}b sockstat -6ql | awk "\\\$3 == ${cmd_pid} {print \\\$6}"|awk -F: "{print \\\$2}" | sort -n | tr '\n' ','` if [ "${_ports}" = "${listener_ports}," ]; then init=1 break; fi done if [ ${init} -eq 0 ]; then jexec ${jname}b sockstat -6ql | awk "\$3 == ${cmd_pid}" echo "App setup failed" exit 1 fi echo "App setup done" # run sender for _ip in ${ips}; do ip="${net_dst}:${_ip}" for port in ${ports}; do echo -n "${text}" | jexec ${jname}a nc -nN ${ip} ${port} exit_code=$? if [ $exit_code -ne 0 ]; then atf_fail "sender exit code $exit_code" ; fi done done wait ${cmd_pid} exit_code=$? if [ $exit_code -ne 0 ]; then atf_fail "receiver exit code $exit_code" ; fi pkt_0=`jexec ${jname}a netstat -Wf link -I ${epair0}a | head | awk '$1!~/^Name/{print$8}'` pkt_1=`jexec ${jname}a netstat -Wf link -I ${epair1}a | head | awk '$1!~/^Name/{print$8}'` if [ ${pkt_0} -le 10 ]; then atf_fail "Balancing failure: 1: ${pkt_0} 2: ${pkt_1}" fi if [ ${pkt_1} -le 10 ]; then atf_fail "Balancing failure: 1: ${pkt_0} 2: ${pkt_1}" fi echo "TCP Balancing: 1: ${pkt_0} 2: ${pkt_1}" } output6_tcp_flowid_mpath_success_cleanup() { vnet_cleanup } atf_test_case "output6_udp_flowid_mpath_success" "cleanup" output6_udp_flowid_mpath_success_head() { atf_set descr 'Test valid IPv6 UDP output flowid generation' atf_set require.user root } output6_udp_flowid_mpath_success_body() { vnet_init mpath_check # Note this test will spawn around ~100 nc processes net_src="2001:db8:0:1" net_dst="2001:db8:0:2" ip_src="${net_src}::1" ip_dst="${net_dst}::1" plen=64 text="testtesttst" script_name=`dirname $0`/../common/net_receiver.py script_name=`realpath ${script_name}` jname="v6t-output6_udp_flowid_mpath_success" epair0=$(vnet_mkepair) epair1=$(vnet_mkepair) lo_src=$(vnet_mkloopback) lo_dst=$(vnet_mkloopback) vnet_mkjail ${jname}a ${epair0}a ${epair1}a ${lo_src} mpath_enable ${jname}a jls -N # enable link-local IPv6 jexec ${jname}a ndp -i ${epair0}a -- -disabled jexec ${jname}a ifconfig ${epair0}a up jexec ${jname}a ndp -i ${epair1}a -- -disabled jexec ${jname}a ifconfig ${epair1}a up jexec ${jname}a ifconfig ${lo_src} up vnet_mkjail ${jname}b ${epair0}b ${epair1}b ${lo_dst} jls -N jexec ${jname}b ndp -i ${epair0}b -- -disabled jexec ${jname}b ifconfig ${epair0}b up jexec ${jname}b ndp -i ${epair1}b -- -disabled jexec ${jname}b ifconfig ${epair1}b up jexec ${jname}b ifconfig ${lo_dst} up # DST ips/ports to test ips="d3:c4:eb:40 2b:ff:dd:52 b1:d4:44:0e 41:2c:4d:43 66:4a:b4:be 8b:da:ac:f7 ca:d1:c4:f0 b1:31:da:d7 0c:ac:45:7a 44:9c:ce:71" ports="53540 49743 43067 9131 16734 5150 14379 40292 20634 51302 3387 24387 9282 14275 42103 26881 42461 29520 45714 11096" jexec ${jname}a ifconfig ${lo_src} inet6 ${ip_src}/128 jexec ${jname}b ifconfig ${lo_dst} inet6 ${ip_dst}/128 for i in ${ips}; do jexec ${jname}b ifconfig ${lo_dst} inet6 ${net_dst}:${i}/128 done # wait for DAD to complete while [ `jexec ${jname}b ifconfig | grep inet6 | grep -c tentative` != "0" ]; do sleep 0.1 done while [ `jexec ${jname}a ifconfig | grep inet6 | grep -c tentative` != "0" ]; do sleep 0.1 done # Add routes # A -> towards B via epair0a LL ll=`jexec ${jname}b ifconfig ${epair0}b inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'` jexec ${jname}a route add -6 -net ${net_dst}::/${plen} ${ll}%${epair0}a # A -> towards B via epair1a LL ll=`jexec ${jname}b ifconfig ${epair1}b inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'` jexec ${jname}a route add -6 -net ${net_dst}::/${plen} ${ll}%${epair1}a # B towards A via epair0b LL ll=`jexec ${jname}a ifconfig ${epair1}a inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'` jexec ${jname}b route add -6 -net ${net_src}::/${plen} ${ll}%${epair1}b # Base setup verification - atf_check -o match:'1 packets transmitted, 1 packets received' jexec ${jname}a ping6 -c1 ${ip_dst} + atf_check -o match:'1 packets transmitted, 1 packets received' jexec ${jname}a ping -6 -c1 ${ip_dst} # run listener num_ports=`echo ${ports} | wc -w` num_ips=`echo ${ips} | wc -w` count_examples=$((num_ports*num_ips)) listener_ports=`echo ${ports} | tr ' ' '\n' | sort -n | tr '\n' ',' | sed -e 's?,$??'` args="--family inet6 --ports ${listener_ports} --count ${count_examples} --match_str ${text}" echo jexec ${jname}b ${script_name} ${args} jexec ${jname}b ${script_name} --test_name "test_listen_udp" ${args} & cmd_pid=$! # wait for the app init counter=0 init=0 while [ ${counter} -le 50 ]; do _ports=`jexec ${jname}b sockstat -6ql | awk "\\\$3 == ${cmd_pid} {print \\\$6}"|awk -F: "{print \\\$2}" | sort -n | tr '\n' ','` if [ "${_ports}" = "${listener_ports}," ]; then init=1 break; fi done if [ ${init} -eq 0 ]; then jexec ${jname}b sockstat -6ql | awk "\$3 == ${cmd_pid}" echo "App setup failed" exit 1 fi echo "App setup done" # run sender for _ip in ${ips}; do ip="${net_dst}:${_ip}" for port in ${ports}; do # XXX: switch to something that allows immediate exit echo -n "${text}" | jexec ${jname}a nc -nuNw1 ${ip} ${port} & sleep 0.01 done done wait ${cmd_pid} exit_code=$? if [ $exit_code -ne 0 ]; then atf_fail "receiver exit code $exit_code" ; fi pkt_0=`jexec ${jname}a netstat -Wf link -I ${epair0}a | head | awk '$1!~/^Name/{print$8}'` pkt_1=`jexec ${jname}a netstat -Wf link -I ${epair1}a | head | awk '$1!~/^Name/{print$8}'` if [ ${pkt_0} -le 10 ]; then atf_fail "Balancing failure: 1: ${pkt_0} 2: ${pkt_1}" fi if [ ${pkt_1} -le 10 ]; then atf_fail "Balancing failure: 1: ${pkt_0} 2: ${pkt_1}" fi echo "UDP BALANCING: 1: ${pkt_0} 2: ${pkt_1}" } output6_udp_flowid_mpath_success_cleanup() { vnet_cleanup } atf_test_case "output6_raw_flowid_mpath_success" "cleanup" output6_raw_flowid_mpath_success_head() { atf_set descr 'Test valid IPv6 raw output flowid generation' atf_set require.user root } output6_raw_flowid_mpath_success_body() { vnet_init mpath_check net_src="2001:db8:0:1" net_dst="2001:db8:0:2" ip_src="${net_src}::1" ip_dst="${net_dst}::1" plen=64 text="testtesttst" jname="v6t-output6_raw_flowid_mpath_success" epair0=$(vnet_mkepair) epair1=$(vnet_mkepair) lo_src=$(vnet_mkloopback) lo_dst=$(vnet_mkloopback) vnet_mkjail ${jname}a ${epair0}a ${epair1}a ${lo_src} mpath_enable ${jname}a jls -N # enable link-local IPv6 jexec ${jname}a ndp -i ${epair0}a -- -disabled jexec ${jname}a ifconfig ${epair0}a up jexec ${jname}a ndp -i ${epair1}a -- -disabled jexec ${jname}a ifconfig ${epair1}a up jexec ${jname}a ifconfig ${lo_src} up vnet_mkjail ${jname}b ${epair0}b ${epair1}b ${lo_dst} jls -N jexec ${jname}b ndp -i ${epair0}b -- -disabled jexec ${jname}b ifconfig ${epair0}b up jexec ${jname}b ndp -i ${epair1}b -- -disabled jexec ${jname}b ifconfig ${epair1}b up jexec ${jname}b ifconfig ${lo_dst} up # DST ips to test ips="9d:33:f2:7f 48:06:9a:0b cf:96:d5:78 76:da:8e:28 d4:66:38:1e ec:43:da:7c bb:f8:93:2f d3:c4:eb:40" ips="${ips} c7:31:0e:ae 8d:ed:35:2e c0:e0:22:31 82:1c:4e:28 c1:00:60:3e 6a:4f:3b:6c 8e:a7:e9:57 2b:ff:dd:52" ips="${ips} 88:44:79:5d 80:62:83:11 c8:e4:17:a6 e7:2a:45:d7 5a:92:0e:04 70:fc:6a:ee ce:24:4c:68 41:2c:4d:43" ips="${ips} 57:2b:5e:a7 f9:e0:69:c6 cb:b9:e6:ed 28:88:5d:fa d6:19:ac:1d dc:de:37:d8 fe:39:55:c7 b1:31:da:d7" jexec ${jname}a ifconfig ${lo_src} inet6 ${ip_src}/128 jexec ${jname}b ifconfig ${lo_dst} inet6 ${ip_dst}/128 for i in ${ips}; do jexec ${jname}b ifconfig ${lo_dst} inet6 ${net_dst}:${i}/128 done # wait for DAD to complete while [ `jexec ${jname}b ifconfig | grep inet6 | grep -c tentative` != "0" ]; do sleep 0.1 done while [ `jexec ${jname}a ifconfig | grep inet6 | grep -c tentative` != "0" ]; do sleep 0.1 done # Add routes # A -> towards B via epair0a LL ll=`jexec ${jname}b ifconfig ${epair0}b inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'` jexec ${jname}a route add -6 -net ${net_dst}::/${plen} ${ll}%${epair0}a # A -> towards B via epair1a LL ll=`jexec ${jname}b ifconfig ${epair1}b inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'` jexec ${jname}a route add -6 -net ${net_dst}::/${plen} ${ll}%${epair1}a # B towards A via epair0b LL ll=`jexec ${jname}a ifconfig ${epair1}a inet6 | awk '$2~/^fe80:/{print$2}' | awk -F% '{print$1}'` jexec ${jname}b route add -6 -net ${net_src}::/${plen} ${ll}%${epair1}b # Base setup verification - atf_check -o match:'1 packets transmitted, 1 packets received' jexec ${jname}a ping6 -nc1 ${ip_dst} + atf_check -o match:'1 packets transmitted, 1 packets received' jexec ${jname}a ping -6 -nc1 ${ip_dst} # run sender valid_message='1 packets transmitted, 1 packets received' for _ip in ${ips}; do ip="${net_dst}:${_ip}" - atf_check -o match:"${valid_message}" jexec ${jname}a ping6 -nc1 ${ip} + atf_check -o match:"${valid_message}" jexec ${jname}a ping -6 -nc1 ${ip} done pkt_0=`jexec ${jname}a netstat -Wf link -I ${epair0}a | head | awk '$1!~/^Name/{print$8}'` pkt_1=`jexec ${jname}a netstat -Wf link -I ${epair1}a | head | awk '$1!~/^Name/{print$8}'` jexec ${jname}a netstat -bWf link -I ${epair0}a jexec ${jname}a netstat -bWf link -I ${epair1}a if [ ${pkt_0} -le 10 ]; then atf_fail "Balancing failure: 1: ${pkt_0} 2: ${pkt_1}" fi if [ ${pkt_1} -le 10 ]; then atf_fail "Balancing failure: 1: ${pkt_0} 2: ${pkt_1}" fi echo "RAW BALANCING: 1: ${pkt_0} 2: ${pkt_1}" } output6_raw_flowid_mpath_success_cleanup() { vnet_cleanup } atf_init_test_cases() { atf_add_test_case "output6_tcp_setup_success" atf_add_test_case "output6_udp_setup_success" atf_add_test_case "output6_raw_success" atf_add_test_case "output6_tcp_flowid_mpath_success" atf_add_test_case "output6_udp_flowid_mpath_success" atf_add_test_case "output6_raw_flowid_mpath_success" } # end Index: head/tests/sys/netipsec/tunnel/utils.subr =================================================================== --- head/tests/sys/netipsec/tunnel/utils.subr (revision 368045) +++ head/tests/sys/netipsec/tunnel/utils.subr (revision 368046) @@ -1,133 +1,133 @@ # $FreeBSD$ # Utility functions (mainly from pf tests, should be merged one day) ## : ${TMPDIR=/tmp} . $(atf_get_srcdir)/../../common/vnet.subr ist_init() { if ! sysctl -q kern.features.ipsec >/dev/null ; then atf_skip "This test requires ipsec" fi vnet_init } ist_labsetup () { epair_LAN_A=$(vnet_mkepair) ifconfig ${epair_LAN_A}a up epair_PUB_A=$(vnet_mkepair) ifconfig ${epair_PUB_A}a up epair_LAN_B=$(vnet_mkepair) ifconfig ${epair_LAN_B}a up epair_PUB_B=$(vnet_mkepair) ifconfig ${epair_PUB_B}a up vnet_mkjail hostA ${epair_LAN_A}a vnet_mkjail ipsecA ${epair_LAN_A}b ${epair_PUB_A}a vnet_mkjail router ${epair_PUB_A}b ${epair_PUB_B}b vnet_mkjail ipsecB ${epair_LAN_B}b ${epair_PUB_B}a vnet_mkjail hostB ${epair_LAN_B}a } ist_v4_setup () { jexec hostA ifconfig ${epair_LAN_A}a 192.0.2.1/30 up jexec ipsecA ifconfig ${epair_LAN_A}b 192.0.2.2/30 up jexec ipsecA ifconfig ${epair_PUB_A}a 198.51.100.2/30 up jexec router ifconfig ${epair_PUB_A}b 198.51.100.1/30 up jexec router ifconfig ${epair_PUB_B}b 198.51.100.5/30 up jexec ipsecB ifconfig ${epair_PUB_B}a 198.51.100.6/30 up jexec ipsecB ifconfig ${epair_LAN_B}b 203.0.113.2/30 up jexec hostB ifconfig ${epair_LAN_B}a 203.0.113.1/30 up jexec ipsecA sysctl net.inet.ip.forwarding=1 jexec router sysctl net.inet.ip.forwarding=1 jexec ipsecB sysctl net.inet.ip.forwarding=1 jexec hostA route add default 192.0.2.2 jexec ipsecA route add default 198.51.100.1 jexec ipsecB route add default 198.51.100.5 jexec hostB route add default 203.0.113.2 } ist_v6_setup () { jexec hostA ifconfig ${epair_LAN_A}a inet6 2001:db8:1::1/64 up no_dad jexec ipsecA ifconfig ${epair_LAN_A}b inet6 2001:db8:1::2/64 up no_dad jexec ipsecA ifconfig ${epair_PUB_A}a inet6 2001:db8:23::2/64 up no_dad jexec router ifconfig ${epair_PUB_A}b inet6 2001:db8:23::3/64 up no_dad jexec router ifconfig ${epair_PUB_B}b inet6 2001:db8:34::3/64 up no_dad jexec ipsecB ifconfig ${epair_PUB_B}a inet6 2001:db8:34::2/64 up no_dad jexec ipsecB ifconfig ${epair_LAN_B}b inet6 2001:db8:45::2/64 up no_dad jexec hostB ifconfig ${epair_LAN_B}a inet6 2001:db8:45::1/64 up no_dad jexec ipsecA sysctl net.inet6.ip6.forwarding=1 jexec router sysctl net.inet6.ip6.forwarding=1 jexec ipsecB sysctl net.inet6.ip6.forwarding=1 jexec hostA route -6 add default 2001:db8:1::2 jexec ipsecA route -6 add default 2001:db8:23::3 jexec ipsecB route -6 add default 2001:db8:34::3 jexec hostB route -6 add default 2001:db8:45::2 } ist_setkey() { jname=$1 dir=$2 afnet=$3 enc_algo=$4 enc_key=$5 auth_algo=$6 auth_key=$7 # Load ( printf "#arguments debug: ${jname} ${afnet} ${dir} ${enc_algo} " printf "${enc_key} ${auth_algo} ${auth_key}\n" printf "flush;\n" printf "spdflush;\n" if [ ${afnet} -eq 4 ]; then SRC_LAN="192.0.2.0/24" DST_LAN="203.0.113.0/24" SRC_GW="198.51.100.2" DST_GW="198.51.100.6" else SRC_LAN="2001:db8:1::/64" DST_LAN="2001:db8:45::/64" SRC_GW="2001:db8:23::2" DST_GW="2001:db8:34::2" fi printf "spdadd ${SRC_LAN} ${DST_LAN} any -P " [ ${dir} = "out" ] && printf "out" || printf "in" printf " ipsec esp/tunnel/${SRC_GW}-${DST_GW}/require;\n" printf "spdadd ${DST_LAN} ${SRC_LAN} any -P " [ ${dir} = "out" ] && printf "in" || printf "out" printf " ipsec esp/tunnel/${DST_GW}-${SRC_GW}/require;\n" printf "add ${SRC_GW} ${DST_GW} esp 0x1000 -E ${enc_algo} \"${enc_key}\"" [ -n "${auth_algo}" ] && printf " -A ${auth_algo} \"${auth_key}\";\n" || printf ";\n" printf "add ${DST_GW} ${SRC_GW} esp 0x1001 -E ${enc_algo} \"${enc_key}\"" [ -n "$auth_algo" ] && printf " -A ${auth_algo} \"${auth_key}\";\n" || printf ";\n" ) > ${TMPDIR}/ipsec.${jname}.conf } ist_test() { ist_init ist_labsetup [ $1 -eq 4 ] && ist_v4_setup || ist_v6_setup ist_setkey ipsecA out $@ atf_check -s exit:0 -o ignore jexec ipsecA setkey -f ${TMPDIR}/ipsec.ipsecA.conf ist_setkey ipsecB in $@ atf_check -s exit:0 -o ignore jexec ipsecB setkey -f ${TMPDIR}/ipsec.ipsecB.conf # Check ipsec tunnel if [ $1 -eq 4 ]; then atf_check -s exit:0 -o ignore jexec hostA ping -c 1 203.0.113.1 else - atf_check -s exit:0 -o ignore jexec hostA ping6 -c 1 2001:db8:45::1 + atf_check -s exit:0 -o ignore jexec hostA ping -6 -c 1 2001:db8:45::1 fi } ist_cleanup() { vnet_cleanup } Index: head/tests/sys/netpfil/common/pass_block.sh =================================================================== --- head/tests/sys/netpfil/common/pass_block.sh (revision 368045) +++ head/tests/sys/netpfil/common/pass_block.sh (revision 368046) @@ -1,129 +1,129 @@ #- # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2019 Ahsan Barkati # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # . $(atf_get_srcdir)/utils.subr . $(atf_get_srcdir)/runner.subr v4_head() { atf_set require.user root } v4_body() { firewall=$1 firewall_init $firewall epair=$(vnet_mkepair) ifconfig ${epair}a 192.0.2.1/24 up vnet_mkjail iron ${epair}b jexec iron ifconfig ${epair}b 192.0.2.2/24 up # Block All firewall_config "iron" ${firewall} \ "pf" \ "block in" \ "ipfw" \ "ipfw -q add 100 deny all from any to any" \ "ipf" \ "block in all" atf_check -s exit:2 -o ignore ping -c 1 -t 1 192.0.2.2 # Pass All firewall_config "iron" ${firewall} \ "pf" \ "pass in" \ "ipfw" \ "ipfw -q add 100 allow all from any to any" \ "ipf" \ "pass in all" atf_check -s exit:0 -o ignore ping -c 1 -t 1 192.0.2.2 } v4_cleanup() { firewall=$1 firewall_cleanup $firewall } v6_head() { atf_set require.user root } v6_body() { firewall=$1 firewall_init $firewall epair=$(vnet_mkepair) ifconfig ${epair}a inet6 fd7a:803f:cc4b::1/64 up no_dad vnet_mkjail iron ${epair}b jexec iron ifconfig ${epair}b inet6 fd7a:803f:cc4b::2/64 up no_dad # Block All firewall_config "iron" ${firewall} \ "pf" \ "block in" \ "ipfw" \ "ipfw -q add 100 deny all from any to any" \ "ipf" \ "block in all" - atf_check -s exit:2 -o ignore ping6 -c 1 -W 1 fd7a:803f:cc4b::2 + atf_check -s exit:2 -o ignore ping -6 -c 1 -W 1 fd7a:803f:cc4b::2 # Pass All firewall_config "iron" ${firewall} \ "pf" \ "pass in" \ "ipfw" \ "ipfw -q add 100 allow all from any to any" \ "ipf" \ "pass in all" - atf_check -s exit:0 -o ignore ping6 -c 1 -W 1 fd7a:803f:cc4b::2 + atf_check -s exit:0 -o ignore ping -6 -c 1 -W 1 fd7a:803f:cc4b::2 } v6_cleanup() { firewall=$1 firewall_cleanup $firewall } setup_tests "v4" \ "pf" \ "ipfw" \ "ipf" \ "v6" \ "pf" \ "ipfw" \ "ipf" Index: head/tests/sys/netpfil/pf/fragmentation.sh =================================================================== --- head/tests/sys/netpfil/pf/fragmentation.sh (revision 368045) +++ head/tests/sys/netpfil/pf/fragmentation.sh (revision 368046) @@ -1,148 +1,148 @@ # $FreeBSD$ # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2017 Kristof Provost # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. . $(atf_get_srcdir)/utils.subr atf_test_case "too_many_fragments" "cleanup" too_many_fragments_head() { atf_set descr 'IPv4 fragment limitation test' atf_set require.user root } too_many_fragments_body() { pft_init epair=$(vnet_mkepair) vnet_mkjail alcatraz ${epair}a ifconfig ${epair}b inet 192.0.2.1/24 up jexec alcatraz ifconfig ${epair}a 192.0.2.2/24 up ifconfig ${epair}b mtu 200 jexec alcatraz ifconfig ${epair}a mtu 200 jexec alcatraz pfctl -e pft_set_rules alcatraz \ "scrub all fragment reassemble" # So we know pf is limiting things jexec alcatraz sysctl net.inet.ip.maxfragsperpacket=1024 # Sanity check atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 # We can ping with < 64 fragments atf_check -s exit:0 -o ignore ping -c 1 -s 800 192.0.2.2 # Too many fragments should fail atf_check -s exit:2 -o ignore ping -c 1 -s 20000 192.0.2.2 } too_many_fragments_cleanup() { pft_cleanup } atf_test_case "v6" "cleanup" v6_head() { atf_set descr 'IPv6 fragmentation test' atf_set require.user root atf_set require.progs scapy } v6_body() { pft_init epair_send=$(vnet_mkepair) epair_link=$(vnet_mkepair) vnet_mkjail alcatraz ${epair_send}b ${epair_link}a vnet_mkjail singsing ${epair_link}b ifconfig ${epair_send}a inet6 2001:db8:42::1/64 no_dad up jexec alcatraz ifconfig ${epair_send}b inet6 2001:db8:42::2/64 no_dad up jexec alcatraz ifconfig ${epair_link}a inet6 2001:db8:43::2/64 no_dad up jexec alcatraz sysctl net.inet6.ip6.forwarding=1 jexec singsing ifconfig ${epair_link}b inet6 2001:db8:43::3/64 no_dad up jexec singsing route add -6 2001:db8:42::/64 2001:db8:43::2 route add -6 2001:db8:43::/64 2001:db8:42::2 jexec alcatraz ifconfig ${epair_send}b inet6 -ifdisabled jexec alcatraz ifconfig ${epair_link}a inet6 -ifdisabled jexec singsing ifconfig ${epair_link}b inet6 -ifdisabled ifconfig ${epair_send}a inet6 -ifdisabled jexec alcatraz pfctl -e pft_set_rules alcatraz \ "scrub fragment reassemble" \ "block in" \ "pass in inet6 proto icmp6 icmp6-type { neighbrsol, neighbradv }" \ "pass in inet6 proto icmp6 icmp6-type { echoreq, echorep }" # Host test atf_check -s exit:0 -o ignore \ - ping6 -c 1 2001:db8:42::2 + ping -6 -c 1 2001:db8:42::2 atf_check -s exit:0 -o ignore \ - ping6 -c 1 -s 4500 2001:db8:42::2 + ping -6 -c 1 -s 4500 2001:db8:42::2 atf_check -s exit:0 -o ignore\ - ping6 -c 1 -b 70000 -s 65000 2001:db8:42::2 + ping -6 -c 1 -b 70000 -s 65000 2001:db8:42::2 # Forwarding test atf_check -s exit:0 -o ignore \ - ping6 -c 1 2001:db8:43::3 + ping -6 -c 1 2001:db8:43::3 atf_check -s exit:0 -o ignore \ - ping6 -c 1 -s 4500 2001:db8:43::3 + ping -6 -c 1 -s 4500 2001:db8:43::3 atf_check -s exit:0 -o ignore\ - ping6 -c 1 -b 70000 -s 65000 2001:db8:43::3 + ping -6 -c 1 -b 70000 -s 65000 2001:db8:43::3 $(atf_get_srcdir)/CVE-2019-5597.py \ ${epair_send}a \ 2001:db8:42::1 \ 2001:db8:43::3 } v6_cleanup() { pft_cleanup } atf_init_test_cases() { atf_add_test_case "too_many_fragments" atf_add_test_case "v6" } Index: head/tests/sys/netpfil/pf/pass_block.sh =================================================================== --- head/tests/sys/netpfil/pf/pass_block.sh (revision 368045) +++ head/tests/sys/netpfil/pf/pass_block.sh (revision 368046) @@ -1,198 +1,198 @@ # $FreeBSD$ # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2018 Kristof Provost # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. . $(atf_get_srcdir)/utils.subr atf_test_case "v4" "cleanup" v4_head() { atf_set descr 'Basic pass/block test for IPv4' atf_set require.user root } v4_body() { pft_init epair=$(vnet_mkepair) ifconfig ${epair}a 192.0.2.1/24 up # Set up a simple jail with one interface vnet_mkjail alcatraz ${epair}b jexec alcatraz ifconfig ${epair}b 192.0.2.2/24 up # Trivial ping to the jail, without pf atf_check -s exit:0 -o ignore ping -c 1 -t 1 192.0.2.2 # pf without policy will let us ping jexec alcatraz pfctl -e atf_check -s exit:0 -o ignore ping -c 1 -t 1 192.0.2.2 # Block everything pft_set_rules alcatraz "block in" atf_check -s exit:2 -o ignore ping -c 1 -t 1 192.0.2.2 # Block everything but ICMP pft_set_rules alcatraz "block in" "pass in proto icmp" atf_check -s exit:0 -o ignore ping -c 1 -t 1 192.0.2.2 } v4_cleanup() { pft_cleanup } atf_test_case "v6" "cleanup" v6_head() { atf_set descr 'Basic pass/block test for IPv6' atf_set require.user root } v6_body() { pft_init epair=$(vnet_mkepair) ifconfig ${epair}a inet6 2001:db8:42::1/64 up no_dad # Set up a simple jail with one interface vnet_mkjail alcatraz ${epair}b jexec alcatraz ifconfig ${epair}b inet6 2001:db8:42::2/64 up no_dad # Trivial ping to the jail, without pf - atf_check -s exit:0 -o ignore ping6 -c 1 -W 1 2001:db8:42::2 + atf_check -s exit:0 -o ignore ping -6 -c 1 -W 1 2001:db8:42::2 # pf without policy will let us ping jexec alcatraz pfctl -e - atf_check -s exit:0 -o ignore ping6 -c 1 -W 1 2001:db8:42::2 + atf_check -s exit:0 -o ignore ping -6 -c 1 -W 1 2001:db8:42::2 # Block everything pft_set_rules alcatraz "block in" - atf_check -s exit:2 -o ignore ping6 -c 1 -W 1 2001:db8:42::2 + atf_check -s exit:2 -o ignore ping -6 -c 1 -W 1 2001:db8:42::2 # Block everything but ICMP pft_set_rules alcatraz "block in" "pass in proto icmp6" - atf_check -s exit:0 -o ignore ping6 -c 1 -W 1 2001:db8:42::2 + atf_check -s exit:0 -o ignore ping -6 -c 1 -W 1 2001:db8:42::2 # Allowing ICMPv4 does not allow ICMPv6 pft_set_rules alcatraz "block in" "pass in proto icmp" - atf_check -s exit:2 -o ignore ping6 -c 1 -W 1 2001:db8:42::2 + atf_check -s exit:2 -o ignore ping -6 -c 1 -W 1 2001:db8:42::2 } v6_cleanup() { pft_cleanup } atf_test_case "noalias" "cleanup" noalias_head() { atf_set descr 'Test the :0 noalias option' atf_set require.user root } noalias_body() { pft_init epair=$(vnet_mkepair) ifconfig ${epair}a inet6 2001:db8:42::1/64 up no_dad vnet_mkjail alcatraz ${epair}b jexec alcatraz ifconfig ${epair}b inet6 2001:db8:42::2/64 up no_dad linklocaladdr=$(jexec alcatraz ifconfig ${epair}b inet6 \ | grep %${epair}b \ | awk '{ print $2; }' \ | cut -d % -f 1) # Sanity check - atf_check -s exit:0 -o ignore ping6 -c 3 -W 1 2001:db8:42::2 - atf_check -s exit:0 -o ignore ping6 -c 3 -W 1 ${linklocaladdr}%${epair}a + atf_check -s exit:0 -o ignore ping -6 -c 3 -W 1 2001:db8:42::2 + atf_check -s exit:0 -o ignore ping -6 -c 3 -W 1 ${linklocaladdr}%${epair}a jexec alcatraz pfctl -e pft_set_rules alcatraz "block out inet6 from (${epair}b:0) to any" - atf_check -s exit:2 -o ignore ping6 -c 3 -W 1 2001:db8:42::2 + atf_check -s exit:2 -o ignore ping -6 -c 3 -W 1 2001:db8:42::2 # We should still be able to ping the link-local address - atf_check -s exit:0 -o ignore ping6 -c 3 -W 1 ${linklocaladdr}%${epair}a + atf_check -s exit:0 -o ignore ping -6 -c 3 -W 1 ${linklocaladdr}%${epair}a pft_set_rules alcatraz "block out inet6 from (${epair}b) to any" # We cannot ping to the link-local address - atf_check -s exit:2 -o ignore ping6 -c 3 -W 1 ${linklocaladdr}%${epair}a + atf_check -s exit:2 -o ignore ping -6 -c 3 -W 1 ${linklocaladdr}%${epair}a } noalias_cleanup() { pft_cleanup } atf_test_case "nested_inline" "cleanup" nested_inline_head() { atf_set descr "Test nested inline anchors, PR196314" atf_set require.user root } nested_inline_body() { pft_init epair=$(vnet_mkepair) ifconfig ${epair}a inet 192.0.2.1/24 up vnet_mkjail alcatraz ${epair}b jexec alcatraz ifconfig ${epair}b 192.0.2.2/24 up jexec alcatraz pfctl -e pft_set_rules alcatraz \ "block in" \ "anchor \"an1\" {" \ "pass in quick proto tcp to port time" \ "anchor \"an2\" {" \ "pass in quick proto icmp" \ "}" \ "}" atf_check -s exit:0 -o ignore ping -c 1 -t 1 192.0.2.2 } nested_inline_cleanup() { pft_cleanup } atf_init_test_cases() { atf_add_test_case "v4" atf_add_test_case "v6" atf_add_test_case "noalias" atf_add_test_case "nested_inline" } Index: head/tests/sys/netpfil/pf/table.sh =================================================================== --- head/tests/sys/netpfil/pf/table.sh (revision 368045) +++ head/tests/sys/netpfil/pf/table.sh (revision 368046) @@ -1,115 +1,115 @@ # $FreeBSD$ # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2020 Mark Johnston # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. . $(atf_get_srcdir)/utils.subr TABLE_STATS_ZERO_REGEXP='Packets: 0[[:space:]]*Bytes: 0[[:space:]]' TABLE_STATS_NONZERO_REGEXP='Packets: [1-9][0-9]*[[:space:]]*Bytes: [1-9][0-9]*[[:space:]]' atf_test_case "v4_counters" "cleanup" v4_counters_head() { atf_set descr 'Verify per-address counters for v4' atf_set require.user root } v4_counters_body() { pft_init epair_send=$(vnet_mkepair) ifconfig ${epair_send}a 192.0.2.1/24 up vnet_mkjail alcatraz ${epair_send}b jexec alcatraz ifconfig ${epair_send}b 192.0.2.2/24 up jexec alcatraz pfctl -e pft_set_rules alcatraz \ "table counters { 192.0.2.1 }" \ "block all" \ "pass in from to any" \ "pass out from any to " atf_check -s exit:0 -o ignore ping -c 3 192.0.2.2 atf_check -s exit:0 -e ignore \ -o match:'In/Block:.*'"$TABLE_STATS_ZERO_REGEXP" \ -o match:'In/Pass:.*'"$TABLE_STATS_NONZERO_REGEXP" \ -o match:'Out/Block:.*'"$TABLE_STATS_ZERO_REGEXP" \ -o match:'Out/Pass:.*'"$TABLE_STATS_NONZERO_REGEXP" \ jexec alcatraz pfctl -t foo -T show -vv } v4_counters_cleanup() { pft_cleanup } atf_test_case "v6_counters" "cleanup" v6_counters_head() { atf_set descr 'Verify per-address counters for v6' atf_set require.user root } v6_counters_body() { pft_init epair_send=$(vnet_mkepair) ifconfig ${epair_send}a inet6 2001:db8:42::1/64 up no_dad -ifdisabled vnet_mkjail alcatraz ${epair_send}b jexec alcatraz ifconfig ${epair_send}b inet6 2001:db8:42::2/64 up no_dad jexec alcatraz pfctl -e pft_set_rules alcatraz \ "table counters { 2001:db8:42::1 }" \ "block all" \ "pass in from to any" \ "pass out from any to " - atf_check -s exit:0 -o ignore ping6 -c 3 2001:db8:42::2 + atf_check -s exit:0 -o ignore ping -6 -c 3 2001:db8:42::2 atf_check -s exit:0 -e ignore \ -o match:'In/Block:.*'"$TABLE_STATS_ZERO_REGEXP" \ -o match:'In/Pass:.*'"$TABLE_STATS_NONZERO_REGEXP" \ -o match:'Out/Block:.*'"$TABLE_STATS_ZERO_REGEXP" \ -o match:'Out/Pass:.*'"$TABLE_STATS_NONZERO_REGEXP" \ jexec alcatraz pfctl -t foo6 -T show -vv } v6_counters_cleanup() { pft_cleanup } atf_init_test_cases() { atf_add_test_case "v4_counters" atf_add_test_case "v6_counters" } Index: head/usr.sbin/traceroute6/traceroute6.8 =================================================================== --- head/usr.sbin/traceroute6/traceroute6.8 (revision 368045) +++ head/usr.sbin/traceroute6/traceroute6.8 (revision 368046) @@ -1,211 +1,210 @@ .\" $KAME: traceroute6.8,v 1.10 2004/06/06 12:35:15 suz Exp $ .\" .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. Neither the name of the project nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" -.Dd September 13, 2020 +.Dd November 25, 2020 .Dt TRACEROUTE6 8 .Os .\" .Sh NAME .Nm traceroute6 .Nd "print the route IPv6 packets will take to a network node" .\" .Sh SYNOPSIS .Nm .Bk -words .Op Fl adIlnNrSTUv .Ek .Bk -words .Op Fl f Ar firsthop .Ek .Bk -words .Op Fl g Ar gateway .Ek .Bk -words .Op Fl m Ar hoplimit .Ek .Bk -words .Op Fl p Ar port .Ek .Bk -words .Op Fl q Ar probes .Ek .Bk -words .Op Fl s Ar src .Ek .Bk -words .Op Fl t Ar tclass .Ek .Bk -words .Op Fl w Ar waittime .Ek .Bk -words .Op Fl A Ar as_server .Ek .Bk -words .Ar target .Op Ar datalen .Ek .\" .Sh DESCRIPTION The .Nm utility uses the IPv6 protocol hop limit field to elicit an ICMPv6 TIME_EXCEEDED response from each gateway along the path to some host. .Pp The only mandatory parameter is the destination host name or IPv6 address. The default probe datagram carries 20 bytes of payload, in addition to the IPv6 header. The size of the payload can be specified by giving a length (in bytes) after the destination host name. .Pp Other options are: .Bl -tag -width Ds .It Fl a Turn on AS# lookups for each hop encountered. .It Fl A Ar as_server Turn on AS# lookups and use the given server instead of the default. .It Fl d Debug mode. .It Fl f Ar firsthop Specify how many hops to skip in trace. .It Fl g Ar gateway Specify intermediate gateway. Please note that .Nm tries to use routing headers. .It Fl I Use ICMP6 ECHO instead of UDP datagrams. .It Fl l Print both host hostnames and numeric addresses. Normally .Nm prints only hostnames if .Fl n is not specified, and only numeric addresses if .Fl n is specified. .It Fl m Ar hoplimit Specify maximum hoplimit, up to 255. The default is the value of the .Va net.inet6.ip6.hlim .Xr sysctl 8 (the same default used for TCP connections). .It Fl n Do not resolve numeric address to hostname. .It Fl N Use a packet with no upper layer header for the probes, instead of UDP datagrams. .It Fl p Ar port Set SCTP/TCP/UDP port number to .Ar port . .It Fl q Ar probes Set the number of probe per hop count to .Ar probes . .It Fl r Bypass the normal routing tables and send directly to a host on an attached network. If the host is not on a directly-connected network, an error is returned. This option corresponds to the .Dv SO_DONTROUTE socket option; it can be used to ping a local host through an interface that has no route through it (e.g., after the interface was dropped by a routing daemon). .It Fl s Ar src .Ar Src specifies the source IPv6 address to be used. .It Fl S Use SCTP packets for the probes. The size of probe packets must be a multiple of 4. If .Ar datalen is up to 28, probe packets consist of a SHUTDOWN-ACK chunk possibly bundled with a PAD chunk. For larger probe packets, an INIT chunk is used. .It Fl t Ar tclass .Ar tclass specifies the .Em traffic class used when sending probe packets. The value must be a decimal integer in the range 0 to 255. The default is 0. .It Fl T Use TCP segments for the probes. .It Fl U Use UDP datagrams for the probes. This is the default. .It Fl v Be verbose. .It Fl w Ar waittime Specify the delay time between probes. .El .Pp This program prints the route to the given destination and the round-trip time to each gateway, in the same manner as traceroute. .Pp Here is a list of possible annotations after the round-trip time for each gateway: .Bl -hang -offset indent .It !N Destination Unreachable - No Route to Host. .It !P Destination Unreachable - Administratively Prohibited. .It !S Destination Unreachable - Not a Neighbour. .It !A Destination Unreachable - Address Unreachable. .It !H Parameter Problem - Unrecognized Next Header Type. .It !\& This is printed if the hop limit is <= 1 on a port unreachable message. This means that the packet got to the destination, but that the reply had a hop limit that was just large enough to allow it to get back to the source of the traceroute6. This was more interesting in the IPv4 case, where some IP stack bugs could be identified by this behaviour. .El .\" .Sh EXIT STATUS The .Nm utility will exit with 0 on success, and non-zero on errors. .\" .Sh SEE ALSO .Xr ping 8 , -.Xr ping6 8 , .Xr traceroute 8 .\" .Sh HISTORY The .Nm utility first appeared in WIDE hydrangea IPv6 protocol stack kit.