]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
netem: remove unnecessary 64 bit modulus
authorStephen Hemminger <stephen@networkplumber.org>
Tue, 14 Nov 2017 19:27:02 +0000 (11:27 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 15 Nov 2017 05:14:16 +0000 (14:14 +0900)
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>
net/sched/sch_netem.c

index 644323d6081cf58a37d173a39844baf97bd8b87d..dd70924cbcdfe4d078f05d346cacf83abb1a9f2e 100644 (file)
@@ -312,9 +312,9 @@ static bool loss_event(struct netem_sched_data *q)
  * 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;
@@ -327,7 +327,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;