git: ba09352b7323 - main - traceroute: Standardize usage

From: Warner Losh <imp_at_FreeBSD.org>
Date: Sat, 03 Feb 2024 04:08:06 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=ba09352b73238bb4f1ca8586aab95cb2d9544bdc

commit ba09352b73238bb4f1ca8586aab95cb2d9544bdc
Author:     Jose Luis Duran <jlduran@gmail.com>
AuthorDate: 2023-11-05 18:35:23 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-02-03 03:14:09 +0000

    traceroute: Standardize usage
    
    Reviewed by: imp
    Pull Request: https://github.com/freebsd/freebsd-src/pull/901
---
 contrib/traceroute/traceroute.8    | 55 +++++++++++++++++++-------------------
 contrib/traceroute/traceroute.c    |  7 ++---
 usr.sbin/traceroute6/traceroute6.8 |  6 ++---
 usr.sbin/traceroute6/traceroute6.c |  7 +++--
 4 files changed, 38 insertions(+), 37 deletions(-)

diff --git a/contrib/traceroute/traceroute.8 b/contrib/traceroute/traceroute.8
index e19fb23f43b9..1ba11b75e37d 100644
--- a/contrib/traceroute/traceroute.8
+++ b/contrib/traceroute/traceroute.8
@@ -25,17 +25,18 @@
 .Nm
 .Bk -words
 .Op Fl adDeEFISnrvx
+.Op Fl A Ar as_server
 .Op Fl f Ar first_ttl
 .Op Fl g Ar gateway
-.Op Fl M Ar first_ttl
+.Op Fl i Ar iface
 .Op Fl m Ar max_ttl
-.Op Fl P Ar proto
+.Op Fl M Ar first_ttl
 .Op Fl p Ar port
+.Op Fl P Ar proto
 .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
@@ -62,6 +63,19 @@ 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
+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 e
 Firewall evasion mode.
 Use fixed destination ports for UDP, UDP-Lite, TCP and SCTP probes.
@@ -86,19 +100,6 @@ is also specified, the corresponding ECN bits will be replaced.
 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
@@ -109,9 +110,6 @@ host. (See the
 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
@@ -119,18 +117,13 @@ packets.  The default is the value of the
 .Xr sysctl 8
 (the same default used for TCP
 connections).
+.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 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
@@ -147,6 +140,14 @@ 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 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 q Ar nprobes
 Set the number of probes per hop (default is 3,
 unless
diff --git a/contrib/traceroute/traceroute.c b/contrib/traceroute/traceroute.c
index 144b6fd80928..ab744c47bed6 100644
--- a/contrib/traceroute/traceroute.c
+++ b/contrib/traceroute/traceroute.c
@@ -2152,8 +2152,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);
 }
diff --git a/usr.sbin/traceroute6/traceroute6.8 b/usr.sbin/traceroute6/traceroute6.8
index 1d71895fcde3..5abd4ba01c5b 100644
--- a/usr.sbin/traceroute6/traceroute6.8
+++ b/usr.sbin/traceroute6/traceroute6.8
@@ -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
@@ -65,9 +68,6 @@
 .Op Fl w Ar waittime
 .Ek
 .Bk -words
-.Op Fl A Ar as_server
-.Ek
-.Bk -words
 .Ar target
 .Op Ar datalen
 .Ek
diff --git a/usr.sbin/traceroute6/traceroute6.c b/usr.sbin/traceroute6/traceroute6.c
index f5e5f341e19a..dfe1d9565b94 100644
--- a/usr.sbin/traceroute6/traceroute6.c
+++ b/usr.sbin/traceroute6/traceroute6.c
@@ -1818,10 +1818,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);
 }