* [PATCH net-next] sch_netem: Bug fixing in calculating Netem interval
@ 2018-02-07 4:14 Md. Islam
2018-02-07 21:19 ` Stephen Hemminger
2018-02-08 2:59 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Md. Islam @ 2018-02-07 4:14 UTC (permalink / raw)
To: shemminger, netdev, edumazet
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:
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 7bbc13b..7c179ad 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;
(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
Many thanks!
Tamim
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] sch_netem: Bug fixing in calculating Netem interval
2018-02-07 4:14 [PATCH net-next] sch_netem: Bug fixing in calculating Netem interval Md. Islam
@ 2018-02-07 21:19 ` Stephen Hemminger
2018-02-08 2:59 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2018-02-07 21:19 UTC (permalink / raw)
To: Md. Islam; +Cc: shemminger, netdev, edumazet
On Tue, 6 Feb 2018 23:14:18 -0500
"Md. Islam" <mislam4@kent.edu> wrote:
> 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:
>
> diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
> index 7bbc13b..7c179ad 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;
>
>
> (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
Thanks for reporting the problem. The original code used 32 bit values
and got converted to 64 bit time values when it went to using ktime.
Your patch fixes the problem, and lets go with it.
The other alternaive would be to make sigma s64 but then it would could
cause unnecessary 64 bit modulus here.
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] sch_netem: Bug fixing in calculating Netem interval
2018-02-07 4:14 [PATCH net-next] sch_netem: Bug fixing in calculating Netem interval Md. Islam
2018-02-07 21:19 ` Stephen Hemminger
@ 2018-02-08 2:59 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-02-08 2:59 UTC (permalink / raw)
To: mislam4; +Cc: shemminger, netdev, edumazet
From: "Md. Islam" <mislam4@kent.edu>
Date: Tue, 6 Feb 2018 23:14:18 -0500
> 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:
...
> (rnd % (2 * sigma)) - sigma was overflowing s32. After applying the
> patch, I found following output which is desirable.
Applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-08 3:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-07 4:14 [PATCH net-next] sch_netem: Bug fixing in calculating Netem interval Md. Islam
2018-02-07 21:19 ` Stephen Hemminger
2018-02-08 2:59 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).