OSDN Git Service

net/sched: cbs: fix port_rate miscalculation
authorLeandro Dorileo <leandro.maciel.dorileo@intel.com>
Mon, 8 Apr 2019 17:12:18 +0000 (10:12 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 27 Jan 2020 13:50:37 +0000 (14:50 +0100)
commitc919556ac75646c02fcedd7097808d8e5a0553f4
treed899cd736ec89898089abd9d6eb8ae612896a0a9
parent963a94102f63624a86342292996c12e879d32930
net/sched: cbs: fix port_rate miscalculation

[ Upstream commit e0a7683d30e91e30ee6cf96314ae58a0314a095e ]

The Credit Based Shaper heavily depends on link speed to calculate
the scheduling credits, we can't properly calculate the credits if the
device has failed to report the link speed.

In that case we can't dequeue packets assuming a wrong port rate that will
result into an inconsistent credit distribution.

This patch makes sure we fail to dequeue case:

1) __ethtool_get_link_ksettings() reports error or 2) the ethernet driver
failed to set the ksettings' speed value (setting link speed to
SPEED_UNKNOWN).

Additionally we properly re calculate the port rate whenever the link speed
is changed.

Fixes: 3d0bd028ffb4a ("net/sched: Add support for HW offloading for CBS")
Signed-off-by: Leandro Dorileo <leandro.maciel.dorileo@intel.com>
Reviewed-by: Vedang Patel <vedang.patel@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/sched/sch_cbs.c