Skip to content

Commit

Permalink
net_sched: gen_estimator: extend packet counter to 64bit
Browse files Browse the repository at this point in the history
I forgot to change last_packets field in struct net_rate_estimator.

Without this fix, rate estimators would misbehave after more
than 2^32 packets have been sent.

Another solution would be to be careful and only use the
32 least significant bits of packets counters, but we have
a hole in net_rate_estimator structure and this looks
easier to read/maintain.

Fixes: d0083d9 ("net_sched: extend packet counter to 64bit")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Nov 7, 2019
1 parent 2d791e3 commit 1c8dd9c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/core/gen_estimator.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct net_rate_estimator {
u8 intvl_log; /* period : (250ms << intvl_log) */

seqcount_t seq;
u32 last_packets;
u64 last_packets;
u64 last_bytes;

u64 avpps;
Expand Down Expand Up @@ -83,7 +83,7 @@ static void est_timer(struct timer_list *t)
brate = (b.bytes - est->last_bytes) << (10 - est->ewma_log - est->intvl_log);
brate -= (est->avbps >> est->ewma_log);

rate = (u64)(b.packets - est->last_packets) << (10 - est->ewma_log - est->intvl_log);
rate = (b.packets - est->last_packets) << (10 - est->ewma_log - est->intvl_log);
rate -= (est->avpps >> est->ewma_log);

write_seqcount_begin(&est->seq);
Expand Down

0 comments on commit 1c8dd9c

Please sign in to comment.