From owner-svn-src-stable-12@freebsd.org Thu Oct 1 16:09:24 2020 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 47EF442C712; Thu, 1 Oct 2020 16:09:24 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4C2J3S17BWz4Kt3; Thu, 1 Oct 2020 16:09:24 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 09C291333F; Thu, 1 Oct 2020 16:09:24 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 091G9Npd012004; Thu, 1 Oct 2020 16:09:23 GMT (envelope-from tuexen@FreeBSD.org) Received: (from tuexen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 091G9Nkj012002; Thu, 1 Oct 2020 16:09:23 GMT (envelope-from tuexen@FreeBSD.org) Message-Id: <202010011609.091G9Nkj012002@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tuexen set sender to tuexen@FreeBSD.org using -f From: Michael Tuexen Date: Thu, 1 Oct 2020 16:09:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r366319 - stable/12/usr.sbin/traceroute6 X-SVN-Group: stable-12 X-SVN-Commit-Author: tuexen X-SVN-Commit-Paths: stable/12/usr.sbin/traceroute6 X-SVN-Commit-Revision: 366319 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Oct 2020 16:09:24 -0000 Author: tuexen Date: Thu Oct 1 16:09:23 2020 New Revision: 366319 URL: https://svnweb.freebsd.org/changeset/base/366319 Log: MFC r365685: Add a -t option to traceroute6 to control the traffic class used when sending probe packets. Modified: stable/12/usr.sbin/traceroute6/traceroute6.8 stable/12/usr.sbin/traceroute6/traceroute6.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/traceroute6/traceroute6.8 ============================================================================== --- stable/12/usr.sbin/traceroute6/traceroute6.8 Thu Oct 1 15:45:07 2020 (r366318) +++ stable/12/usr.sbin/traceroute6/traceroute6.8 Thu Oct 1 16:09:23 2020 (r366319) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 16, 2019 +.Dd September 13, 2020 .Dt TRACEROUTE6 8 .Os .\" @@ -61,6 +61,9 @@ .Op Fl s Ar src .Ek .Bk -words +.Op Fl t Ar tclass +.Ek +.Bk -words .Op Fl w Ar waittime .Ek .Bk -words @@ -148,6 +151,13 @@ 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 Modified: stable/12/usr.sbin/traceroute6/traceroute6.c ============================================================================== --- stable/12/usr.sbin/traceroute6/traceroute6.c Thu Oct 1 15:45:07 2020 (r366318) +++ stable/12/usr.sbin/traceroute6/traceroute6.c Thu Oct 1 16:09:23 2020 (r366319) @@ -341,6 +341,7 @@ static u_long max_hops = 30; static u_int16_t srcport; static u_int16_t port = 32768+666; /* start udp dest port # for probe packets */ static u_int16_t ident; +static int tclass = -1; static int options; /* socket options */ static int verbose; static int waittime = 5; /* time to wait for response (in seconds) */ @@ -359,7 +360,7 @@ main(int argc, char *argv[]) int ch, i, on = 1, seq, rcvcmsglen, error; struct addrinfo hints, *res; static u_char *rcvcmsgbuf; - u_long probe, hops, lport; + u_long probe, hops, lport, ltclass; struct hostent *hp; size_t size, minlen; uid_t uid; @@ -406,7 +407,7 @@ main(int argc, char *argv[]) seq = 0; 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) { case 'a': as_path = 1; @@ -522,6 +523,17 @@ main(int argc, char *argv[]) case 'S': useproto = IPPROTO_SCTP; 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': useproto = IPPROTO_TCP; break; @@ -591,6 +603,13 @@ main(int argc, char *argv[]) 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) usage();