From: Stephen Hemminger stephen@networkplumber.org Sent: Monday, March 17, 2025 2:41 PM To: Chia-Yu Chang (Nokia) chia-yu.chang@nokia-bell-labs.com Cc: netdev@vger.kernel.org; dave.taht@gmail.com; pabeni@redhat.com; jhs@mojatatu.com; kuba@kernel.org; xiyou.wangcong@gmail.com; jiri@resnulli.us; davem@davemloft.net; edumazet@google.com; horms@kernel.org; andrew+netdev@lunn.ch; donald.hunter@gmail.com; ast@fiberby.net; liuhangbin@gmail.com; shuah@kernel.org; linux-kselftest@vger.kernel.org; ij@kernel.org; ncardwell@google.com; Koen De Schepper (Nokia) koen.de_schepper@nokia-bell-labs.com; g.white g.white@cablelabs.com; ingemar.s.johansson@ericsson.com; mirja.kuehlewind@ericsson.com; cheshire@apple.com; rs.ietf@gmx.at; Jason_Livingood@comcast.com; vidhi_goel vidhi_goel@apple.com; Olga Albisser olga@albisser.org; Olivier Tilmans (Nokia) olivier.tilmans@nokia.com; Bob Briscoe research@bobbriscoe.net; Henrik Steen henrist@henrist.net Subject: Re: [PATCH v4 iproute2-next 1/1] tc: add dualpi2 scheduler module
CAUTION: This is an external email. Please be very careful when clicking links or opening attachments. See the URL nok.it/ext for additional information.
On Sun, 16 Mar 2025 16:39:17 +0100 chia-yu.chang@nokia-bell-labs.com wrote:
+static int try_get_percentage(int *val, const char *arg, int base) {
long res;
char *ptr;
if (!arg || !*arg)
return -1;
res = strtol(arg, &ptr, base);
if (!ptr || ptr == arg || (*ptr && strcmp(ptr, "%")))
return -1;
if (res == ULONG_MAX && errno == ERANGE)
return -1;
if (res < 0 || res > 100)
return -1;
*val = res;
return 0;
+}
I wonder if dualpi2 and netem could share some code on handling scaled percentage values.
Thanks for the feedback, and I would reuse "parse_percent" in tc/tc_util.c in the next version.
Since the scaling factor of percentage in netem is to UINT32_MAX, while in dualpi2 is between 0 to 100.