Blob Blame History Raw
From: Stephen Hemminger <stephen@networkplumber.org>
Date: Tue, 14 Nov 2017 11:27:02 -0800
Subject: netem: remove unnecessary 64 bit modulus
Patch-mainline: v4.15-rc1
Git-commit: 9b0ed89172efec1d9f214d173ad6046f10f6b742
References: bsc#1109837

Fix compilation on 32 bit platforms (where doing modulus operation
with 64 bit requires extra glibc functions) by truncation.
The jitter for table distribution is limited to a 32 bit value
because random numbers are scaled as 32 bit value.

Also fix some whitespace.

Fixes: 99803171ef04 ("netem: add uapi to express delay and jitter in nanoseconds")
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
 net/sched/sch_netem.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -313,9 +313,9 @@ static bool loss_event(struct netem_sche
  * std deviation sigma.  Uses table lookup to approximate the desired
  * distribution, and a uniformly-distributed pseudo-random source.
  */
-static s64 tabledist(s64 mu, s64 sigma,
+static s64 tabledist(s64 mu, s32 sigma,
 		     struct crndstate *state,
-			 const struct disttable *dist)
+		     const struct disttable *dist)
 {
 	s64 x;
 	long t;
@@ -328,7 +328,7 @@ static s64 tabledist(s64 mu, s64 sigma,
 
 	/* default uniform distribution */
 	if (dist == NULL)
-		return (rnd % (2*sigma)) - sigma + mu;
+		return (rnd % (2 * sigma)) - sigma + mu;
 
 	t = dist->table[rnd % dist->size];
 	x = (sigma % NETEM_DIST_SCALE) * t;