Skip to contentSkip to conversation

selftests: net: validate team flags propagation

PATCH Applied Stanislav Fomichev 2 participants 2 messages May 16, 2025 – May 21, 2025

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

PATCH v2 1/1 selftests: net: validate team flags propagation

Cover three recent cases:
1. missing ops locking for the lowers during netdev_sync_lower_features
2. missing locking for dev_set_promiscuity (plus netdev_ops_assert_locked with a comment on why/when it's needed)
3. rcu lock during team_change_rx_flags

Verified that each one triggers when the respective fix is reverted. Not sure about the placement, but since it all relies on teaming, added to the teaming directory.

One ugly bit is that I add NETIF_F_LRO to netdevsim; there is no way to trigger netdev_sync_lower_features without it.

---
v2: fix cleanup and wrong exit code (Jakub)

---
 drivers/net/netdevsim/netdev.c                |  2 +
 net/core/dev.c                                | 10 ++-
 .../selftests/drivers/net/team/Makefile       |  2 +-
 .../testing/selftests/drivers/net/team/config |  1 +
 .../selftests/drivers/net/team/propagation.sh | 80 +++++++++++++++++++
 5 files changed, 93 insertions(+), 2 deletions(-)
 create mode 100755 tools/testing/selftests/drivers/net/team/propagation.sh
drivers/net/netdevsim/netdev.c +2 -0
index 0e0321a7ddd7..3bd1f8cffee8 100644
@@ -879,11 +879,13 @@ static void nsim_setup(struct net_device *dev)
 			 NETIF_F_SG |
 			 NETIF_F_FRAGLIST |
 			 NETIF_F_HW_CSUM |
+			 NETIF_F_LRO |
 			 NETIF_F_TSO;
 	dev->hw_features |= NETIF_F_HW_TC |
 			    NETIF_F_SG |
 			    NETIF_F_FRAGLIST |
 			    NETIF_F_HW_CSUM |
+			    NETIF_F_LRO |
 			    NETIF_F_TSO;
 	dev->max_mtu = ETH_MAX_MTU;
 	dev->xdp_features = NETDEV_XDP_ACT_HW_OFFLOAD;
net/core/dev.c +9 -1
index 0d891634c692..4debd4b8e0f5 100644
@@ -9188,8 +9188,16 @@ static int __dev_set_promiscuity(struct net_device *dev, int inc, bool notify)
 
 		dev_change_rx_flags(dev, IFF_PROMISC);
 	}
-	if (notify)
+	if (notify) {
+		/* The ops lock is only required to ensure consistent locking
+		 * for `NETDEV_CHANGE` notifiers. This function is sometimes
+		 * called without the lock, even for devices that are ops
+		 * locked, such as in `dev_uc_sync_multiple` when using
+		 * bonding or teaming.
+		 */
+		netdev_ops_assert_locked(dev);
 		__dev_notify_flags(dev, old_flags, IFF_PROMISC, 0, NULL);
+	}
 	return 0;
 }
 
tools/testing/selftests/drivers/net/team/Makefile +1 -1
index 2d5a76d99181..eaf6938f100e 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 # Makefile for net selftests
 
-TEST_PROGS := dev_addr_lists.sh
+TEST_PROGS := dev_addr_lists.sh propagation.sh
 
 TEST_INCLUDES := \
 	../bonding/lag_lib.sh \
tools/testing/selftests/drivers/net/team/config +1 -0
index b5e3a3aad4bf..636b3525b679 100644
@@ -1,5 +1,6 @@
 CONFIG_DUMMY=y
 CONFIG_IPV6=y
 CONFIG_MACVLAN=y
+CONFIG_NETDEVSIM=m
 CONFIG_NET_TEAM=y
 CONFIG_NET_TEAM_MODE_LOADBALANCE=y
tools/testing/selftests/drivers/net/team/propagation.sh new file +80 -0

80 lines not on this page · raw message

Signature · 1 line
2.49.0
#1 lore raw
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Fri, 16 May 2025 16:22:05 -0700 you wrote:

Cover three recent cases:
1. missing ops locking for the lowers during netdev_sync_lower_features
2. missing locking for dev_set_promiscuity (plus netdev_ops_assert_locked with a comment on why/when it's needed)
3. rcu lock during team_change_rx_flags

Verified that each one triggers when the respective fix is reverted. Not sure about the placement, but since it all relies on teaming, added to the teaming directory.

[...]

Here is the summary with links:
- [net,v2] selftests: net: validate team flags propagation

    https://git.kernel.org/netdev/net-next/c/f792709e0baa

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html