linux/net/dsa
Vladimir Oltean 1bec0f0506 net: dsa: fix bridge_num not getting cleared after ports leaving the bridge
The dp->bridge_num is zero-based, with -1 being the encoding for an
invalid value. But dsa_bridge_num_put used to check for an invalid value
by comparing bridge_num with 0, which is of course incorrect.

The result is that the bridge_num will never get cleared by
dsa_bridge_num_put, and further port joins to other bridges will get a
bridge_num larger than the previous one, and once all the available
bridges with TX forwarding offload supported by the hardware get
exhausted, the TX forwarding offload feature is simply disabled.

In the case of sja1105, 7 iterations of the loop below are enough to
exhaust the TX forwarding offload bits, and further bridge joins operate
without that feature.

ip link add br0 type bridge vlan_filtering 1

while :; do
        ip link set sw0p2 master br0 && sleep 1
        ip link set sw0p2 nomaster && sleep 1
done

This issue is enough of an indication that having the dp->bridge_num
invalid encoding be a negative number is prone to bugs, so this will be
changed to a one-based value, with the dp->bridge_num of zero being the
indication of no bridge. However, that is material for net-next.

Fixes: f5e165e72b ("net: dsa: track unique bridge numbers across all DSA switch trees")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-10-08 15:47:45 -07:00
..
dsa2.c net: dsa: fix bridge_num not getting cleared after ports leaving the bridge 2021-10-08 15:47:45 -07:00
dsa_priv.h net: dsa: flush switchdev workqueue before tearing down CPU/DSA ports 2021-09-15 15:09:46 -07:00
dsa.c net: dsa: flush switchdev workqueue before tearing down CPU/DSA ports 2021-09-15 15:09:46 -07:00
Kconfig net: dsa: tag_sja1105: be dsa_loop-safe 2021-08-18 10:33:15 +01:00
Makefile net: dsa: build tag_8021q.c as part of DSA core 2021-07-20 06:36:42 -07:00
master.c dev_ioctl: split out ndo_eth_ioctl 2021-07-27 20:11:45 +01:00
port.c net: dsa: don't advertise 'rx-vlan-filter' when not needed 2021-08-24 09:30:58 +01:00
slave.c net: dsa: destroy the phylink instance on any error in dsa_slave_phy_setup 2021-09-15 15:03:36 -07:00
switch.c net: dsa: let drivers state that they need VLAN filtering while standalone 2021-08-24 09:30:58 +01:00
tag_8021q.c net: dsa: tag_8021q: fix notifiers broadcast when they shouldn't, and vice versa 2021-08-16 11:14:18 +01:00
tag_ar9331.c net: dsa: remove the struct packet_type argument from dsa_device_ops::rcv() 2021-08-02 15:13:15 +01:00
tag_brcm.c net: dsa: create a helper for locating EtherType DSA headers on RX 2021-08-11 14:44:58 +01:00
tag_dsa.c dsa: tag_dsa: Fix mask for trunked packets 2021-10-04 13:43:55 +01:00
tag_gswip.c net: dsa: remove the struct packet_type argument from dsa_device_ops::rcv() 2021-08-02 15:13:15 +01:00
tag_hellcreek.c net: dsa: remove the struct packet_type argument from dsa_device_ops::rcv() 2021-08-02 15:13:15 +01:00
tag_ksz.c net: dsa: remove the struct packet_type argument from dsa_device_ops::rcv() 2021-08-02 15:13:15 +01:00
tag_lan9303.c net: dsa: create a helper for locating EtherType DSA headers on TX 2021-08-11 14:44:58 +01:00
tag_mtk.c net: dsa: create a helper for locating EtherType DSA headers on TX 2021-08-11 14:44:58 +01:00
tag_ocelot_8021q.c net: update NXP copyright text 2021-09-17 13:52:17 +01:00
tag_ocelot.c net: update NXP copyright text 2021-09-17 13:52:17 +01:00
tag_qca.c net: dsa: create a helper for locating EtherType DSA headers on TX 2021-08-11 14:44:58 +01:00
tag_rtl4_a.c net: dsa: tag_rtl4_a: Fix egress tags 2021-09-01 11:48:05 +01:00
tag_sja1105.c net: dsa: tag_sja1105: stop asking the sja1105 driver in sja1105_xmit_tpid 2021-08-25 11:14:34 +01:00
tag_trailer.c net: dsa: remove the struct packet_type argument from dsa_device_ops::rcv() 2021-08-02 15:13:15 +01:00
tag_xrs700x.c net: dsa: remove the struct packet_type argument from dsa_device_ops::rcv() 2021-08-02 15:13:15 +01:00