diff mbox series

net: bridge: fix switchdev host mdb entry updates

Message ID 20240822163836.67061-1-nbd@nbd.name (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: bridge: fix switchdev host mdb entry updates | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 16 this patch: 16
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 16 this patch: 16
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 19 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-08-25--21-00 (tests: 714)

Commit Message

Felix Fietkau Aug. 22, 2024, 4:38 p.m. UTC
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.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 net/bridge/br_switchdev.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Paolo Abeni Aug. 27, 2024, 11:03 a.m. UTC | #1
Hi,

On 8/22/24 18:38, Felix Fietkau wrote:
> 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.
> 
> Signed-off-by: Felix Fietkau <nbd@nbd.name>

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
Felix Fietkau Aug. 27, 2024, 3:56 p.m. UTC | #2
On 27.08.24 13:03, Paolo Abeni wrote:
> Hi,
> 
> On 8/22/24 18:38, Felix Fietkau wrote:
>> 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.
>> 
>> Signed-off-by: Felix Fietkau <nbd@nbd.name>
> 
> 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
diff mbox series

Patch

diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
index 7b41ee8740cb..3490c3968638 100644
--- a/net/bridge/br_switchdev.c
+++ b/net/bridge/br_switchdev.c
@@ -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