[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220616200814.15fff125@hermes.local>
Date: Thu, 16 Jun 2022 20:08:14 -0700
From: Stephen Hemminger <stephen@...workplumber.org>
To: Peilin Ye <yepeilin.cs@...il.com>
Cc: Jamal Hadi Salim <jhs@...atatu.com>,
Cong Wang <xiyou.wangcong@...il.com>,
Jiri Pirko <jiri@...nulli.us>,
Peilin Ye <peilin.ye@...edance.com>,
Yuming Chen <chenyuming.junnan@...edance.com>,
Ted Lin <ted@...tlyuseful.tech>,
Dave Taht <dave.taht@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, Cong Wang <cong.wang@...edance.com>
Subject: Re: [PATCH net] net/sched: sch_netem: Fix arithmetic in
netem_dump() for 32-bit platforms
On Thu, 16 Jun 2022 16:43:36 -0700
Peilin Ye <yepeilin.cs@...il.com> wrote:
> From: Peilin Ye <peilin.ye@...edance.com>
>
> As reported by Yuming, currently tc always show a latency of UINT_MAX
> for netem Qdisc's on 32-bit platforms:
>
> $ tc qdisc add dev dummy0 root netem latency 100ms
> $ tc qdisc show dev dummy0
> qdisc netem 8001: root refcnt 2 limit 1000 delay 275s 275s
> ^^^^^^^^^^^^^^^^
>
> Let us take a closer look at netem_dump():
>
> qopt.latency = min_t(psched_tdiff_t, PSCHED_NS2TICKS(q->latency,
> UINT_MAX);
>
> qopt.latency is __u32, psched_tdiff_t is signed long,
> (psched_tdiff_t)(UINT_MAX) is negative for 32-bit platforms, so
> qopt.latency is always UINT_MAX.
>
> Fix it by using psched_time_t (u64) instead.
>
> Note: confusingly, users have two ways to specify 'latency':
>
> 1. normally, via '__u32 latency' in struct tc_netem_qopt;
> 2. via the TCA_NETEM_LATENCY64 attribute, which is s64.
>
> For the second case, theoretically 'latency' could be negative. This
> patch ignores that corner case, since it is broken (i.e. assigning a
> negative s64 to __u32) anyways, and should be handled separately.
>
> Thanks Ted Lin for the analysis [1] .
>
> [1] https://github.com/raspberrypi/linux/issues/3512
>
> Reported-by: Yuming Chen <chenyuming.junnan@...edance.com>
> Fixes: 112f9cb65643 ("netem: convert to qdisc_watchdog_schedule_ns")
> Reviewed-by: Cong Wang <cong.wang@...edance.com>
> Signed-off-by: Peilin Ye <peilin.ye@...edance.com>
> ---
> net/sched/sch_netem.c | 4 ++--
Thanks for fixing.
Guess it is time to run netem on one of the Pi's.
Acked-by: Stephen Hemminger <stephen@...workplumber.org>
Powered by blists - more mailing lists