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