Skip to content

Commit 6b3f468

Browse files
pmachatadavem330
authored andcommitted
selftests: mlxsw: rif_lag_vlan: Add a new selftest
This test verifies driver behavior with regards to creation of RIFs for LAG VLAN uppers as ports are added or removed to/from the LAG. Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Danielle Ratson <danieller@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 4308967 commit 6b3f468

File tree

1 file changed

+146
-0
lines changed

1 file changed

+146
-0
lines changed
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
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+
vlan_create lag1 100
37+
ip link set dev lag1.100 addrgenmode none
38+
39+
vlan_create lag1 200
40+
ip link set dev lag1.200 addrgenmode none
41+
}
42+
43+
cleanup()
44+
{
45+
pre_cleanup
46+
47+
ip link del dev lag1.200
48+
ip link del dev lag1.100
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 del dev lag1
58+
}
59+
60+
lag_rif_add()
61+
{
62+
RET=0
63+
64+
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
65+
__addr_add_del lag1.100 add 192.0.2.2/28
66+
__addr_add_del lag1.200 add 192.0.2.18/28
67+
sleep 1
68+
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
69+
local expected_rifs=$((rifs_occ_t0 + 2))
70+
71+
((expected_rifs == rifs_occ_t1))
72+
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
73+
74+
log_test "Add RIFs for LAG VLANs on address addition"
75+
}
76+
77+
lag_rif_nomaster()
78+
{
79+
RET=0
80+
81+
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
82+
ip link set dev $swp1 nomaster
83+
sleep 1
84+
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
85+
local expected_rifs=$((rifs_occ_t0 - 2))
86+
87+
((expected_rifs == rifs_occ_t1))
88+
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
89+
90+
log_test "Drop RIFs for LAG VLANs on port deslavement"
91+
}
92+
93+
lag_rif_remaster()
94+
{
95+
RET=0
96+
97+
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
98+
ip link set dev $swp1 down
99+
ip link set dev $swp1 master lag1
100+
ip link set dev $swp1 up
101+
setup_wait_dev $swp1
102+
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
103+
local expected_rifs=$((rifs_occ_t0 + 2))
104+
105+
((expected_rifs == rifs_occ_t1))
106+
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
107+
108+
log_test "Add RIFs for LAG VLANs on port reenslavement"
109+
}
110+
111+
lag_rif_nomaster_addr()
112+
{
113+
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
114+
115+
# Adding an address while the port is LAG'd shouldn't generate a RIF.
116+
__addr_add_del $swp1 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 port from LAG should drop two RIFs for the LAG VLANs (as
125+
# tested in lag_rif_nomaster), but since the port now has an address, it
126+
# should gain a RIF.
127+
ip link set dev $swp1 nomaster
128+
sleep 1
129+
local rifs_occ_t2=$(devlink_resource_occ_get rifs)
130+
local expected_rifs=$((rifs_occ_t0 - 1))
131+
132+
((expected_rifs == rifs_occ_t2))
133+
check_err $? "After deslaving: Expected $expected_rifs RIFs, $rifs_occ_t2 are used"
134+
135+
__addr_add_del $swp1 del 192.0.2.65/28
136+
log_test "Add RIF for port on deslavement from LAG"
137+
}
138+
139+
trap cleanup EXIT
140+
141+
setup_prepare
142+
setup_wait
143+
144+
tests_run
145+
146+
exit $EXIT_STATUS

0 commit comments

Comments
 (0)