Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/tools/testing/selftests/drivers/net/team/propagation.sh
26296 views
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/[email protected]/
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/[email protected]/
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
81
82