Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net_sched: gen_estimator: extend packet counter to 64bit

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: d0083d98f685 ("net_sched: extend packet counter to 64bit")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
1c8dd9cb 2d791e3b

+2 -2
+2 -2
net/core/gen_estimator.c
··· 48 48 u8 intvl_log; /* period : (250ms << intvl_log) */ 49 49 50 50 seqcount_t seq; 51 - u32 last_packets; 51 + u64 last_packets; 52 52 u64 last_bytes; 53 53 54 54 u64 avpps; ··· 83 83 brate = (b.bytes - est->last_bytes) << (10 - est->ewma_log - est->intvl_log); 84 84 brate -= (est->avbps >> est->ewma_log); 85 85 86 - rate = (u64)(b.packets - est->last_packets) << (10 - est->ewma_log - est->intvl_log); 86 + rate = (b.packets - est->last_packets) << (10 - est->ewma_log - est->intvl_log); 87 87 rate -= (est->avpps >> est->ewma_log); 88 88 89 89 write_seqcount_begin(&est->seq);