Skip to content

Commit 776b64b

Browse files
fmaurer-rhPaolo Abeni
authored andcommitted
selftests: hsr: Check duplicates on HSR with VLAN
Previously the hsr_ping test only checked that all nodes in a VLAN are reachable (using do_ping). Update the test to also check that there is no packet loss and no duplicate packets by running the same tests for VLANs as without VLANs (including using do_ping_long). This also adds tests for IPv6 over VLAN. To unify the test code, the topology without VLANs now uses IP addresses from dead:beef:0::/64 to align with the 100.64.0.0/24 range for IPv4. Error messages are updated across the board to make it easier to find what actually failed. Also update the VLAN test to only run in VLAN 2, as there is no need to check if ping really works with VLAN IDs 2, 3, 4, and 5. This lowers the number of long ping tests on VLANs to keep the overall test runtime in bounds. It's still necessary to bump the test timeout a bit, though: a ping long tests takes 1sec, do_ping_tests performs 12 of them, do_link_problem_tests 6, and the VLAN tests again 12. With some buffer for setup and waiting and for two protocol versions, 90sec timeout seems reasonable. Signed-off-by: Felix Maurer <fmaurer@redhat.com> Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Link: https://patch.msgid.link/e3ded0e2547b5f720524b62fabeb96debc579697.1770299429.git.fmaurer@redhat.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent c01a6c7 commit 776b64b

2 files changed

Lines changed: 70 additions & 120 deletions

File tree

tools/testing/selftests/net/hsr/hsr_ping.sh

Lines changed: 69 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,34 @@ while getopts "$optstring" option;do
2727
esac
2828
done
2929

30-
do_complete_ping_test()
30+
do_ping_tests()
3131
{
32-
echo "INFO: Initial validation ping."
33-
# Each node has to be able each one.
34-
do_ping "$ns1" 100.64.0.2
35-
do_ping "$ns2" 100.64.0.1
36-
do_ping "$ns3" 100.64.0.1
37-
stop_if_error "Initial validation failed."
38-
39-
do_ping "$ns1" 100.64.0.3
40-
do_ping "$ns2" 100.64.0.3
41-
do_ping "$ns3" 100.64.0.2
32+
local netid="$1"
4233

43-
do_ping "$ns1" dead:beef:1::2
44-
do_ping "$ns1" dead:beef:1::3
45-
do_ping "$ns2" dead:beef:1::1
46-
do_ping "$ns2" dead:beef:1::2
47-
do_ping "$ns3" dead:beef:1::1
48-
do_ping "$ns3" dead:beef:1::2
34+
echo "INFO: Running ping tests."
4935

50-
stop_if_error "Initial validation failed."
36+
echo "INFO: Initial validation ping."
37+
# Each node has to be able to reach each one.
38+
do_ping "$ns1" "100.64.$netid.2"
39+
do_ping "$ns1" "100.64.$netid.3"
40+
do_ping "$ns2" "100.64.$netid.1"
41+
do_ping "$ns2" "100.64.$netid.3"
42+
do_ping "$ns3" "100.64.$netid.1"
43+
do_ping "$ns3" "100.64.$netid.2"
44+
stop_if_error "Initial validation failed on IPv4."
45+
46+
do_ping "$ns1" "dead:beef:$netid::2"
47+
do_ping "$ns1" "dead:beef:$netid::3"
48+
do_ping "$ns2" "dead:beef:$netid::1"
49+
do_ping "$ns2" "dead:beef:$netid::2"
50+
do_ping "$ns3" "dead:beef:$netid::1"
51+
do_ping "$ns3" "dead:beef:$netid::2"
52+
stop_if_error "Initial validation failed on IPv6."
5153

5254
# Wait until supervisor all supervision frames have been processed and the node
5355
# entries have been merged. Otherwise duplicate frames will be observed which is
5456
# valid at this stage.
57+
echo "INFO: Wait for node table entries to be merged."
5558
WAIT=5
5659
while [ ${WAIT} -gt 0 ]
5760
do
@@ -68,24 +71,28 @@ do_complete_ping_test()
6871
sleep 1
6972

7073
echo "INFO: Longer ping test."
71-
do_ping_long "$ns1" 100.64.0.2
72-
do_ping_long "$ns1" dead:beef:1::2
73-
do_ping_long "$ns1" 100.64.0.3
74-
do_ping_long "$ns1" dead:beef:1::3
75-
76-
stop_if_error "Longer ping test failed."
77-
78-
do_ping_long "$ns2" 100.64.0.1
79-
do_ping_long "$ns2" dead:beef:1::1
80-
do_ping_long "$ns2" 100.64.0.3
81-
do_ping_long "$ns2" dead:beef:1::2
82-
stop_if_error "Longer ping test failed."
74+
do_ping_long "$ns1" "100.64.$netid.2"
75+
do_ping_long "$ns1" "dead:beef:$netid::2"
76+
do_ping_long "$ns1" "100.64.$netid.3"
77+
do_ping_long "$ns1" "dead:beef:$netid::3"
78+
stop_if_error "Longer ping test failed (ns1)."
79+
80+
do_ping_long "$ns2" "100.64.$netid.1"
81+
do_ping_long "$ns2" "dead:beef:$netid::1"
82+
do_ping_long "$ns2" "100.64.$netid.3"
83+
do_ping_long "$ns2" "dead:beef:$netid::3"
84+
stop_if_error "Longer ping test failed (ns2)."
85+
86+
do_ping_long "$ns3" "100.64.$netid.1"
87+
do_ping_long "$ns3" "dead:beef:$netid::1"
88+
do_ping_long "$ns3" "100.64.$netid.2"
89+
do_ping_long "$ns3" "dead:beef:$netid::2"
90+
stop_if_error "Longer ping test failed (ns3)."
91+
}
8392

84-
do_ping_long "$ns3" 100.64.0.1
85-
do_ping_long "$ns3" dead:beef:1::1
86-
do_ping_long "$ns3" 100.64.0.2
87-
do_ping_long "$ns3" dead:beef:1::2
88-
stop_if_error "Longer ping test failed."
93+
do_link_problem_tests()
94+
{
95+
echo "INFO: Running link problem tests."
8996

9097
echo "INFO: Cutting one link."
9198
do_ping_long "$ns1" 100.64.0.3 &
@@ -104,26 +111,22 @@ do_complete_ping_test()
104111

105112
do_ping_long "$ns1" 100.64.0.2
106113
do_ping_long "$ns1" 100.64.0.3
107-
108-
stop_if_error "Failed with delay and packetloss."
114+
stop_if_error "Failed with delay and packetloss (ns1)."
109115

110116
do_ping_long "$ns2" 100.64.0.1
111117
do_ping_long "$ns2" 100.64.0.3
112-
113-
stop_if_error "Failed with delay and packetloss."
118+
stop_if_error "Failed with delay and packetloss (ns2)."
114119

115120
do_ping_long "$ns3" 100.64.0.1
116121
do_ping_long "$ns3" 100.64.0.2
117-
stop_if_error "Failed with delay and packetloss."
118-
119-
echo "INFO: All good."
122+
stop_if_error "Failed with delay and packetloss (ns3)."
120123
}
121124

122125
setup_hsr_interfaces()
123126
{
124127
local HSRv="$1"
125128

126-
echo "INFO: preparing interfaces for HSRv${HSRv}."
129+
echo "INFO: Preparing interfaces for HSRv${HSRv}."
127130
# Three HSR nodes. Each node has one link to each of its neighbour, two links in total.
128131
#
129132
# ns1eth1 ----- ns2eth1
@@ -140,17 +143,20 @@ setup_hsr_interfaces()
140143
ip link add ns3eth2 netns "$ns3" type veth peer name ns2eth2 netns "$ns2"
141144

142145
# HSRv0/1
143-
ip -net "$ns1" link add name hsr1 type hsr slave1 ns1eth1 slave2 ns1eth2 supervision 45 version $HSRv proto 0
144-
ip -net "$ns2" link add name hsr2 type hsr slave1 ns2eth1 slave2 ns2eth2 supervision 45 version $HSRv proto 0
145-
ip -net "$ns3" link add name hsr3 type hsr slave1 ns3eth1 slave2 ns3eth2 supervision 45 version $HSRv proto 0
146+
ip -net "$ns1" link add name hsr1 type hsr slave1 ns1eth1 \
147+
slave2 ns1eth2 supervision 45 version "$HSRv" proto 0
148+
ip -net "$ns2" link add name hsr2 type hsr slave1 ns2eth1 \
149+
slave2 ns2eth2 supervision 45 version "$HSRv" proto 0
150+
ip -net "$ns3" link add name hsr3 type hsr slave1 ns3eth1 \
151+
slave2 ns3eth2 supervision 45 version "$HSRv" proto 0
146152

147153
# IP for HSR
148154
ip -net "$ns1" addr add 100.64.0.1/24 dev hsr1
149-
ip -net "$ns1" addr add dead:beef:1::1/64 dev hsr1 nodad
155+
ip -net "$ns1" addr add dead:beef:0::1/64 dev hsr1 nodad
150156
ip -net "$ns2" addr add 100.64.0.2/24 dev hsr2
151-
ip -net "$ns2" addr add dead:beef:1::2/64 dev hsr2 nodad
157+
ip -net "$ns2" addr add dead:beef:0::2/64 dev hsr2 nodad
152158
ip -net "$ns3" addr add 100.64.0.3/24 dev hsr3
153-
ip -net "$ns3" addr add dead:beef:1::3/64 dev hsr3 nodad
159+
ip -net "$ns3" addr add dead:beef:0::3/64 dev hsr3 nodad
154160

155161
ip -net "$ns1" link set address 00:11:22:00:01:01 dev ns1eth1
156162
ip -net "$ns1" link set address 00:11:22:00:01:02 dev ns1eth2
@@ -177,113 +183,57 @@ setup_hsr_interfaces()
177183

178184
setup_vlan_interfaces() {
179185
ip -net "$ns1" link add link hsr1 name hsr1.2 type vlan id 2
180-
ip -net "$ns1" link add link hsr1 name hsr1.3 type vlan id 3
181-
ip -net "$ns1" link add link hsr1 name hsr1.4 type vlan id 4
182-
ip -net "$ns1" link add link hsr1 name hsr1.5 type vlan id 5
183-
184186
ip -net "$ns2" link add link hsr2 name hsr2.2 type vlan id 2
185-
ip -net "$ns2" link add link hsr2 name hsr2.3 type vlan id 3
186-
ip -net "$ns2" link add link hsr2 name hsr2.4 type vlan id 4
187-
ip -net "$ns2" link add link hsr2 name hsr2.5 type vlan id 5
188-
189187
ip -net "$ns3" link add link hsr3 name hsr3.2 type vlan id 2
190-
ip -net "$ns3" link add link hsr3 name hsr3.3 type vlan id 3
191-
ip -net "$ns3" link add link hsr3 name hsr3.4 type vlan id 4
192-
ip -net "$ns3" link add link hsr3 name hsr3.5 type vlan id 5
193188

194189
ip -net "$ns1" addr add 100.64.2.1/24 dev hsr1.2
195-
ip -net "$ns1" addr add 100.64.3.1/24 dev hsr1.3
196-
ip -net "$ns1" addr add 100.64.4.1/24 dev hsr1.4
197-
ip -net "$ns1" addr add 100.64.5.1/24 dev hsr1.5
190+
ip -net "$ns1" addr add dead:beef:2::1/64 dev hsr1.2 nodad
198191

199192
ip -net "$ns2" addr add 100.64.2.2/24 dev hsr2.2
200-
ip -net "$ns2" addr add 100.64.3.2/24 dev hsr2.3
201-
ip -net "$ns2" addr add 100.64.4.2/24 dev hsr2.4
202-
ip -net "$ns2" addr add 100.64.5.2/24 dev hsr2.5
193+
ip -net "$ns2" addr add dead:beef:2::2/64 dev hsr2.2 nodad
203194

204195
ip -net "$ns3" addr add 100.64.2.3/24 dev hsr3.2
205-
ip -net "$ns3" addr add 100.64.3.3/24 dev hsr3.3
206-
ip -net "$ns3" addr add 100.64.4.3/24 dev hsr3.4
207-
ip -net "$ns3" addr add 100.64.5.3/24 dev hsr3.5
196+
ip -net "$ns3" addr add dead:beef:2::3/64 dev hsr3.2 nodad
208197

209198
ip -net "$ns1" link set dev hsr1.2 up
210-
ip -net "$ns1" link set dev hsr1.3 up
211-
ip -net "$ns1" link set dev hsr1.4 up
212-
ip -net "$ns1" link set dev hsr1.5 up
213-
214199
ip -net "$ns2" link set dev hsr2.2 up
215-
ip -net "$ns2" link set dev hsr2.3 up
216-
ip -net "$ns2" link set dev hsr2.4 up
217-
ip -net "$ns2" link set dev hsr2.5 up
218-
219200
ip -net "$ns3" link set dev hsr3.2 up
220-
ip -net "$ns3" link set dev hsr3.3 up
221-
ip -net "$ns3" link set dev hsr3.4 up
222-
ip -net "$ns3" link set dev hsr3.5 up
223201

224202
}
225203

226-
hsr_vlan_ping() {
227-
do_ping "$ns1" 100.64.2.2
228-
do_ping "$ns1" 100.64.3.2
229-
do_ping "$ns1" 100.64.4.2
230-
do_ping "$ns1" 100.64.5.2
231-
232-
do_ping "$ns1" 100.64.2.3
233-
do_ping "$ns1" 100.64.3.3
234-
do_ping "$ns1" 100.64.4.3
235-
do_ping "$ns1" 100.64.5.3
236-
237-
do_ping "$ns2" 100.64.2.1
238-
do_ping "$ns2" 100.64.3.1
239-
do_ping "$ns2" 100.64.4.1
240-
do_ping "$ns2" 100.64.5.1
241-
242-
do_ping "$ns2" 100.64.2.3
243-
do_ping "$ns2" 100.64.3.3
244-
do_ping "$ns2" 100.64.4.3
245-
do_ping "$ns2" 100.64.5.3
246-
247-
do_ping "$ns3" 100.64.2.1
248-
do_ping "$ns3" 100.64.3.1
249-
do_ping "$ns3" 100.64.4.1
250-
do_ping "$ns3" 100.64.5.1
251-
252-
do_ping "$ns3" 100.64.2.2
253-
do_ping "$ns3" 100.64.3.2
254-
do_ping "$ns3" 100.64.4.2
255-
do_ping "$ns3" 100.64.5.2
204+
run_complete_ping_tests()
205+
{
206+
echo "INFO: Running complete ping tests."
207+
do_ping_tests 0
208+
do_link_problem_tests
256209
}
257210

258-
run_vlan_tests() {
211+
run_vlan_tests()
212+
{
259213
vlan_challenged_hsr1=$(ip net exec "$ns1" ethtool -k hsr1 | grep "vlan-challenged" | awk '{print $2}')
260214
vlan_challenged_hsr2=$(ip net exec "$ns2" ethtool -k hsr2 | grep "vlan-challenged" | awk '{print $2}')
261215
vlan_challenged_hsr3=$(ip net exec "$ns3" ethtool -k hsr3 | grep "vlan-challenged" | awk '{print $2}')
262216

263217
if [[ "$vlan_challenged_hsr1" = "off" || "$vlan_challenged_hsr2" = "off" || "$vlan_challenged_hsr3" = "off" ]]; then
264218
echo "INFO: Running VLAN tests"
265219
setup_vlan_interfaces
266-
hsr_vlan_ping
220+
do_ping_tests 2
267221
else
268222
echo "INFO: Not Running VLAN tests as the device does not support VLAN"
269223
fi
270224
}
271225

272226
check_prerequisites
273-
setup_ns ns1 ns2 ns3
274-
275227
trap cleanup_all_ns EXIT
276228

229+
setup_ns ns1 ns2 ns3
277230
setup_hsr_interfaces 0
278-
do_complete_ping_test
279-
231+
run_complete_ping_tests
280232
run_vlan_tests
281233

282234
setup_ns ns1 ns2 ns3
283-
284235
setup_hsr_interfaces 1
285-
do_complete_ping_test
286-
236+
run_complete_ping_tests
287237
run_vlan_tests
288238

289239
exit $ret
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
timeout=50
1+
timeout=90

0 commit comments

Comments
 (0)