Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

Signed-off-by: Stanislav Fomichev <stfomichev@gmail.com>
Link: https://patch.msgid.link/20250516232205.539266-1-stfomichev@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Stanislav Fomichev and committed by
Jakub Kicinski
f792709e fa919a30

+93 -2
+2
drivers/net/netdevsim/netdev.c
··· 881 881 NETIF_F_SG | 882 882 NETIF_F_FRAGLIST | 883 883 NETIF_F_HW_CSUM | 884 + NETIF_F_LRO | 884 885 NETIF_F_TSO; 885 886 dev->hw_features |= NETIF_F_HW_TC | 886 887 NETIF_F_SG | 887 888 NETIF_F_FRAGLIST | 888 889 NETIF_F_HW_CSUM | 890 + NETIF_F_LRO | 889 891 NETIF_F_TSO; 890 892 dev->max_mtu = ETH_MAX_MTU; 891 893 dev->xdp_features = NETDEV_XDP_ACT_HW_OFFLOAD;
+9 -1
net/core/dev.c
··· 9278 9278 9279 9279 dev_change_rx_flags(dev, IFF_PROMISC); 9280 9280 } 9281 - if (notify) 9281 + if (notify) { 9282 + /* The ops lock is only required to ensure consistent locking 9283 + * for `NETDEV_CHANGE` notifiers. This function is sometimes 9284 + * called without the lock, even for devices that are ops 9285 + * locked, such as in `dev_uc_sync_multiple` when using 9286 + * bonding or teaming. 9287 + */ 9288 + netdev_ops_assert_locked(dev); 9282 9289 __dev_notify_flags(dev, old_flags, IFF_PROMISC, 0, NULL); 9290 + } 9283 9291 return 0; 9284 9292 } 9285 9293
+1 -1
tools/testing/selftests/drivers/net/team/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 # Makefile for net selftests 3 3 4 - TEST_PROGS := dev_addr_lists.sh 4 + TEST_PROGS := dev_addr_lists.sh propagation.sh 5 5 6 6 TEST_INCLUDES := \ 7 7 ../bonding/lag_lib.sh \
+1
tools/testing/selftests/drivers/net/team/config
··· 1 1 CONFIG_DUMMY=y 2 2 CONFIG_IPV6=y 3 3 CONFIG_MACVLAN=y 4 + CONFIG_NETDEVSIM=m 4 5 CONFIG_NET_TEAM=y 5 6 CONFIG_NET_TEAM_MODE_LOADBALANCE=y
+80
tools/testing/selftests/drivers/net/team/propagation.sh
··· 1 + #!/bin/bash 2 + # SPDX-License-Identifier: GPL-2.0 3 + 4 + set -e 5 + 6 + NSIM_LRO_ID=$((256 + RANDOM % 256)) 7 + NSIM_LRO_SYS=/sys/bus/netdevsim/devices/netdevsim$NSIM_LRO_ID 8 + 9 + NSIM_DEV_SYS_NEW=/sys/bus/netdevsim/new_device 10 + NSIM_DEV_SYS_DEL=/sys/bus/netdevsim/del_device 11 + 12 + cleanup() 13 + { 14 + set +e 15 + ip link del dummyteam &>/dev/null 16 + ip link del team0 &>/dev/null 17 + echo $NSIM_LRO_ID > $NSIM_DEV_SYS_DEL 18 + modprobe -r netdevsim 19 + } 20 + 21 + # Trigger LRO propagation to the lower. 22 + # https://lore.kernel.org/netdev/aBvOpkIoxcr9PfDg@mini-arch/ 23 + team_lro() 24 + { 25 + # using netdevsim because it supports NETIF_F_LRO 26 + NSIM_LRO_NAME=$(find $NSIM_LRO_SYS/net -maxdepth 1 -type d ! \ 27 + -path $NSIM_LRO_SYS/net -exec basename {} \;) 28 + 29 + ip link add name team0 type team 30 + ip link set $NSIM_LRO_NAME down 31 + ip link set dev $NSIM_LRO_NAME master team0 32 + ip link set team0 up 33 + ethtool -K team0 large-receive-offload off 34 + 35 + ip link del team0 36 + } 37 + 38 + # Trigger promisc propagation to the lower during IFLA_MASTER. 39 + # https://lore.kernel.org/netdev/20250506032328.3003050-1-sdf@fomichev.me/ 40 + team_promisc() 41 + { 42 + ip link add name dummyteam type dummy 43 + ip link add name team0 type team 44 + ip link set dummyteam down 45 + ip link set team0 promisc on 46 + ip link set dev dummyteam master team0 47 + ip link set team0 up 48 + 49 + ip link del team0 50 + ip link del dummyteam 51 + } 52 + 53 + # Trigger promisc propagation to the lower via netif_change_flags (aka 54 + # ndo_change_rx_flags). 55 + # https://lore.kernel.org/netdev/20250514220319.3505158-1-stfomichev@gmail.com/ 56 + team_change_flags() 57 + { 58 + ip link add name dummyteam type dummy 59 + ip link add name team0 type team 60 + ip link set dummyteam down 61 + ip link set dev dummyteam master team0 62 + ip link set team0 up 63 + ip link set team0 promisc on 64 + 65 + # Make sure we can add more L2 addresses without any issues. 66 + ip link add link team0 address 00:00:00:00:00:01 team0.1 type macvlan 67 + ip link set team0.1 up 68 + 69 + ip link del team0.1 70 + ip link del team0 71 + ip link del dummyteam 72 + } 73 + 74 + trap cleanup EXIT 75 + modprobe netdevsim || : 76 + echo $NSIM_LRO_ID > $NSIM_DEV_SYS_NEW 77 + udevadm settle 78 + team_lro 79 + team_promisc 80 + team_change_flags