netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC iproute2] tos: interpret ToS in natural numeral system
@ 2022-02-16 19:42 Jakub Kicinski
  2022-02-16 22:23 ` Guillaume Nault
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Jakub Kicinski @ 2022-02-16 19:42 UTC (permalink / raw)
  To: dsahern, stephen, gnault; +Cc: netdev, Jakub Kicinski

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.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
--
I get the feeling this was discussed in the past.

Also there's more:

devlink/devlink.c:	val = strtoull(str, &endptr, 10);
devlink/devlink.c:	val = strtoul(str, &endptr, 10);
devlink/devlink.c:	val = strtoul(str, &endptr, 10);
devlink/devlink.c:	val = strtoul(str, &endptr, 10);
lib/utils.c:	res = strtoul(arg, &ptr, base);
lib/utils.c:		n = strtoul(cp, &endp, 16);
lib/utils.c:		tmp = strtoul(tmpstr, &endptr, 16);
lib/utils.c:		tmp = strtoul(arg + i * 3, &endptr, 16);
misc/lnstat_util.c:			unsigned long f = strtoul(ptr, &ptr, 16);
tc/f_u32.c:	htid = strtoul(str, &tmp, 16);
tc/f_u32.c:		hash = strtoul(str, &tmp, 16);
tc/f_u32.c:			nodeid = strtoul(str, &tmp, 16);
tc/tc_util.c:	maj = strtoul(str, &p, 16);
tc/tc_util.c:	maj = strtoul(str, &p, 16);
tc/tc_util.c:		min = strtoul(str, &p, 16);
---
 lib/rt_names.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/rt_names.c b/lib/rt_names.c
index b976471d7979..7eb63dad7d4d 100644
--- a/lib/rt_names.c
+++ b/lib/rt_names.c
@@ -531,7 +531,7 @@ int rtnl_dsfield_a2n(__u32 *id, const char *arg)
 		}
 	}
 
-	res = strtoul(arg, &end, 16);
+	res = strtoul(arg, &end, 0);
 	if (!end || end == arg || *end || res > 255)
 		return -1;
 	*id = res;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-02-17 19:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2022-02-17 19:12 ` Stephen Hemminger
2022-02-17 19:14 ` Stephen Hemminger

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).