netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: David Ahern <dsahern@gmail.com>, Guillaume Nault <gnault@redhat.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>,
	Cong Wang <xiyou.wangcong@gmail.com>,
	stephen@networkplumber.org, netdev@vger.kernel.org
Subject: Re: [RFC iproute2] tos: interpret ToS in natural numeral system
Date: Wed, 16 Feb 2022 18:40:25 -0800	[thread overview]
Message-ID: <20220216184025.153816f1@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> (raw)
In-Reply-To: <6dbf4b79-70d4-ed6c-0fd4-c393ab1c90b3@gmail.com>

On Wed, 16 Feb 2022 18:52:43 -0700 David Ahern wrote:
> On 2/16/22 3:23 PM, Guillaume Nault wrote:
> > On Wed, Feb 16, 2022 at 11:42:05AM -0800, Jakub Kicinski wrote:  
> >> Silently forcing a base numeral system is very painful for users.
> >> ip currently interprets tos 10 as 0x10. Imagine user's bash script
> >> does:
> >>
> >>   .. tos $((TOS * 2)) ..
> >>
> >> or any numerical operation on the ToS.
> >>
> >> This patch breaks existing scripts if they expect 10 to be 0x10.  
> > 
> > I agree that we shouldn't have forced base 16 in the first place.
> > But after so many years I find it a bit dangerous to change that.  
> 
> I agree. In this case the change in behavior will not be very obvious
> and could lead to confusion. I think this is something we have to live with.
> 
> > 
> > What about just printing a warning when the value isn't prefixed with
> > '0x'? Something like (completely untested):
> > 
> > @@ -535,6 +535,12 @@ int rtnl_dsfield_a2n(__u32 *id, const char *arg)
> >  	if (!end || end == arg || *end || res > 255)
> >  		return -1;
> >  	*id = res;
> > +
> > +	if (strncmp("0x", arg, 2))
> > +		fprintf(stderr,
> > +			"Warning: dsfield and tos parameters are interpreted as hexadecimal values\n"
> > +			"Use 'dsfield 0x%02x' to avoid this message\n", res);
> > +
> >  	return 0;
> >  }  
> 
> That seems reasonable to me to let users know of this behavior.

SGTM!

  reply	other threads:[~2022-02-17  2:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-16 19:42 [RFC iproute2] tos: interpret ToS in natural numeral system Jakub Kicinski
2022-02-16 22:23 ` Guillaume Nault
2022-02-16 22:44   ` David Laight
2022-02-17 11:18     ` Guillaume Nault
2022-02-17  1:52   ` David Ahern
2022-02-17  2:40     ` Jakub Kicinski [this message]
2022-02-17 19:12 ` Stephen Hemminger
2022-02-17 19:14 ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220216184025.153816f1@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com \
    --to=kuba@kernel.org \
    --cc=dsahern@gmail.com \
    --cc=gnault@redhat.com \
    --cc=jhs@mojatatu.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).