Skip to content

Commit 0a368a5

Browse files
committed
Merge branch 'selftests-mlxsw'
Petr Machata says: ==================== selftests: New selftests for out-of-order-operations patches in mlxsw In the past, the mlxsw driver made the assumption that the user applies configuration in a bottom-up manner. Thus netdevices needed to be added to the bridge before IP addresses were configured on that bridge or SVI added on top of it, because whatever happened before a netdevice was mlxsw upper was generally ignored by mlxsw. Recently, several patch series were pushed to introduce the bookkeeping and replays necessary to offload the full state, not just the immediate configuration step. In this patchset, introduce new selftests that directly exercise the out of order code paths in mlxsw. - Patch #1 adds new tests into the existing selftest router_bridge.sh. - Patches #2-#5 add new generic selftests. - Patches #6-#8 add new mlxsw-specific selftests. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 10857e6 + 67d5ffb commit 0a368a5

File tree

9 files changed

+1580
-0
lines changed

9 files changed

+1580
-0
lines changed
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
4+
lib_dir=$(dirname $0)/../../../net/forwarding
5+
6+
ALL_TESTS="
7+
bridge_rif_add
8+
bridge_rif_nomaster
9+
bridge_rif_remaster
10+
bridge_rif_nomaster_addr
11+
bridge_rif_nomaster_port
12+
bridge_rif_remaster_port
13+
"
14+
15+
NUM_NETIFS=2
16+
source $lib_dir/lib.sh
17+
source $lib_dir/devlink_lib.sh
18+
19+
setup_prepare()
20+
{
21+
swp1=${NETIFS[p1]}
22+
swp2=${NETIFS[p2]}
23+
24+
team_create lag1 lacp
25+
ip link set dev lag1 addrgenmode none
26+
ip link set dev lag1 address $(mac_get $swp1)
27+
28+
team_create lag2 lacp
29+
ip link set dev lag2 addrgenmode none
30+
ip link set dev lag2 address $(mac_get $swp2)
31+
32+
ip link add name br1 type bridge vlan_filtering 1
33+
ip link set dev br1 addrgenmode none
34+
ip link set dev br1 address $(mac_get lag1)
35+
ip link set dev br1 up
36+
37+
ip link set dev lag1 master br1
38+
39+
ip link set dev $swp1 master lag1
40+
ip link set dev $swp1 up
41+
42+
ip link set dev $swp2 master lag2
43+
ip link set dev $swp2 up
44+
}
45+
46+
cleanup()
47+
{
48+
pre_cleanup
49+
50+
ip link set dev $swp2 nomaster
51+
ip link set dev $swp2 down
52+
53+
ip link set dev $swp1 nomaster
54+
ip link set dev $swp1 down
55+
56+
ip link del dev lag2
57+
ip link set dev lag1 nomaster
58+
ip link del dev lag1
59+
60+
ip link del dev br1
61+
}
62+
63+
bridge_rif_add()
64+
{
65+
RET=0
66+
67+
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
68+
__addr_add_del br1 add 192.0.2.2/28
69+
sleep 1
70+
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
71+
local expected_rifs=$((rifs_occ_t0 + 1))
72+
73+
((expected_rifs == rifs_occ_t1))
74+
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
75+
76+
log_test "Add RIF for bridge on address addition"
77+
}
78+
79+
bridge_rif_nomaster()
80+
{
81+
RET=0
82+
83+
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
84+
ip link set dev lag1 nomaster
85+
sleep 1
86+
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
87+
local expected_rifs=$((rifs_occ_t0 - 1))
88+
89+
((expected_rifs == rifs_occ_t1))
90+
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
91+
92+
log_test "Drop RIF for bridge on LAG deslavement"
93+
}
94+
95+
bridge_rif_remaster()
96+
{
97+
RET=0
98+
99+
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
100+
ip link set dev lag1 master br1
101+
sleep 1
102+
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
103+
local expected_rifs=$((rifs_occ_t0 + 1))
104+
105+
((expected_rifs == rifs_occ_t1))
106+
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
107+
108+
log_test "Add RIF for bridge on LAG reenslavement"
109+
}
110+
111+
bridge_rif_nomaster_addr()
112+
{
113+
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
114+
115+
# Adding an address while the LAG is enslaved shouldn't generate a RIF.
116+
__addr_add_del lag1 add 192.0.2.65/28
117+
sleep 1
118+
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
119+
local expected_rifs=$((rifs_occ_t0))
120+
121+
((expected_rifs == rifs_occ_t1))
122+
check_err $? "After adding IP: Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
123+
124+
# Removing the LAG from the bridge should drop RIF for the bridge (as
125+
# tested in bridge_rif_lag_nomaster), but since the LAG now has an
126+
# address, it should gain a RIF.
127+
ip link set dev lag1 nomaster
128+
sleep 1
129+
local rifs_occ_t2=$(devlink_resource_occ_get rifs)
130+
local expected_rifs=$((rifs_occ_t0))
131+
132+
((expected_rifs == rifs_occ_t2))
133+
check_err $? "After deslaving: Expected $expected_rifs RIFs, $rifs_occ_t2 are used"
134+
135+
log_test "Add RIF for LAG on deslavement from bridge"
136+
137+
__addr_add_del lag1 del 192.0.2.65/28
138+
ip link set dev lag1 master br1
139+
sleep 1
140+
}
141+
142+
bridge_rif_nomaster_port()
143+
{
144+
RET=0
145+
146+
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
147+
ip link set dev $swp1 nomaster
148+
sleep 1
149+
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
150+
local expected_rifs=$((rifs_occ_t0 - 1))
151+
152+
((expected_rifs == rifs_occ_t1))
153+
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
154+
155+
log_test "Drop RIF for bridge on deslavement of port from LAG"
156+
}
157+
158+
bridge_rif_remaster_port()
159+
{
160+
RET=0
161+
162+
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
163+
ip link set dev $swp1 down
164+
ip link set dev $swp1 master lag1
165+
ip link set dev $swp1 up
166+
setup_wait_dev $swp1
167+
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
168+
local expected_rifs=$((rifs_occ_t0 + 1))
169+
170+
((expected_rifs == rifs_occ_t1))
171+
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
172+
173+
log_test "Add RIF for bridge on reenslavement of port to LAG"
174+
}
175+
176+
trap cleanup EXIT
177+
178+
setup_prepare
179+
setup_wait
180+
181+
tests_run
182+
183+
exit $EXIT_STATUS
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
4+
lib_dir=$(dirname $0)/../../../net/forwarding
5+
6+
ALL_TESTS="
7+
lag_rif_add
8+
lag_rif_nomaster
9+
lag_rif_remaster
10+
lag_rif_nomaster_addr
11+
"
12+
13+
NUM_NETIFS=2
14+
source $lib_dir/lib.sh
15+
source $lib_dir/devlink_lib.sh
16+
17+
setup_prepare()
18+
{
19+
swp1=${NETIFS[p1]}
20+
swp2=${NETIFS[p2]}
21+
22+
team_create lag1 lacp
23+
ip link set dev lag1 addrgenmode none
24+
ip link set dev lag1 address $(mac_get $swp1)
25+
26+
team_create lag2 lacp
27+
ip link set dev lag2 addrgenmode none
28+
ip link set dev lag2 address $(mac_get $swp2)
29+
30+
ip link set dev $swp1 master lag1
31+
ip link set dev $swp1 up
32+
33+
ip link set dev $swp2 master lag2
34+
ip link set dev $swp2 up
35+
}
36+
37+
cleanup()
38+
{
39+
pre_cleanup
40+
41+
ip link set dev $swp2 nomaster
42+
ip link set dev $swp2 down
43+
44+
ip link set dev $swp1 nomaster
45+
ip link set dev $swp1 down
46+
47+
ip link del dev lag2
48+
ip link del dev lag1
49+
}
50+
51+
lag_rif_add()
52+
{
53+
RET=0
54+
55+
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
56+
__addr_add_del lag1 add 192.0.2.2/28
57+
sleep 1
58+
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
59+
local expected_rifs=$((rifs_occ_t0 + 1))
60+
61+
((expected_rifs == rifs_occ_t1))
62+
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
63+
64+
log_test "Add RIF for LAG on address addition"
65+
}
66+
67+
lag_rif_nomaster()
68+
{
69+
RET=0
70+
71+
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
72+
ip link set dev $swp1 nomaster
73+
sleep 1
74+
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
75+
local expected_rifs=$((rifs_occ_t0 - 1))
76+
77+
((expected_rifs == rifs_occ_t1))
78+
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
79+
80+
log_test "Drop RIF for LAG on port deslavement"
81+
}
82+
83+
lag_rif_remaster()
84+
{
85+
RET=0
86+
87+
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
88+
ip link set dev $swp1 down
89+
ip link set dev $swp1 master lag1
90+
ip link set dev $swp1 up
91+
setup_wait_dev $swp1
92+
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
93+
local expected_rifs=$((rifs_occ_t0 + 1))
94+
95+
((expected_rifs == rifs_occ_t1))
96+
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
97+
98+
log_test "Add RIF for LAG on port reenslavement"
99+
}
100+
101+
lag_rif_nomaster_addr()
102+
{
103+
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
104+
105+
# Adding an address while the port is LAG'd shouldn't generate a RIF.
106+
__addr_add_del $swp1 add 192.0.2.65/28
107+
sleep 1
108+
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
109+
local expected_rifs=$((rifs_occ_t0))
110+
111+
((expected_rifs == rifs_occ_t1))
112+
check_err $? "After adding IP: Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
113+
114+
# Removing the port from LAG should drop RIF for the LAG (as tested in
115+
# lag_rif_nomaster), but since the port now has an address, it should
116+
# gain a RIF.
117+
ip link set dev $swp1 nomaster
118+
sleep 1
119+
local rifs_occ_t2=$(devlink_resource_occ_get rifs)
120+
local expected_rifs=$((rifs_occ_t0))
121+
122+
((expected_rifs == rifs_occ_t2))
123+
check_err $? "After deslaving: Expected $expected_rifs RIFs, $rifs_occ_t2 are used"
124+
125+
__addr_add_del $swp1 del 192.0.2.65/28
126+
log_test "Add RIF for port on deslavement from LAG"
127+
}
128+
129+
trap cleanup EXIT
130+
131+
setup_prepare
132+
setup_wait
133+
134+
tests_run
135+
136+
exit $EXIT_STATUS

0 commit comments

Comments
 (0)