net: dsa: mark parsed interface mode for legacy switch drivers
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Tue, 8 Aug 2023 11:12:16 +0000 (12:12 +0100)
committerJakub Kicinski <kuba@kernel.org>
Wed, 9 Aug 2023 20:08:09 +0000 (13:08 -0700)
commit145622771d22a7ad5061278eb6fb16396c29d308
treea9a0d1bec268647a0a0a87b8bfbe05f9fb061049
parent832140804e3b3ad19d73adebd25f69ed98778c58
net: dsa: mark parsed interface mode for legacy switch drivers

If we successfully parsed an interface mode with a legacy switch
driver, populate that mode into phylink's supported interfaces rather
than defaulting to the internal and gmii interfaces.

This hasn't caused an issue so far, because when the interface doesn't
match a supported one, phylink_validate() doesn't clear the supported
mask, but instead returns -EINVAL. phylink_parse_fixedlink() doesn't
check this return value, and merely relies on the supported ethtool
link modes mask being cleared. Therefore, the fixed link settings end
up being allowed despite validation failing.

Before this causes a problem, arrange for DSA to more accurately
populate phylink's supported interfaces mask so validation can
correctly succeed.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Link: https://lore.kernel.org/r/E1qTKdM-003Cpx-Eh@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/dsa/port.c