[iproute2,1/2] tc: pie: change maximum integer value of tc_pie_xstats->prob
diff mbox series

Message ID 20190323184835.20456-2-lesliemonis@gmail.com
State Changes Requested
Delegated to: stephen hemminger
Headers show
Series
  • tc: pie: make tc/q_pie.c consistent with the kernel
Related show

Commit Message

Leslie Monis March 23, 2019, 6:48 p.m. UTC
tc_pie_xstats->prob has a maximum value of (2^64 - 1).

Signed-off-by: Leslie Monis <lesliemonis@gmail.com>
---
 tc/q_pie.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stephen Hemminger March 27, 2019, 2:53 p.m. UTC | #1
On Sun, 24 Mar 2019 00:18:34 +0530
Leslie Monis <lesliemonis@gmail.com> wrote:

> tc_pie_xstats->prob has a maximum value of (2^64 - 1).
> 
> Signed-off-by: Leslie Monis <lesliemonis@gmail.com>
> ---
>  tc/q_pie.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tc/q_pie.c b/tc/q_pie.c
> index f7924ef5..6566ca10 100644
> --- a/tc/q_pie.c
> +++ b/tc/q_pie.c
> @@ -198,7 +198,7 @@ static int pie_print_xstats(struct qdisc_util *qu, FILE *f,
>  	st = RTA_DATA(xstats);
>  	/*prob is returned as a fracion of maximum integer value */
>  	fprintf(f, "prob %f delay %uus avg_dq_rate %u\n",
> -		(double)st->prob / (double)0xffffffff, st->delay,
> +		(double)st->prob / (double)0xffffffffffffffff, st->delay,

This won't work correctly on 32bit systems because that value won't fit there.. You would be better off using UINT64_MAX
Leslie Monis March 27, 2019, 3:24 p.m. UTC | #2
On Wed, Mar 27, 2019 at 07:53:57AM -0700, Stephen Hemminger wrote:
> On Sun, 24 Mar 2019 00:18:34 +0530
> Leslie Monis <lesliemonis@gmail.com> wrote:
> 
> > tc_pie_xstats->prob has a maximum value of (2^64 - 1).
> > 
> > Signed-off-by: Leslie Monis <lesliemonis@gmail.com>
> > ---
> >  tc/q_pie.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/tc/q_pie.c b/tc/q_pie.c
> > index f7924ef5..6566ca10 100644
> > --- a/tc/q_pie.c
> > +++ b/tc/q_pie.c
> > @@ -198,7 +198,7 @@ static int pie_print_xstats(struct qdisc_util *qu, FILE *f,
> >  	st = RTA_DATA(xstats);
> >  	/*prob is returned as a fracion of maximum integer value */
> >  	fprintf(f, "prob %f delay %uus avg_dq_rate %u\n",
> > -		(double)st->prob / (double)0xffffffff, st->delay,
> > +		(double)st->prob / (double)0xffffffffffffffff, st->delay,
> 
> This won't work correctly on 32bit systems because that value won't fit there.. You would be better off using UINT64_MAX

Alright. I will correct this.
Thanks

Patch
diff mbox series

diff --git a/tc/q_pie.c b/tc/q_pie.c
index f7924ef5..6566ca10 100644
--- a/tc/q_pie.c
+++ b/tc/q_pie.c
@@ -198,7 +198,7 @@  static int pie_print_xstats(struct qdisc_util *qu, FILE *f,
 	st = RTA_DATA(xstats);
 	/*prob is returned as a fracion of maximum integer value */
 	fprintf(f, "prob %f delay %uus avg_dq_rate %u\n",
-		(double)st->prob / (double)0xffffffff, st->delay,
+		(double)st->prob / (double)0xffffffffffffffff, st->delay,
 		st->avg_dq_rate);
 	fprintf(f, "pkts_in %u overlimit %u dropped %u maxq %u ecn_mark %u\n",
 		st->packets_in, st->overlimit, st->dropped, st->maxq,