xref: /linux/tools/testing/selftests/drivers/net/team/propagation.sh (revision 1b98f357dadd6ea613a435fbaef1a5dd7b35fd21)
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4set -e
5
6NSIM_LRO_ID=$((256 + RANDOM % 256))
7NSIM_LRO_SYS=/sys/bus/netdevsim/devices/netdevsim$NSIM_LRO_ID
8
9NSIM_DEV_SYS_NEW=/sys/bus/netdevsim/new_device
10NSIM_DEV_SYS_DEL=/sys/bus/netdevsim/del_device
11
12cleanup()
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/
23team_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/
40team_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/
56team_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
74trap cleanup EXIT
75modprobe netdevsim || :
76echo $NSIM_LRO_ID > $NSIM_DEV_SYS_NEW
77udevadm settle
78team_lro
79team_promisc
80team_change_flags
81