sch_netem: Bug fixing in calculating Netem interval

"Linux Kernel Mailing List" <[email protected]>
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/043e337f555e610ad8237fd23522d97c968d72b9
Commit:     043e337f555e610ad8237fd23522d97c968d72b9
Parent:     62f94c2101f35cd45775df00ba09bde77580e26a
Refname:    refs/heads/master
Author:     Md. Islam <[email protected]>
AuthorDate: Tue Feb 6 23:14:18 2018 -0500
Committer:  David S. Miller <[email protected]>
CommitDate: Wed Feb 7 21:59:12 2018 -0500

    sch_netem: Bug fixing in calculating Netem interval
    
    In Kernel 4.15.0+, Netem does not work properly.
    
    Netem setup:
    
    tc qdisc add dev h1-eth0 root handle 1: netem delay 10ms 2ms
    
    Result:
    
    PING 172.16.101.2 (172.16.101.2) 56(84) bytes of data.
    64 bytes from 172.16.101.2: icmp_seq=1 ttl=64 time=22.8 ms
    64 bytes from 172.16.101.2: icmp_seq=2 ttl=64 time=10.9 ms
    64 bytes from 172.16.101.2: icmp_seq=3 ttl=64 time=10.9 ms
    64 bytes from 172.16.101.2: icmp_seq=5 ttl=64 time=11.4 ms
    64 bytes from 172.16.101.2: icmp_seq=6 ttl=64 time=11.8 ms
    64 bytes from 172.16.101.2: icmp_seq=4 ttl=64 time=4303 ms
    64 bytes from 172.16.101.2: icmp_seq=10 ttl=64 time=11.2 ms
    64 bytes from 172.16.101.2: icmp_seq=11 ttl=64 time=10.3 ms
    64 bytes from 172.16.101.2: icmp_seq=7 ttl=64 time=4304 ms
    64 bytes from 172.16.101.2: icmp_seq=8 ttl=64 time=4303 ms
    
    Patch:
    
    (rnd % (2 * sigma)) - sigma was overflowing s32. After applying the
    patch, I found following output which is desirable.
    
    PING 172.16.101.2 (172.16.101.2) 56(84) bytes of data.
    64 bytes from 172.16.101.2: icmp_seq=1 ttl=64 time=21.1 ms
    64 bytes from 172.16.101.2: icmp_seq=2 ttl=64 time=8.46 ms
    64 bytes from 172.16.101.2: icmp_seq=3 ttl=64 time=9.00 ms
    64 bytes from 172.16.101.2: icmp_seq=4 ttl=64 time=11.8 ms
    64 bytes from 172.16.101.2: icmp_seq=5 ttl=64 time=8.36 ms
    64 bytes from 172.16.101.2: icmp_seq=6 ttl=64 time=11.8 ms
    64 bytes from 172.16.101.2: icmp_seq=7 ttl=64 time=8.11 ms
    64 bytes from 172.16.101.2: icmp_seq=8 ttl=64 time=10.0 ms
    64 bytes from 172.16.101.2: icmp_seq=9 ttl=64 time=11.3 ms
    64 bytes from 172.16.101.2: icmp_seq=10 ttl=64 time=11.5 ms
    64 bytes from 172.16.101.2: icmp_seq=11 ttl=64 time=10.2 ms
    
    Reviewed-by: Stephen Hemminger <[email protected]>
    Signed-off-by: David S. Miller <[email protected]>
---
 net/sched/sch_netem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 7bbc13b8ca47..7c179addebcd 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -327,7 +327,7 @@ static s64 tabledist(s64 mu, s32 sigma,
 
 	/* default uniform distribution */
 	if (dist == NULL)
-		return (rnd % (2 * sigma)) - sigma + mu;
+		return ((rnd % (2 * sigma)) + mu) - sigma;
 
 	t = dist->table[rnd % dist->size];
 	x = (sigma % NETEM_DIST_SCALE) * t;
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.