Skip to contentSkip to conversation

selftests: net: validate team flags propagation

PATCH Superseded Stanislav Fomichev 2 participants 3 messages May 15, 2025 – May 16, 2025

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 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 | 79 +++++++++++++++++++
 5 files changed, 92 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 +79 -0

79 lines not on this page · raw message

Signature · 1 line
2.49.0
maintainer
#1 lore raw
Quoted 6 lines · On Thu, 15 May 2025 16:13:32 -0700 Stanislav Fomichev 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

Quoted 6 lines

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.

Seems to consistently fail in NIPA :(

Signature · 1 line
pw-bot: cr
#2 lore raw
Quoted 7 lines · Jakub Kicinski
Quoted 6 lines · On Thu, 15 May 2025 16:13:32 -0700 Stanislav Fomichev 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

Quoted 10 lines
Quoted 6 lines

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.

Seems to consistently fail in NIPA :(

Signature · 1 line
pw-bot: cr

Cleanup is a bit messy. Will add set +e and retest locally with vng, thanks!