Commit c4c0ce5c57ef0ca47a4428a14de6b5c8cdf8de8a
Committed by
David S. Miller
1 parent
30a584d944
Exists in
master
and in
39 other branches
[PKT_SCHED] RED: Fix overflow in calculation of queue average
Overflow can occur very easily with 32 bits, e.g., with 1 second us_idle is approx. 2^20, which leaves only 11-Wlog bits for queue length. Since the EWMA exponent is typically around 9, queue lengths larger than 2^2 cause overflow. Whether the affected branch is taken when us_idle is as high as 1 second, depends on Scell_log, but with rather reasonable configuration Scell_log is large enough to cause p->Stab to have zero index, which always results zero shift (typically also few other small indices result in zero shift). Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff
include/net/red.h
... | ... | @@ -212,7 +212,7 @@ |
212 | 212 | * Seems, it is the best solution to |
213 | 213 | * problem of too coarse exponent tabulation. |
214 | 214 | */ |
215 | - us_idle = (p->qavg * us_idle) >> p->Scell_log; | |
215 | + us_idle = (p->qavg * (u64)us_idle) >> p->Scell_log; | |
216 | 216 | |
217 | 217 | if (us_idle < (p->qavg >> 1)) |
218 | 218 | return p->qavg - us_idle; |