Bridge numbers are unique across all DSA trees, and a bridge spanning ports of two trees gets one number, which both trees use. dsa_port_bridge_destroy() puts the number when the last port of its own tree leaves the bridge, and dsa_bridge_num_put() clears the bit unconditionally, so the number is free while the other tree still offloads the bridge under it. The next bridge that gets a number then gets the same one: on a tag_8021q switch both bridges share a VLAN, on mv88e6xxx a cross-chip PVT row, and frames of one reach the ports of the other. Clear the bit only when no tree offloads the bridge under that number any more, as the put did before d3eed0e57d5d. Fixes: d3eed0e57d5d ("net: dsa: keep the bridge_dev and bridge_num as part of the same structure") Signed-off-by: Julius Bairaktaris --- v2 (v1 6/6): Fixes d3eed0e57d5d instead of f5e165e72b29 (Sashiko, Willem de Bruijn); correct with 1/7, which keeps the lookup from returning 0 from an unnumbered tree. net/dsa/dsa.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 4e697b8926a7..c11d983d9721 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -177,10 +177,13 @@ unsigned int dsa_bridge_num_get(const struct net_device *bridge_dev, int max) void dsa_bridge_num_put(const struct net_device *bridge_dev, unsigned int bridge_num) { - /* Since we refcount bridges, we know that when we call this function - * it is no longer in use, so we can just go ahead and remove it from - * the bit mask. + /* The bridge is no longer offloaded by the tree that calls this, but + * the number is global: another tree may still offload the bridge + * under it. */ + if (dsa_bridge_num_find(bridge_dev) == bridge_num) + return; + clear_bit(bridge_num, &dsa_fwd_offloading_bridges); } -- 2.53.0