From owner-svn-src-all@freebsd.org Fri Sep 25 10:57:12 2020 Return-Path: Delivered-To: svn-src-all@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 9E17E3F26C6; Fri, 25 Sep 2020 10:57:12 +0000 (UTC) (envelope-from rscheff@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 4ByTQ03JlQz3VgG; Fri, 25 Sep 2020 10:57:12 +0000 (UTC) (envelope-from rscheff@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 5464111CE1; Fri, 25 Sep 2020 10:57:12 +0000 (UTC) (envelope-from rscheff@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 08PAvCOi021431; Fri, 25 Sep 2020 10:57:12 GMT (envelope-from rscheff@FreeBSD.org) Received: (from rscheff@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 08PAvCxo021429; Fri, 25 Sep 2020 10:57:12 GMT (envelope-from rscheff@FreeBSD.org) Message-Id: <202009251057.08PAvCxo021429@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rscheff set sender to rscheff@FreeBSD.org using -f From: Richard Scheffenegger Date: Fri, 25 Sep 2020 10:57:12 +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: r366152 - stable/12/sbin/ping6 X-SVN-Group: stable-12 X-SVN-Commit-Author: rscheff X-SVN-Commit-Paths: stable/12/sbin/ping6 X-SVN-Commit-Revision: 366152 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Sep 2020 10:57:12 -0000 Author: rscheff Date: Fri Sep 25 10:57:11 2020 New Revision: 366152 URL: https://svnweb.freebsd.org/changeset/base/366152 Log: MFC r365547: Add -z "TOS" option to ping6, to test DSCP/ECN values ping has the option to add the (deprecated) TOS byte using the -z option. Adding the same option, with the same (deprecated) Traffic Class Byte (nowadays actually DSCP and ECN fields) to ping6 to validate proper QoS processing in network switches. Reviewed by: tuexen MFC after: 2 weeks Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D26384 Modified: stable/12/sbin/ping6/ping6.8 stable/12/sbin/ping6/ping6.c Modified: stable/12/sbin/ping6/ping6.8 ============================================================================== --- stable/12/sbin/ping6/ping6.8 Fri Sep 25 10:49:26 2020 (r366151) +++ stable/12/sbin/ping6/ping6.8 Fri Sep 25 10:57:11 2020 (r366152) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 22, 2014 +.Dd September 10, 2020 .Dt PING6 8 .Os .Sh NAME @@ -87,6 +87,9 @@ packets to network hosts .Op Fl s Ar packetsize .Ek .Bk -words +.Op Fl z Ar tclass +.Ek +.Bk -words .Op Ar hops ... .Ek .Bk -words @@ -329,6 +332,8 @@ This option is present for backward compatibility. has no effect if .Fl w is specified. +.It Fl z Ar tclass +Use the specified traffic class when sending. .It Ar hops IPv6 addresses for intermediate nodes, which will be put into type 0 routing header. Modified: stable/12/sbin/ping6/ping6.c ============================================================================== --- stable/12/sbin/ping6/ping6.c Fri Sep 25 10:49:26 2020 (r366151) +++ stable/12/sbin/ping6/ping6.c Fri Sep 25 10:57:11 2020 (r366152) @@ -229,6 +229,7 @@ static char *hostname; static int ident; /* process id to identify our packets */ static u_int8_t nonce[8]; /* nonce field for node information */ static int hoplimit = -1; /* hoplimit */ +static int tclass = -1; /* traffic class */ static u_char *packet = NULL; static cap_channel_t *capdns; @@ -351,7 +352,7 @@ main(int argc, char *argv[]) #endif /*IPSEC_POLICY_IPSEC*/ #endif while ((ch = getopt(argc, argv, - "a:b:c:DdfHg:h:I:i:l:mnNop:qrRS:s:tvwWx:X:" ADDOPTS)) != -1) { + "a:b:c:DdfHg:h:I:i:l:mnNop:qrRS:s:tvwWx:X:z:" ADDOPTS)) != -1) { #undef ADDOPTS switch (ch) { case 'a': @@ -576,6 +577,14 @@ main(int argc, char *argv[]) optarg, MAXALARM); alarm((int)alarmtimeout); break; + case 'z': /* traffic class */ + tclass = strtol(optarg, &e, 10); + if (*optarg == '\0' || *e != '\0') + errx(1, "illegal traffic class %s", optarg); + if (255 < tclass || tclass < -1) + errx(1, + "illegal traffic class -- %s", optarg); + break; #ifdef IPSEC #ifdef IPSEC_POLICY_IPSEC case 'P': @@ -926,6 +935,12 @@ main(int argc, char *argv[]) memcpy(CMSG_DATA(scmsgp), &hoplimit, sizeof(hoplimit)); scmsgp = CMSG_NXTHDR(&smsghdr, scmsgp); + } + + if (tclass != -1) { + if (setsockopt(ssend, IPPROTO_IPV6, IPV6_TCLASS, + &tclass, sizeof(tclass)) == -1) + err(1, "setsockopt(IPV6_TCLASS)"); } if (argc > 1) { /* some intermediate addrs are specified */