Re: let ping6 set the IPv6 traffic class like it does for IPv4 TOS
On Fri, Nov 09, 2018 at 06:43:06PM +1000, David Gwynne wrote: > On Fri, Nov 09, 2018 at 08:30:08AM +0100, Denis Fondras wrote: > > On Fri, Nov 09, 2018 at 05:07:10PM +1000, David Gwynne wrote: > > > On Fri, Nov 09, 2018 at 06:33:46AM +0100, Florian Obser wrote: > > > > please update usage(), then it's OK florian@ > > > > > > > > Could you do tracerute6, too? > > > > > > like this? > > > > > > > Can you also update traceroute.8 ? :) > > I can... > Thanks, OK denis@ > Index: sbin/ping/ping.8 > === > RCS file: /cvs/src/sbin/ping/ping.8,v > retrieving revision 1.59 > diff -u -p -r1.59 ping.8 > --- sbin/ping/ping.8 26 Oct 2016 16:18:45 - 1.59 > +++ sbin/ping/ping.8 9 Nov 2018 08:42:06 - > @@ -87,6 +87,7 @@ > .Op Fl l Ar preload > .Op Fl p Ar pattern > .Op Fl s Ar packetsize > +.Op Fl T Ar toskeyword > .Op Fl V Ar rtable > .Op Fl w Ar maxwait > .Ar host > @@ -221,8 +222,7 @@ which translates into 64 ICMP data bytes > when combined with the 8 bytes of ICMP header data. > The maximum packet size is 65467 for IPv4 and 65527 for IPv6. > .It Fl T Ar toskeyword > -.Pq IPv4 only > -Change the TOS value. > +Change the IPv4 TOS or IPv6 Traffic Class value. > .Ar toskeyword > may be one of > .Cm critical , > Index: sbin/ping/ping.c > === > RCS file: /cvs/src/sbin/ping/ping.c,v > retrieving revision 1.230 > diff -u -p -r1.230 ping.c > --- sbin/ping/ping.c 14 Oct 2018 19:47:53 - 1.230 > +++ sbin/ping/ping.c 9 Nov 2018 08:42:06 - > @@ -150,7 +150,7 @@ int options; > /* 0x0200 */ > #define F_HDRINCL 0x0400 > #define F_TTL 0x0800 > -/* 0x1000 */ > +#define F_TOS 0x1000 > #define F_AUD_RECV 0x2000 > #define F_AUD_MISS 0x4000 > > @@ -291,7 +291,7 @@ main(int argc, char *argv[]) > preload = 0; > datap = [ECHOLEN + ECHOTMLEN]; > while ((ch = getopt(argc, argv, v6flag ? > - "c:dEefHh:I:i:Ll:mNnp:qS:s:V:vw:" : > + "c:dEefHh:I:i:Ll:mNnp:qS:s:T:V:vw:" : > "DEI:LRS:c:defHi:l:np:qs:T:t:V:vw:")) != -1) { > switch(ch) { > case 'c': > @@ -386,6 +386,7 @@ main(int argc, char *argv[]) > #ifndef SMALL > case 'T': > options |= F_HDRINCL; > + options |= F_TOS; > errno = 0; > errstr = NULL; > if (map_tos(optarg, )) > @@ -673,6 +674,13 @@ main(int argc, char *argv[]) > *(int *)(CMSG_DATA(scmsg)) = hoplimit; > } > > + if (options & F_TOS) { > + optval = tos; > + if (setsockopt(s, IPPROTO_IPV6, IPV6_TCLASS, , > + (socklen_t)sizeof(optval)) < 0) > + warn("setsockopt(IPV6_TVAL)"); /* XXX err? */ > + } > + > optval = 1; > if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, , > (socklen_t)sizeof(optval)) < 0) > @@ -2160,7 +2168,8 @@ usage(void) > fprintf(stderr, > "usage: ping6 [-dEefHLmnqv] [-c count] [-h hoplimit] " > "[-I sourceaddr]\n\t[-i wait] [-l preload] [-p pattern] " > - "[-s packetsize] [-V rtable]\n\t[-w maxwait] host\n"); > + "[-s packetsize] [-T toskeyword]\n\t" > + "[-V rtable] [-w maxwait] host\n"); > } else { > fprintf(stderr, > "usage: ping [-DdEefHLnqRv] [-c count] [-I ifaddr]" > Index: usr.sbin/traceroute/traceroute.8 > === > RCS file: /cvs/src/usr.sbin/traceroute/traceroute.8,v > retrieving revision 1.66 > diff -u -p -r1.66 traceroute.8 > --- usr.sbin/traceroute/traceroute.8 21 Oct 2016 09:26:36 - 1.66 > +++ usr.sbin/traceroute/traceroute.8 9 Nov 2018 08:42:06 - > @@ -62,6 +62,7 @@ > .Op Fl p Ar port > .Op Fl q Ar nqueries > .Op Fl s Ar src_addr > +.Op Fl t Ar toskeyword > .Op Fl V Ar rtable > .Op Fl w Ar waittime > .Ar host > @@ -196,7 +197,6 @@ Useful values are probably > .Cm lowdelay > and > .Cm throughput . > -This option is not available for IPv6. > .It Fl V Ar rtable > Set the routing table to be used. > .It Fl v > Index: usr.sbin/traceroute/traceroute.c > === > RCS file: /cvs/src/usr.sbin/traceroute/traceroute.c,v > retrieving revision 1.157 > diff -u -p -r1.157 traceroute.c > --- usr.sbin/traceroute/traceroute.c 20 Oct 2018 19:55:01 - 1.157 > +++ usr.sbin/traceroute/traceroute.c 9 Nov 2018 08:42:06 - > @@ -414,7 +414,7 @@ main(int argc, char *argv[]) > err(1, "sysctl"); > conf->max_ttl = i; > > - while ((ch = getopt(argc, argv, v6flag
Re: let ping6 set the IPv6 traffic class like it does for IPv4 TOS
OK florian@ On Fri, Nov 09, 2018 at 06:43:06PM +1000, David Gwynne wrote: > On Fri, Nov 09, 2018 at 08:30:08AM +0100, Denis Fondras wrote: > > On Fri, Nov 09, 2018 at 05:07:10PM +1000, David Gwynne wrote: > > > On Fri, Nov 09, 2018 at 06:33:46AM +0100, Florian Obser wrote: > > > > please update usage(), then it's OK florian@ > > > > > > > > Could you do tracerute6, too? > > > > > > like this? > > > > > > > Can you also update traceroute.8 ? :) > > I can... > > Index: sbin/ping/ping.8 > === > RCS file: /cvs/src/sbin/ping/ping.8,v > retrieving revision 1.59 > diff -u -p -r1.59 ping.8 > --- sbin/ping/ping.8 26 Oct 2016 16:18:45 - 1.59 > +++ sbin/ping/ping.8 9 Nov 2018 08:42:06 - > @@ -87,6 +87,7 @@ > .Op Fl l Ar preload > .Op Fl p Ar pattern > .Op Fl s Ar packetsize > +.Op Fl T Ar toskeyword > .Op Fl V Ar rtable > .Op Fl w Ar maxwait > .Ar host > @@ -221,8 +222,7 @@ which translates into 64 ICMP data bytes > when combined with the 8 bytes of ICMP header data. > The maximum packet size is 65467 for IPv4 and 65527 for IPv6. > .It Fl T Ar toskeyword > -.Pq IPv4 only > -Change the TOS value. > +Change the IPv4 TOS or IPv6 Traffic Class value. > .Ar toskeyword > may be one of > .Cm critical , > Index: sbin/ping/ping.c > === > RCS file: /cvs/src/sbin/ping/ping.c,v > retrieving revision 1.230 > diff -u -p -r1.230 ping.c > --- sbin/ping/ping.c 14 Oct 2018 19:47:53 - 1.230 > +++ sbin/ping/ping.c 9 Nov 2018 08:42:06 - > @@ -150,7 +150,7 @@ int options; > /* 0x0200 */ > #define F_HDRINCL 0x0400 > #define F_TTL 0x0800 > -/* 0x1000 */ > +#define F_TOS 0x1000 > #define F_AUD_RECV 0x2000 > #define F_AUD_MISS 0x4000 > > @@ -291,7 +291,7 @@ main(int argc, char *argv[]) > preload = 0; > datap = [ECHOLEN + ECHOTMLEN]; > while ((ch = getopt(argc, argv, v6flag ? > - "c:dEefHh:I:i:Ll:mNnp:qS:s:V:vw:" : > + "c:dEefHh:I:i:Ll:mNnp:qS:s:T:V:vw:" : > "DEI:LRS:c:defHi:l:np:qs:T:t:V:vw:")) != -1) { > switch(ch) { > case 'c': > @@ -386,6 +386,7 @@ main(int argc, char *argv[]) > #ifndef SMALL > case 'T': > options |= F_HDRINCL; > + options |= F_TOS; > errno = 0; > errstr = NULL; > if (map_tos(optarg, )) > @@ -673,6 +674,13 @@ main(int argc, char *argv[]) > *(int *)(CMSG_DATA(scmsg)) = hoplimit; > } > > + if (options & F_TOS) { > + optval = tos; > + if (setsockopt(s, IPPROTO_IPV6, IPV6_TCLASS, , > + (socklen_t)sizeof(optval)) < 0) > + warn("setsockopt(IPV6_TVAL)"); /* XXX err? */ > + } > + > optval = 1; > if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, , > (socklen_t)sizeof(optval)) < 0) > @@ -2160,7 +2168,8 @@ usage(void) > fprintf(stderr, > "usage: ping6 [-dEefHLmnqv] [-c count] [-h hoplimit] " > "[-I sourceaddr]\n\t[-i wait] [-l preload] [-p pattern] " > - "[-s packetsize] [-V rtable]\n\t[-w maxwait] host\n"); > + "[-s packetsize] [-T toskeyword]\n\t" > + "[-V rtable] [-w maxwait] host\n"); > } else { > fprintf(stderr, > "usage: ping [-DdEefHLnqRv] [-c count] [-I ifaddr]" > Index: usr.sbin/traceroute/traceroute.8 > === > RCS file: /cvs/src/usr.sbin/traceroute/traceroute.8,v > retrieving revision 1.66 > diff -u -p -r1.66 traceroute.8 > --- usr.sbin/traceroute/traceroute.8 21 Oct 2016 09:26:36 - 1.66 > +++ usr.sbin/traceroute/traceroute.8 9 Nov 2018 08:42:06 - > @@ -62,6 +62,7 @@ > .Op Fl p Ar port > .Op Fl q Ar nqueries > .Op Fl s Ar src_addr > +.Op Fl t Ar toskeyword > .Op Fl V Ar rtable > .Op Fl w Ar waittime > .Ar host > @@ -196,7 +197,6 @@ Useful values are probably > .Cm lowdelay > and > .Cm throughput . > -This option is not available for IPv6. > .It Fl V Ar rtable > Set the routing table to be used. > .It Fl v > Index: usr.sbin/traceroute/traceroute.c > === > RCS file: /cvs/src/usr.sbin/traceroute/traceroute.c,v > retrieving revision 1.157 > diff -u -p -r1.157 traceroute.c > --- usr.sbin/traceroute/traceroute.c 20 Oct 2018 19:55:01 - 1.157 > +++ usr.sbin/traceroute/traceroute.c 9 Nov 2018 08:42:06 - > @@ -414,7 +414,7 @@ main(int argc, char *argv[]) > err(1, "sysctl"); > conf->max_ttl = i; > > - while ((ch = getopt(argc, argv, v6flag ?
Re: let ping6 set the IPv6 traffic class like it does for IPv4 TOS
On Fri, Nov 09, 2018 at 08:30:08AM +0100, Denis Fondras wrote: > On Fri, Nov 09, 2018 at 05:07:10PM +1000, David Gwynne wrote: > > On Fri, Nov 09, 2018 at 06:33:46AM +0100, Florian Obser wrote: > > > please update usage(), then it's OK florian@ > > > > > > Could you do tracerute6, too? > > > > like this? > > > > Can you also update traceroute.8 ? :) I can... Index: sbin/ping/ping.8 === RCS file: /cvs/src/sbin/ping/ping.8,v retrieving revision 1.59 diff -u -p -r1.59 ping.8 --- sbin/ping/ping.826 Oct 2016 16:18:45 - 1.59 +++ sbin/ping/ping.89 Nov 2018 08:42:06 - @@ -87,6 +87,7 @@ .Op Fl l Ar preload .Op Fl p Ar pattern .Op Fl s Ar packetsize +.Op Fl T Ar toskeyword .Op Fl V Ar rtable .Op Fl w Ar maxwait .Ar host @@ -221,8 +222,7 @@ which translates into 64 ICMP data bytes when combined with the 8 bytes of ICMP header data. The maximum packet size is 65467 for IPv4 and 65527 for IPv6. .It Fl T Ar toskeyword -.Pq IPv4 only -Change the TOS value. +Change the IPv4 TOS or IPv6 Traffic Class value. .Ar toskeyword may be one of .Cm critical , Index: sbin/ping/ping.c === RCS file: /cvs/src/sbin/ping/ping.c,v retrieving revision 1.230 diff -u -p -r1.230 ping.c --- sbin/ping/ping.c14 Oct 2018 19:47:53 - 1.230 +++ sbin/ping/ping.c9 Nov 2018 08:42:06 - @@ -150,7 +150,7 @@ int options; /* 0x0200 */ #defineF_HDRINCL 0x0400 #defineF_TTL 0x0800 -/* 0x1000 */ +#defineF_TOS 0x1000 #defineF_AUD_RECV 0x2000 #defineF_AUD_MISS 0x4000 @@ -291,7 +291,7 @@ main(int argc, char *argv[]) preload = 0; datap = [ECHOLEN + ECHOTMLEN]; while ((ch = getopt(argc, argv, v6flag ? - "c:dEefHh:I:i:Ll:mNnp:qS:s:V:vw:" : + "c:dEefHh:I:i:Ll:mNnp:qS:s:T:V:vw:" : "DEI:LRS:c:defHi:l:np:qs:T:t:V:vw:")) != -1) { switch(ch) { case 'c': @@ -386,6 +386,7 @@ main(int argc, char *argv[]) #ifndef SMALL case 'T': options |= F_HDRINCL; + options |= F_TOS; errno = 0; errstr = NULL; if (map_tos(optarg, )) @@ -673,6 +674,13 @@ main(int argc, char *argv[]) *(int *)(CMSG_DATA(scmsg)) = hoplimit; } + if (options & F_TOS) { + optval = tos; + if (setsockopt(s, IPPROTO_IPV6, IPV6_TCLASS, , + (socklen_t)sizeof(optval)) < 0) + warn("setsockopt(IPV6_TVAL)"); /* XXX err? */ + } + optval = 1; if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, , (socklen_t)sizeof(optval)) < 0) @@ -2160,7 +2168,8 @@ usage(void) fprintf(stderr, "usage: ping6 [-dEefHLmnqv] [-c count] [-h hoplimit] " "[-I sourceaddr]\n\t[-i wait] [-l preload] [-p pattern] " - "[-s packetsize] [-V rtable]\n\t[-w maxwait] host\n"); + "[-s packetsize] [-T toskeyword]\n\t" + "[-V rtable] [-w maxwait] host\n"); } else { fprintf(stderr, "usage: ping [-DdEefHLnqRv] [-c count] [-I ifaddr]" Index: usr.sbin/traceroute/traceroute.8 === RCS file: /cvs/src/usr.sbin/traceroute/traceroute.8,v retrieving revision 1.66 diff -u -p -r1.66 traceroute.8 --- usr.sbin/traceroute/traceroute.821 Oct 2016 09:26:36 - 1.66 +++ usr.sbin/traceroute/traceroute.89 Nov 2018 08:42:06 - @@ -62,6 +62,7 @@ .Op Fl p Ar port .Op Fl q Ar nqueries .Op Fl s Ar src_addr +.Op Fl t Ar toskeyword .Op Fl V Ar rtable .Op Fl w Ar waittime .Ar host @@ -196,7 +197,6 @@ Useful values are probably .Cm lowdelay and .Cm throughput . -This option is not available for IPv6. .It Fl V Ar rtable Set the routing table to be used. .It Fl v Index: usr.sbin/traceroute/traceroute.c === RCS file: /cvs/src/usr.sbin/traceroute/traceroute.c,v retrieving revision 1.157 diff -u -p -r1.157 traceroute.c --- usr.sbin/traceroute/traceroute.c20 Oct 2018 19:55:01 - 1.157 +++ usr.sbin/traceroute/traceroute.c9 Nov 2018 08:42:06 - @@ -414,7 +414,7 @@ main(int argc, char *argv[]) err(1, "sysctl"); conf->max_ttl = i; - while ((ch = getopt(argc, argv, v6flag ? "AcDdf:Ilm:np:q:Ss:w:vV:" : + while ((ch = getopt(argc, argv, v6flag ? "AcDdf:Ilm:np:q:Ss:t:w:vV:" : "AcDdf:g:Ilm:nP:p:q:Ss:t:V:vw:x")) != -1) switch (ch) { case 'A': @@ -802,6 +802,12 @@
Re: let ping6 set the IPv6 traffic class like it does for IPv4 TOS
On Fri, Nov 09, 2018 at 05:07:10PM +1000, David Gwynne wrote: > On Fri, Nov 09, 2018 at 06:33:46AM +0100, Florian Obser wrote: > > please update usage(), then it's OK florian@ > > > > Could you do tracerute6, too? > > like this? > Can you also update traceroute.8 ? :) > Index: sbin/ping/ping.8 > === > RCS file: /cvs/src/sbin/ping/ping.8,v > retrieving revision 1.59 > diff -u -p -r1.59 ping.8 > --- sbin/ping/ping.8 26 Oct 2016 16:18:45 - 1.59 > +++ sbin/ping/ping.8 9 Nov 2018 07:00:46 - > @@ -87,6 +87,7 @@ > .Op Fl l Ar preload > .Op Fl p Ar pattern > .Op Fl s Ar packetsize > +.Op Fl T Ar toskeyword > .Op Fl V Ar rtable > .Op Fl w Ar maxwait > .Ar host > @@ -221,8 +222,7 @@ which translates into 64 ICMP data bytes > when combined with the 8 bytes of ICMP header data. > The maximum packet size is 65467 for IPv4 and 65527 for IPv6. > .It Fl T Ar toskeyword > -.Pq IPv4 only > -Change the TOS value. > +Change the IPv4 TOS or IPv6 Traffic Class value. > .Ar toskeyword > may be one of > .Cm critical , > Index: sbin/ping/ping.c > === > RCS file: /cvs/src/sbin/ping/ping.c,v > retrieving revision 1.230 > diff -u -p -r1.230 ping.c > --- sbin/ping/ping.c 14 Oct 2018 19:47:53 - 1.230 > +++ sbin/ping/ping.c 9 Nov 2018 07:00:46 - > @@ -150,7 +150,7 @@ int options; > /* 0x0200 */ > #define F_HDRINCL 0x0400 > #define F_TTL 0x0800 > -/* 0x1000 */ > +#define F_TOS 0x1000 > #define F_AUD_RECV 0x2000 > #define F_AUD_MISS 0x4000 > > @@ -291,7 +291,7 @@ main(int argc, char *argv[]) > preload = 0; > datap = [ECHOLEN + ECHOTMLEN]; > while ((ch = getopt(argc, argv, v6flag ? > - "c:dEefHh:I:i:Ll:mNnp:qS:s:V:vw:" : > + "c:dEefHh:I:i:Ll:mNnp:qS:s:T:V:vw:" : > "DEI:LRS:c:defHi:l:np:qs:T:t:V:vw:")) != -1) { > switch(ch) { > case 'c': > @@ -386,6 +386,7 @@ main(int argc, char *argv[]) > #ifndef SMALL > case 'T': > options |= F_HDRINCL; > + options |= F_TOS; > errno = 0; > errstr = NULL; > if (map_tos(optarg, )) > @@ -673,6 +674,13 @@ main(int argc, char *argv[]) > *(int *)(CMSG_DATA(scmsg)) = hoplimit; > } > > + if (options & F_TOS) { > + optval = tos; > + if (setsockopt(s, IPPROTO_IPV6, IPV6_TCLASS, , > + (socklen_t)sizeof(optval)) < 0) > + warn("setsockopt(IPV6_TVAL)"); /* XXX err? */ > + } > + > optval = 1; > if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, , > (socklen_t)sizeof(optval)) < 0) > @@ -2160,7 +2168,8 @@ usage(void) > fprintf(stderr, > "usage: ping6 [-dEefHLmnqv] [-c count] [-h hoplimit] " > "[-I sourceaddr]\n\t[-i wait] [-l preload] [-p pattern] " > - "[-s packetsize] [-V rtable]\n\t[-w maxwait] host\n"); > + "[-s packetsize] [-T toskeyword]\n\t" > + "[-V rtable] [-w maxwait] host\n"); > } else { > fprintf(stderr, > "usage: ping [-DdEefHLnqRv] [-c count] [-I ifaddr]" > Index: usr.sbin/traceroute/traceroute.c > === > RCS file: /cvs/src/usr.sbin/traceroute/traceroute.c,v > retrieving revision 1.157 > diff -u -p -r1.157 traceroute.c > --- usr.sbin/traceroute/traceroute.c 20 Oct 2018 19:55:01 - 1.157 > +++ usr.sbin/traceroute/traceroute.c 9 Nov 2018 07:00:46 - > @@ -414,7 +414,7 @@ main(int argc, char *argv[]) > err(1, "sysctl"); > conf->max_ttl = i; > > - while ((ch = getopt(argc, argv, v6flag ? "AcDdf:Ilm:np:q:Ss:w:vV:" : > + while ((ch = getopt(argc, argv, v6flag ? "AcDdf:Ilm:np:q:Ss:t:w:vV:" : > "AcDdf:g:Ilm:nP:p:q:Ss:t:V:vw:x")) != -1) > switch (ch) { > case 'A': > @@ -802,6 +802,12 @@ main(int argc, char *argv[]) > 0) > err(1, "bind sndsock"); > > + if (conf->tflag) { > + if (setsockopt(sndsock, IPPROTO_IPV6, IPV6_TCLASS, > + >tos, sizeof(conf->tos)) < 0) > + err(6, "IPV6_TCLASS"); > + } > + > len = sizeof(from6); > if (getsockname(sndsock, (struct sockaddr *), ) < 0) > err(1, "getsockname"); > @@ -943,10 +949,10 @@ void > usage(int v6flag) > { > if (v6flag) { > - fprintf(stderr, "usage: traceroute6 [-AcDdIlnSv] [-f first_hop] > " > - "[-m max_hop] [-p
Re: let ping6 set the IPv6 traffic class like it does for IPv4 TOS
On Fri, Nov 09, 2018 at 06:33:46AM +0100, Florian Obser wrote: > please update usage(), then it's OK florian@ > > Could you do tracerute6, too? like this? Index: sbin/ping/ping.8 === RCS file: /cvs/src/sbin/ping/ping.8,v retrieving revision 1.59 diff -u -p -r1.59 ping.8 --- sbin/ping/ping.826 Oct 2016 16:18:45 - 1.59 +++ sbin/ping/ping.89 Nov 2018 07:00:46 - @@ -87,6 +87,7 @@ .Op Fl l Ar preload .Op Fl p Ar pattern .Op Fl s Ar packetsize +.Op Fl T Ar toskeyword .Op Fl V Ar rtable .Op Fl w Ar maxwait .Ar host @@ -221,8 +222,7 @@ which translates into 64 ICMP data bytes when combined with the 8 bytes of ICMP header data. The maximum packet size is 65467 for IPv4 and 65527 for IPv6. .It Fl T Ar toskeyword -.Pq IPv4 only -Change the TOS value. +Change the IPv4 TOS or IPv6 Traffic Class value. .Ar toskeyword may be one of .Cm critical , Index: sbin/ping/ping.c === RCS file: /cvs/src/sbin/ping/ping.c,v retrieving revision 1.230 diff -u -p -r1.230 ping.c --- sbin/ping/ping.c14 Oct 2018 19:47:53 - 1.230 +++ sbin/ping/ping.c9 Nov 2018 07:00:46 - @@ -150,7 +150,7 @@ int options; /* 0x0200 */ #defineF_HDRINCL 0x0400 #defineF_TTL 0x0800 -/* 0x1000 */ +#defineF_TOS 0x1000 #defineF_AUD_RECV 0x2000 #defineF_AUD_MISS 0x4000 @@ -291,7 +291,7 @@ main(int argc, char *argv[]) preload = 0; datap = [ECHOLEN + ECHOTMLEN]; while ((ch = getopt(argc, argv, v6flag ? - "c:dEefHh:I:i:Ll:mNnp:qS:s:V:vw:" : + "c:dEefHh:I:i:Ll:mNnp:qS:s:T:V:vw:" : "DEI:LRS:c:defHi:l:np:qs:T:t:V:vw:")) != -1) { switch(ch) { case 'c': @@ -386,6 +386,7 @@ main(int argc, char *argv[]) #ifndef SMALL case 'T': options |= F_HDRINCL; + options |= F_TOS; errno = 0; errstr = NULL; if (map_tos(optarg, )) @@ -673,6 +674,13 @@ main(int argc, char *argv[]) *(int *)(CMSG_DATA(scmsg)) = hoplimit; } + if (options & F_TOS) { + optval = tos; + if (setsockopt(s, IPPROTO_IPV6, IPV6_TCLASS, , + (socklen_t)sizeof(optval)) < 0) + warn("setsockopt(IPV6_TVAL)"); /* XXX err? */ + } + optval = 1; if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, , (socklen_t)sizeof(optval)) < 0) @@ -2160,7 +2168,8 @@ usage(void) fprintf(stderr, "usage: ping6 [-dEefHLmnqv] [-c count] [-h hoplimit] " "[-I sourceaddr]\n\t[-i wait] [-l preload] [-p pattern] " - "[-s packetsize] [-V rtable]\n\t[-w maxwait] host\n"); + "[-s packetsize] [-T toskeyword]\n\t" + "[-V rtable] [-w maxwait] host\n"); } else { fprintf(stderr, "usage: ping [-DdEefHLnqRv] [-c count] [-I ifaddr]" Index: usr.sbin/traceroute/traceroute.c === RCS file: /cvs/src/usr.sbin/traceroute/traceroute.c,v retrieving revision 1.157 diff -u -p -r1.157 traceroute.c --- usr.sbin/traceroute/traceroute.c20 Oct 2018 19:55:01 - 1.157 +++ usr.sbin/traceroute/traceroute.c9 Nov 2018 07:00:46 - @@ -414,7 +414,7 @@ main(int argc, char *argv[]) err(1, "sysctl"); conf->max_ttl = i; - while ((ch = getopt(argc, argv, v6flag ? "AcDdf:Ilm:np:q:Ss:w:vV:" : + while ((ch = getopt(argc, argv, v6flag ? "AcDdf:Ilm:np:q:Ss:t:w:vV:" : "AcDdf:g:Ilm:nP:p:q:Ss:t:V:vw:x")) != -1) switch (ch) { case 'A': @@ -802,6 +802,12 @@ main(int argc, char *argv[]) 0) err(1, "bind sndsock"); + if (conf->tflag) { + if (setsockopt(sndsock, IPPROTO_IPV6, IPV6_TCLASS, + >tos, sizeof(conf->tos)) < 0) + err(6, "IPV6_TCLASS"); + } + len = sizeof(from6); if (getsockname(sndsock, (struct sockaddr *), ) < 0) err(1, "getsockname"); @@ -943,10 +949,10 @@ void usage(int v6flag) { if (v6flag) { - fprintf(stderr, "usage: traceroute6 [-AcDdIlnSv] [-f first_hop] " - "[-m max_hop] [-p port]\n" - "\t[-q nqueries] [-s src_addr] [-V rtable] [-w waittime] " - "host\n\t[datalen]\n"); + fprintf(stderr, "usage: %s " + "[-AcDdIlnSv] [-f
Re: let ping6 set the IPv6 traffic class like it does for IPv4 TOS
please update usage(), then it's OK florian@ Could you do tracerute6, too? On Fri, Nov 09, 2018 at 03:08:20PM +1000, David Gwynne wrote: > This sets ping6 up to specify the traffic class field for the IPv6 > traffic class field. The v6 traffic class is equivalent to the IPv6 > TOS/DSCP field, so this uses the same getopt param and parsing to get > the value. > > ok? > > Index: ping.8 > === > RCS file: /cvs/src/sbin/ping/ping.8,v > retrieving revision 1.59 > diff -u -p -r1.59 ping.8 > --- ping.826 Oct 2016 16:18:45 - 1.59 > +++ ping.89 Nov 2018 05:05:35 - > @@ -87,6 +87,7 @@ > .Op Fl l Ar preload > .Op Fl p Ar pattern > .Op Fl s Ar packetsize > +.Op Fl T Ar toskeyword > .Op Fl V Ar rtable > .Op Fl w Ar maxwait > .Ar host > @@ -221,8 +222,7 @@ which translates into 64 ICMP data bytes > when combined with the 8 bytes of ICMP header data. > The maximum packet size is 65467 for IPv4 and 65527 for IPv6. > .It Fl T Ar toskeyword > -.Pq IPv4 only > -Change the TOS value. > +Change the IPv4 TOS or IPv6 Traffic Class value. > .Ar toskeyword > may be one of > .Cm critical , > Index: ping.c > === > RCS file: /cvs/src/sbin/ping/ping.c,v > retrieving revision 1.230 > diff -u -p -r1.230 ping.c > --- ping.c14 Oct 2018 19:47:53 - 1.230 > +++ ping.c9 Nov 2018 05:05:35 - > @@ -150,7 +150,7 @@ int options; > /* 0x0200 */ > #define F_HDRINCL 0x0400 > #define F_TTL 0x0800 > -/* 0x1000 */ > +#define F_TOS 0x1000 > #define F_AUD_RECV 0x2000 > #define F_AUD_MISS 0x4000 > > @@ -291,7 +291,7 @@ main(int argc, char *argv[]) > preload = 0; > datap = [ECHOLEN + ECHOTMLEN]; > while ((ch = getopt(argc, argv, v6flag ? > - "c:dEefHh:I:i:Ll:mNnp:qS:s:V:vw:" : > + "c:dEefHh:I:i:Ll:mNnp:qS:s:T:V:vw:" : > "DEI:LRS:c:defHi:l:np:qs:T:t:V:vw:")) != -1) { > switch(ch) { > case 'c': > @@ -386,6 +386,7 @@ main(int argc, char *argv[]) > #ifndef SMALL > case 'T': > options |= F_HDRINCL; > + options |= F_TOS; > errno = 0; > errstr = NULL; > if (map_tos(optarg, )) > @@ -671,6 +672,13 @@ main(int argc, char *argv[]) > scmsg->cmsg_level = IPPROTO_IPV6; > scmsg->cmsg_type = IPV6_HOPLIMIT; > *(int *)(CMSG_DATA(scmsg)) = hoplimit; > + } > + > + if (options & F_TOS) { > + optval = tos; > + if (setsockopt(s, IPPROTO_IPV6, IPV6_TCLASS, , > + (socklen_t)sizeof(optval)) < 0) > + warn("setsockopt(IPV6_TVAL)"); /* XXX err? */ > } > > optval = 1; > -- I'm not entirely sure you are real.