]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
openvswitch: meter: fix race when getting now_ms.
authorTao Liu <thomas.liu@ucloud.cn>
Thu, 13 May 2021 13:08:00 +0000 (21:08 +0800)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Thu, 15 Jul 2021 17:22:55 +0000 (19:22 +0200)
commit32396e16361b37e4c9ca81a4f895953a23a3487f
treed1ccbcdad2d447eb87c8a5a3be5876d3105921e3
parent9fc9c38be31682db1e8632eb4ded2f973393869e
openvswitch: meter: fix race when getting now_ms.

BugLink: https://bugs.launchpad.net/bugs/1931896
[ Upstream commit e4df1b0c24350a0f00229ff895a91f1072bd850d ]

We have observed meters working unexpected if traffic is 3+Gbit/s
with multiple connections.

now_ms is not pretected by meter->lock, we may get a negative
long_delta_ms when another cpu updated meter->used, then:
    delta_ms = (u32)long_delta_ms;
which will be a large value.

    band->bucket += delta_ms * band->rate;
then we get a wrong band->bucket.

OpenVswitch userspace datapath has fixed the same issue[1] some
time ago, and we port the implementation to kernel datapath.

[1] https://patchwork.ozlabs.org/project/openvswitch/patch/20191025114436.9746-1-i.maximets@ovn.org/

Fixes: 96fbc13d7e77 ("openvswitch: Add meter infrastructure")
Signed-off-by: Tao Liu <thomas.liu@ucloud.cn>
Suggested-by: Ilya Maximets <i.maximets@ovn.org>
Reviewed-by: Ilya Maximets <i.maximets@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
net/openvswitch/meter.c