Skip to content

Commit 8908c3c

Browse files
fmaurer-rhPaolo Abeni
authored andcommitted
selftests: hsr: Add tests for more link faults with PRP
Add tests where one link has different rates of packet loss or reorders packets. PRP should still be able to recover from these link faults and show no packet loss. However, it is acceptable to receive some level of duplicate packets. This matches the current specification (IEC 62439-3:2021) of the duplicate discard algorithm that requires it to be "designed such that it never rejects a legitimate frame, while occasional acceptance of a duplicate can be tolerated." The rate of acceptable duplicates in this test is intentionally high (10%) to make the test stable, the values I observed in the worst test cases (20% loss) are around 5% duplicates. The duplicates occur because of the 10ms ping interval in the test. As blocks expire after 400ms based on the timestamp of the first received sequence number in the block, every approx. 40th will lead to a new, clean block being used where the sequence number hasn't been seen before. As this occurs on both nodes in the test (for requests and replies), we observe around 20 duplicate frames. Signed-off-by: Felix Maurer <fmaurer@redhat.com> Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Link: https://patch.msgid.link/7b36506d3a80e53786fe56526cf6046c74dfeee1.1770299429.git.fmaurer@redhat.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 415e636 commit 8908c3c

1 file changed

Lines changed: 74 additions & 5 deletions

File tree

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

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ ALL_TESTS="
1111
test_cut_link_hsrv1
1212
test_clean_prp
1313
test_cut_link_prp
14+
test_packet_loss_prp
15+
test_high_packet_loss_prp
16+
test_reordering_prp
1417
"
1518

16-
# The tests are running ping for 5sec with a relatively short interval with a
17-
# cut link, which should be recoverable by HSR/PRP.
19+
# The tests are running ping for 5sec with a relatively short interval in
20+
# different scenarios with faulty links (cut links, packet loss, delay,
21+
# reordering) that should be recoverable by HSR/PRP. The ping interval (10ms)
22+
# is short enough that the base delay (50ms) leads to a queue in the netem
23+
# qdiscs which is needed for reordering.
1824

1925
setup_hsr_topo()
2026
{
@@ -160,6 +166,7 @@ check_ping()
160166
{
161167
local node="$1"
162168
local dst="$2"
169+
local accepted_dups="$3"
163170
local ping_args="-q -i 0.01 -c 400"
164171

165172
log_info "Running ping $node -> $dst"
@@ -178,7 +185,9 @@ check_ping()
178185
loss="${BASH_REMATCH[1]}"
179186
fi
180187

181-
check_err "$dups" "Unexpected duplicate packets (${dups})"
188+
if [ "$dups" -gt "$accepted_dups" ]; then
189+
check_err 1 "Unexpected duplicate packets (${dups})"
190+
fi
182191
if [ "$loss" != "0%" ]; then
183192
check_err 1 "Unexpected packet loss (${loss})"
184193
fi
@@ -197,7 +206,7 @@ test_clean()
197206
return
198207
fi
199208

200-
check_ping "$node1" "100.64.0.2"
209+
check_ping "$node1" "100.64.0.2" 0
201210

202211
log_test "${tname}"
203212
}
@@ -237,7 +246,7 @@ test_cut_link()
237246
log_info "Cutting link"
238247
ip -net "$node1" link set vethB down
239248
) &
240-
check_ping "$node1" "100.64.0.2"
249+
check_ping "$node1" "100.64.0.2" 0
241250

242251
wait
243252
log_test "${tname}"
@@ -259,6 +268,66 @@ test_cut_link_prp()
259268
test_cut_link "PRP"
260269
}
261270

271+
test_packet_loss()
272+
{
273+
local proto="$1"
274+
local loss="$2"
275+
276+
RET=0
277+
tname="${FUNCNAME[0]} - ${proto}, ${loss}"
278+
279+
setup_topo "$proto"
280+
if ((RET != ksft_pass)); then
281+
log_test "${tname} setup"
282+
return
283+
fi
284+
285+
# Packet loss with lower delay makes sure the packets on the lossy link
286+
# arrive first.
287+
tc -net "$node1" qdisc add dev vethA root netem delay 50ms
288+
tc -net "$node1" qdisc add dev vethB root netem delay 20ms loss "$loss"
289+
290+
check_ping "$node1" "100.64.0.2" 40
291+
292+
log_test "${tname}"
293+
}
294+
295+
test_packet_loss_prp()
296+
{
297+
test_packet_loss "PRP" "20%"
298+
}
299+
300+
test_high_packet_loss_prp()
301+
{
302+
test_packet_loss "PRP" "80%"
303+
}
304+
305+
test_reordering()
306+
{
307+
local proto="$1"
308+
309+
RET=0
310+
tname="${FUNCNAME[0]} - ${proto}"
311+
312+
setup_topo "$proto"
313+
if ((RET != ksft_pass)); then
314+
log_test "${tname} setup"
315+
return
316+
fi
317+
318+
tc -net "$node1" qdisc add dev vethA root netem delay 50ms
319+
tc -net "$node1" qdisc add dev vethB root netem delay 50ms reorder 20%
320+
321+
check_ping "$node1" "100.64.0.2" 40
322+
323+
log_test "${tname}"
324+
}
325+
326+
test_reordering_prp()
327+
{
328+
test_reordering "PRP"
329+
}
330+
262331
cleanup()
263332
{
264333
cleanup_all_ns

0 commit comments

Comments
 (0)