Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

traceroute/traceroute6: Cleanup usage and manual fixes #901

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions contrib/traceroute/FREEBSD-upgrade
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
$FreeBSD$

This directory contains virgin copies of the original distribution files
on a "vendor" branch. Do not, under any circumstances, attempt to upgrade
the files in this directory via patches and a cvs commit.
Expand Down
1 change: 0 additions & 1 deletion contrib/traceroute/as.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* $FreeBSD$ */
/* $NetBSD: as.c,v 1.1 2001/11/04 23:14:36 atatat Exp $ */

/*
Expand Down
1 change: 0 additions & 1 deletion contrib/traceroute/as.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* $FreeBSD$ */
/* $NetBSD: as.h,v 1.1 2001/11/04 23:14:36 atatat Exp $ */

/*
Expand Down
3 changes: 1 addition & 2 deletions contrib/traceroute/ifaddrlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ ifaddrlist(register struct ifaddrlist **ipaddrp, register char *errbuf)
continue;


(void)strncpy(device, ifr.ifr_name, sizeof(ifr.ifr_name));
device[sizeof(device) - 1] = '\0';
(void)strlcpy(device, ifr.ifr_name, sizeof(device));
#ifdef sun
/* Ignore sun virtual interfaces */
if (strchr(device, ':') != NULL)
Expand Down
312 changes: 155 additions & 157 deletions contrib/traceroute/traceroute.8

Large diffs are not rendered by default.

15 changes: 7 additions & 8 deletions contrib/traceroute/traceroute.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ The Regents of the University of California. All rights reserved.\n";
static const char rcsid[] =
"@(#)$Id: traceroute.c,v 1.68 2000/12/14 08:04:33 leres Exp $ (LBL)";
#endif
static const char rcsid[] =
"$FreeBSD$";
#endif

/*
Expand Down Expand Up @@ -57,7 +55,7 @@ static const char rcsid[] =
* A sample use might be:
*
* [yak 71]% traceroute nis.nsf.net.
* traceroute to nis.nsf.net (35.1.1.48), 64 hops max, 56 byte packet
* traceroute to nis.nsf.net (35.1.1.48), 64 hops max, 40 byte packets
* 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
Expand All @@ -77,7 +75,7 @@ static const char rcsid[] =
* A more interesting example is:
*
* [yak 72]% traceroute allspice.lcs.mit.edu.
* traceroute to allspice.lcs.mit.edu (18.26.0.115), 64 hops max
* traceroute to allspice.lcs.mit.edu (18.26.0.115), 64 hops max, 40 byte packets
* 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
Expand Down Expand Up @@ -157,7 +155,7 @@ static const char rcsid[] =
* This program requires a kernel mod that does not appear in any
* system available from Berkeley: A raw ip socket using proto
* IPPROTO_RAW must interpret the data sent as an ip datagram (as
* opposed to data to be wrapped in a ip datagram). See the README
* opposed to data to be wrapped in an ip datagram). See the README
* file that came with the source to this program for a description
* of the mods I made to /sys/netinet/raw_ip.c. Your mileage may
* vary. But, again, ANY 4.x (x < 4) BSD KERNEL WILL HAVE TO BE
Expand Down Expand Up @@ -2152,8 +2150,9 @@ usage(void)

Fprintf(stderr, "Version %s\n", version);
Fprintf(stderr,
"Usage: %s [-adDeEFInrSvx] [-f first_ttl] [-g gateway] [-i iface]\n"
"\t[-m max_ttl] [-p port] [-P proto] [-q nqueries] [-s src_addr]\n"
"\t[-t tos] [-w waittime] [-A as_server] [-z pausemsecs] host [packetlen]\n", prog);
"Usage: %s [-adDeEFInrSvx] [-A as_server] [-f first_ttl] [-g gateway]\n"
"\t[-i iface] [-m max_ttl] [-M first_ttl] [-p port] [-P proto]\n"
"\t[-q nprobes] [-s src_addr] [-t tos] [-w waittime]\n"
"\t[-z pausemsecs] host [packetlen]\n", prog);
exit(1);
}
54 changes: 26 additions & 28 deletions usr.sbin/traceroute6/traceroute6.8
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd October 25, 2023
.Dd November 17, 2023
.Dt TRACEROUTE6 8
.Os
.\"
Expand All @@ -41,6 +41,9 @@
.Op Fl adEIlnNrSTUv
.Ek
.Bk -words
.Op Fl A Ar as_server
.Ek
.Bk -words
.Op Fl f Ar firsthop
.Ek
.Bk -words
Expand All @@ -65,26 +68,21 @@
.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.
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.
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
Expand Down Expand Up @@ -137,25 +135,24 @@ The default is the value of the
.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.
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.
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).
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.
Expand Down Expand Up @@ -185,10 +182,11 @@ Be verbose.
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.
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:
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.
Expand All @@ -202,11 +200,11 @@ Destination Unreachable - Address Unreachable.
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.
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
Expand Down
19 changes: 9 additions & 10 deletions usr.sbin/traceroute6/traceroute6.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@
* 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 30 hops & can be changed with the -m flag). Three
* probes (change with -q flag) are sent at each ttl setting and a
* line is printed showing the ttl, address of the gateway and
* defaults to net.inet.ip.ttl hops & can be changed with the -m flag).
* Three probes (change with -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
Expand All @@ -89,7 +89,7 @@
* A sample use might be:
*
* [yak 71]% traceroute nis.nsf.net.
* traceroute to nis.nsf.net (35.1.1.48), 30 hops max, 56 byte packet
* traceroute to nis.nsf.net (35.1.1.48), 64 hops max, 40 byte packets
* 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
Expand All @@ -109,7 +109,7 @@
* A more interesting example is:
*
* [yak 72]% traceroute allspice.lcs.mit.edu.
* traceroute to allspice.lcs.mit.edu (18.26.0.115), 30 hops max
* traceroute to allspice.lcs.mit.edu (18.26.0.115), 64 hops max, 40 byte packets
* 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
Expand Down Expand Up @@ -230,7 +230,7 @@
* back to yourself. Unfortunately, SO many gateways botch source
* routing, the thing is almost worthless. Maybe one day...
*
* -- Van Jacobson (van@helios.ee.lbl.gov)
* -- Van Jacobson (van@ee.lbl.gov)
* Tue Dec 20 03:50:13 PST 1988
*/

Expand Down Expand Up @@ -1822,10 +1822,9 @@ tcp_chksum(struct sockaddr_in6 *src, struct sockaddr_in6 *dst,
void
usage(void)
{

fprintf(stderr,
"usage: traceroute6 [-adEIlnNrSTUv] [-A as_server] [-f firsthop] [-g gateway]\n"
" [-m hoplimit] [-p port] [-q probes] [-s src] [-w waittime] target\n"
" [datalen]\n");
"Usage: traceroute6 [-adEIlnNrSTUv] [-A as_server] [-f firsthop] [-g gateway]\n"
"\t[-m hoplimit] [-p port] [-q probes] [-s src] [-t tclass]\n"
"\t[-w waittime] target [datalen]\n");
exit(1);
}