aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/red.h
diff options
context:
space:
mode:
authorIlpo Järvinen <ilpo.jarvinen@helsinki.fi>2006-08-04 16:36:18 -0700
committerDavid S. Miller <davem@sunset.davemloft.net>2006-08-04 22:59:51 -0700
commitc4c0ce5c57ef0ca47a4428a14de6b5c8cdf8de8a (patch)
tree762530925f75495b9d2b8bb35702060e7e2fa9ae /include/net/red.h
parent[LLX]: SOCK_DGRAM interface fixes (diff)
downloadlinux-dev-c4c0ce5c57ef0ca47a4428a14de6b5c8cdf8de8a.tar.xz
linux-dev-c4c0ce5c57ef0ca47a4428a14de6b5c8cdf8de8a.zip
[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>
Diffstat (limited to 'include/net/red.h')
-rw-r--r--include/net/red.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/net/red.h b/include/net/red.h
index 5ccdbb3d4722..a4eb37946f2c 100644
--- a/include/net/red.h
+++ b/include/net/red.h
@@ -212,7 +212,7 @@ static inline unsigned long red_calc_qavg_from_idle_time(struct red_parms *p)
* Seems, it is the best solution to
* problem of too coarse exponent tabulation.
*/
- us_idle = (p->qavg * us_idle) >> p->Scell_log;
+ us_idle = (p->qavg * (u64)us_idle) >> p->Scell_log;
if (us_idle < (p->qavg >> 1))
return p->qavg - us_idle;