netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [iproute PATCH] tc: htb: Print default value in hex
@ 2018-10-19 15:42 Phil Sutter
  2018-10-22 16:56 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Phil Sutter @ 2018-10-19 15:42 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Jiri Pirko, netdev

Value of 'default' is assumed to be hexadecimal when parsing, so
consequently it should be printed in hex as well. This is a regression
introduced when adding JSON output.

Fixes: f354fa6aa5ff0 ("tc: jsonify htb qdisc")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 tc/q_htb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tc/q_htb.c b/tc/q_htb.c
index c8b2941d945b7..c69485db8ef7d 100644
--- a/tc/q_htb.c
+++ b/tc/q_htb.c
@@ -332,7 +332,7 @@ static int htb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 		if (RTA_PAYLOAD(tb[TCA_HTB_INIT])  < sizeof(*gopt)) return -1;
 
 		print_int(PRINT_ANY, "r2q", "r2q %d", gopt->rate2quantum);
-		print_uint(PRINT_ANY, "default", " default %u", gopt->defcls);
+		print_uint(PRINT_ANY, "default", " default %x", gopt->defcls);
 		print_uint(PRINT_ANY, "direct_packets_stat",
 			   " direct_packets_stat %u", gopt->direct_pkts);
 		if (show_details) {
-- 
2.19.0

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

* Re: [iproute PATCH] tc: htb: Print default value in hex
  2018-10-19 15:42 [iproute PATCH] tc: htb: Print default value in hex Phil Sutter
@ 2018-10-22 16:56 ` Stephen Hemminger
  2018-10-22 17:28   ` Phil Sutter
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2018-10-22 16:56 UTC (permalink / raw)
  To: Phil Sutter; +Cc: Jiri Pirko, netdev

On Fri, 19 Oct 2018 17:42:55 +0200
Phil Sutter <phil@nwl.cc> wrote:

> Value of 'default' is assumed to be hexadecimal when parsing, so
> consequently it should be printed in hex as well. This is a regression
> introduced when adding JSON output.
> 
> Fixes: f354fa6aa5ff0 ("tc: jsonify htb qdisc")
> Signed-off-by: Phil Sutter <phil@nwl.cc>
> ---
>  tc/q_htb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tc/q_htb.c b/tc/q_htb.c
> index c8b2941d945b7..c69485db8ef7d 100644
> --- a/tc/q_htb.c
> +++ b/tc/q_htb.c
> @@ -332,7 +332,7 @@ static int htb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
>  		if (RTA_PAYLOAD(tb[TCA_HTB_INIT])  < sizeof(*gopt)) return -1;
>  
>  		print_int(PRINT_ANY, "r2q", "r2q %d", gopt->rate2quantum);
> -		print_uint(PRINT_ANY, "default", " default %u", gopt->defcls);
> +		print_uint(PRINT_ANY, "default", " default %x", gopt->defcls);
>  		print_uint(PRINT_ANY, "direct_packets_stat",
>  			   " direct_packets_stat %u", gopt->direct_pkts);
>  		if (show_details) {

The output should be in hex. Because you used print_uint it will still be in decimal
in the JSON output.  The correct fix here is to use print_0xhex instead.

Please fix that, test it, and resubmit.

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

* Re: [iproute PATCH] tc: htb: Print default value in hex
  2018-10-22 16:56 ` Stephen Hemminger
@ 2018-10-22 17:28   ` Phil Sutter
  0 siblings, 0 replies; 3+ messages in thread
From: Phil Sutter @ 2018-10-22 17:28 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Jiri Pirko, netdev

On Mon, Oct 22, 2018 at 09:56:23AM -0700, Stephen Hemminger wrote:
> On Fri, 19 Oct 2018 17:42:55 +0200
> Phil Sutter <phil@nwl.cc> wrote:
> 
> > Value of 'default' is assumed to be hexadecimal when parsing, so
> > consequently it should be printed in hex as well. This is a regression
> > introduced when adding JSON output.
> > 
> > Fixes: f354fa6aa5ff0 ("tc: jsonify htb qdisc")
> > Signed-off-by: Phil Sutter <phil@nwl.cc>
> > ---
> >  tc/q_htb.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/tc/q_htb.c b/tc/q_htb.c
> > index c8b2941d945b7..c69485db8ef7d 100644
> > --- a/tc/q_htb.c
> > +++ b/tc/q_htb.c
> > @@ -332,7 +332,7 @@ static int htb_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
> >  		if (RTA_PAYLOAD(tb[TCA_HTB_INIT])  < sizeof(*gopt)) return -1;
> >  
> >  		print_int(PRINT_ANY, "r2q", "r2q %d", gopt->rate2quantum);
> > -		print_uint(PRINT_ANY, "default", " default %u", gopt->defcls);
> > +		print_uint(PRINT_ANY, "default", " default %x", gopt->defcls);
> >  		print_uint(PRINT_ANY, "direct_packets_stat",
> >  			   " direct_packets_stat %u", gopt->direct_pkts);
> >  		if (show_details) {
> 
> The output should be in hex. Because you used print_uint it will still be in decimal
> in the JSON output.  The correct fix here is to use print_0xhex instead.
> 
> Please fix that, test it, and resubmit.

I did test, but not JSON output. It is not a regression in the latter
because it has been like this since JSON output was added to HTB.
Assuming the output is programmatically parsed, it shouldn't matter too
much as well.

Grepping through the code I found three more cases where print_uint()
was used for data printed in %x. Should I fix those as well?

Thanks, Phil

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

end of thread, other threads:[~2018-10-23  1:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-19 15:42 [iproute PATCH] tc: htb: Print default value in hex Phil Sutter
2018-10-22 16:56 ` Stephen Hemminger
2018-10-22 17:28   ` Phil Sutter

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