Add a -t option to traceroute6 to control the traffic class used when
sending probe packets. Reviewed by: rscheff MFC after: 1 week Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D26410
This commit is contained in:
parent
7be655c2b4
commit
c70906519a
@ -29,7 +29,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd July 16, 2019
|
.Dd September 13, 2020
|
||||||
.Dt TRACEROUTE6 8
|
.Dt TRACEROUTE6 8
|
||||||
.Os
|
.Os
|
||||||
.\"
|
.\"
|
||||||
@ -61,6 +61,9 @@
|
|||||||
.Op Fl s Ar src
|
.Op Fl s Ar src
|
||||||
.Ek
|
.Ek
|
||||||
.Bk -words
|
.Bk -words
|
||||||
|
.Op Fl t Ar tclass
|
||||||
|
.Ek
|
||||||
|
.Bk -words
|
||||||
.Op Fl w Ar waittime
|
.Op Fl w Ar waittime
|
||||||
.Ek
|
.Ek
|
||||||
.Bk -words
|
.Bk -words
|
||||||
@ -148,6 +151,13 @@ If
|
|||||||
.Ar datalen
|
.Ar datalen
|
||||||
is up to 28, probe packets consist of a SHUTDOWN-ACK chunk possibly bundled
|
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.
|
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
|
.It Fl T
|
||||||
Use TCP segments for the probes.
|
Use TCP segments for the probes.
|
||||||
.It Fl U
|
.It Fl U
|
||||||
|
@ -346,6 +346,7 @@ static u_long max_hops = 30;
|
|||||||
static u_int16_t srcport;
|
static u_int16_t srcport;
|
||||||
static u_int16_t port = 32768+666; /* start udp dest port # for probe packets */
|
static u_int16_t port = 32768+666; /* start udp dest port # for probe packets */
|
||||||
static u_int16_t ident;
|
static u_int16_t ident;
|
||||||
|
static int tclass = -1;
|
||||||
static int options; /* socket options */
|
static int options; /* socket options */
|
||||||
static int verbose;
|
static int verbose;
|
||||||
static int waittime = 5; /* time to wait for response (in seconds) */
|
static int waittime = 5; /* time to wait for response (in seconds) */
|
||||||
@ -364,7 +365,7 @@ main(int argc, char *argv[])
|
|||||||
int ch, i, on = 1, seq, rcvcmsglen, error;
|
int ch, i, on = 1, seq, rcvcmsglen, error;
|
||||||
struct addrinfo hints, *res;
|
struct addrinfo hints, *res;
|
||||||
static u_char *rcvcmsgbuf;
|
static u_char *rcvcmsgbuf;
|
||||||
u_long probe, hops, lport;
|
u_long probe, hops, lport, ltclass;
|
||||||
struct hostent *hp;
|
struct hostent *hp;
|
||||||
size_t size, minlen;
|
size_t size, minlen;
|
||||||
uid_t uid;
|
uid_t uid;
|
||||||
@ -414,7 +415,7 @@ main(int argc, char *argv[])
|
|||||||
seq = 0;
|
seq = 0;
|
||||||
ident = htons(getpid() & 0xffff); /* same as ping6 */
|
ident = htons(getpid() & 0xffff); /* same as ping6 */
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "aA:df:g:Ilm:nNp:q:rs:STUvw:")) != -1)
|
while ((ch = getopt(argc, argv, "aA:df:g:Ilm:nNp:q:rs:St:TUvw:")) != -1)
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'a':
|
case 'a':
|
||||||
as_path = 1;
|
as_path = 1;
|
||||||
@ -531,6 +532,17 @@ main(int argc, char *argv[])
|
|||||||
case 'S':
|
case 'S':
|
||||||
useproto = IPPROTO_SCTP;
|
useproto = IPPROTO_SCTP;
|
||||||
break;
|
break;
|
||||||
|
case 't':
|
||||||
|
ep = NULL;
|
||||||
|
errno = 0;
|
||||||
|
ltclass = strtoul(optarg, &ep, 0);
|
||||||
|
if (errno || !*optarg || *ep || ltclass > 255) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"traceroute6: invalid traffic class.\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
tclass = (int)ltclass;
|
||||||
|
break;
|
||||||
case 'T':
|
case 'T':
|
||||||
useproto = IPPROTO_TCP;
|
useproto = IPPROTO_TCP;
|
||||||
break;
|
break;
|
||||||
@ -595,6 +607,13 @@ main(int argc, char *argv[])
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tclass != -1) {
|
||||||
|
if (setsockopt(sndsock, IPPROTO_IPV6, IPV6_TCLASS, &tclass,
|
||||||
|
sizeof(int)) == -1) {
|
||||||
|
perror("setsockopt(IPV6_TCLASS)");
|
||||||
|
exit(7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (argc < 1 || argc > 2)
|
if (argc < 1 || argc > 2)
|
||||||
usage();
|
usage();
|
||||||
|
Loading…
Reference in New Issue
Block a user