Skip to content

Commit 555e553

Browse files
committed
selftests: net/forwarding: spawn sh inside vrf to speed up ping loop
Looking at timestamped output of netdev CI reveals that most of the time in forwarding tests for custom route hashing is spent on a single case, namely the test which uses ping (mausezahn does not support flow labels). On a non-debug kernel we spend 714 of 730 total test runtime (97%) on this test case. While having flow label support in a traffic gen tool / mausezahn would be best, we can significantly speed up the loop by putting ip vrf exec outside of the iteration. In a test of 1000 pings using a normal loop takes 50 seconds to finish. While using: ip vrf exec $vrf sh -c "$loop-body" takes 12 seconds (1/4 of the time). Some of the slowness is likely due to our inefficient virtualization setup, but even on my laptop running "ip link help" 16k times takes 25-30 seconds, so I think it's worth optimizing even for fastest setups. Reviewed-by: Ido Schimmel <[email protected]> Tested-by: Ido Schimmel <[email protected]> Reviewed-by: Hangbin Liu <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7976538 commit 555e553

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

tools/testing/selftests/net/forwarding/custom_multipath_hash.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,10 @@ send_dst_ipv6()
224224
send_flowlabel()
225225
{
226226
# Generate 16384 echo requests, each with a random flow label.
227-
for _ in $(seq 1 16384); do
228-
ip vrf exec v$h1 \
229-
$PING6 2001:db8:4::2 -F 0 -c 1 -q >/dev/null 2>&1
230-
done
227+
ip vrf exec v$h1 sh -c \
228+
"for _ in {1..16384}; do \
229+
$PING6 2001:db8:4::2 -F 0 -c 1 -q >/dev/null 2>&1; \
230+
done"
231231
}
232232

233233
send_src_udp6()

tools/testing/selftests/net/forwarding/gre_custom_multipath_hash.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,10 @@ send_dst_ipv6()
319319
send_flowlabel()
320320
{
321321
# Generate 16384 echo requests, each with a random flow label.
322-
for _ in $(seq 1 16384); do
323-
ip vrf exec v$h1 \
324-
$PING6 2001:db8:2::2 -F 0 -c 1 -q >/dev/null 2>&1
325-
done
322+
ip vrf exec v$h1 sh -c \
323+
"for _ in {1..16384}; do \
324+
$PING6 2001:db8:2::2 -F 0 -c 1 -q >/dev/null 2>&1; \
325+
done"
326326
}
327327

328328
send_src_udp6()

tools/testing/selftests/net/forwarding/ip6gre_custom_multipath_hash.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,10 @@ send_dst_ipv6()
321321
send_flowlabel()
322322
{
323323
# Generate 16384 echo requests, each with a random flow label.
324-
for _ in $(seq 1 16384); do
325-
ip vrf exec v$h1 \
326-
$PING6 2001:db8:2::2 -F 0 -c 1 -q >/dev/null 2>&1
327-
done
324+
ip vrf exec v$h1 sh -c \
325+
"for _ in {1..16384}; do \
326+
$PING6 2001:db8:2::2 -F 0 -c 1 -q >/dev/null 2>&1; \
327+
done"
328328
}
329329

330330
send_src_udp6()

0 commit comments

Comments
 (0)