Skip to contentSkip to conversation

net: bridge: fix switchdev host mdb entry updates

PATCH In review Felix Fietkau 2 participants 3 messages Aug 22, 2024 – Aug 27, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: bridge: fix switchdev host mdb entry updates

When a mdb entry is removed, the bridge switchdev code can issue a switchdev_port_obj_del call for a port that was not offloaded.

This leads to an imbalance in switchdev_port_obj_add/del calls, since br_switchdev_mdb_replay has not been called for the port before.

This can lead to potential multicast forwarding issues and messages such as:
mt7915e 0000:01:00.0 wl1-ap0: Failed to del Host Multicast Database entry

	(object id=3) with error: -ENOENT (-2).

Fix this issue by checking the port offload status when iterating over lower devs.

---
 net/bridge/br_switchdev.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
net/bridge/br_switchdev.c +9 -1
index 7b41ee8740cb..3490c3968638 100644
@@ -568,10 +568,18 @@ static void br_switchdev_host_mdb(struct net_device *dev,
 				  struct net_bridge_mdb_entry *mp, int type)
 {
 	struct net_device *lower_dev;
+	struct net_bridge_port *port;
 	struct list_head *iter;
 
-	netdev_for_each_lower_dev(dev, lower_dev, iter)
+	rcu_read_lock();
+	netdev_for_each_lower_dev(dev, lower_dev, iter) {
+		port = br_port_get_rcu(lower_dev);
+		if (!port || !port->offload_count)
+			continue;
+
 		br_switchdev_host_mdb_one(dev, lower_dev, mp, type);
+	}
+	rcu_read_unlock();
 }
 
 static int
Signature · 1 line
2.46.0
maintainer
#1 lore raw

Hi,

Quoted 6 lines · Felix Fietkau

When a mdb entry is removed, the bridge switchdev code can issue a switchdev_port_obj_del call for a port that was not offloaded.

This leads to an imbalance in switchdev_port_obj_add/del calls, since br_switchdev_mdb_replay has not been called for the port before.

Quoted 8 lines

This can lead to potential multicast forwarding issues and messages such as:
mt7915e 0000:01:00.0 wl1-ap0: Failed to del Host Multicast Database entry

	(object id=3) with error: -ENOENT (-2).

Fix this issue by checking the port offload status when iterating over lower devs.

This looks like a fix suitable for the net tree and deserving a fixes tag. Could you please repost adding both the target tree prefix and tag?

Thanks,

Paolo

#2 lore raw
Quoted 13 lines · Paolo Abeni

Hi,

Quoted 10 lines · Felix Fietkau

When a mdb entry is removed, the bridge switchdev code can issue a switchdev_port_obj_del call for a port that was not offloaded.

This leads to an imbalance in switchdev_port_obj_add/del calls, since br_switchdev_mdb_replay has not been called for the port before.

This can lead to potential multicast forwarding issues and messages such as:
mt7915e 0000:01:00.0 wl1-ap0: Failed to del Host Multicast Database entry

	(object id=3) with error: -ENOENT (-2).
Quoted 7 lines
Quoted 4 lines

Fix this issue by checking the port offload status when iterating over lower devs.

This looks like a fix suitable for the net tree and deserving a fixes tag. Could you please repost adding both the target tree prefix and tag?

Looking at the code changes, I wasn't able to figure out which commit introduced the bug. Do you have any ideas what commit I could reference in the Fixes tag?

- Felix