Skip to content

Commit dfd04b2

Browse files
Guillaume Naultgregkh
authored andcommitted
selftests: pmtu.sh: Kill nettest processes launched in subshell.
[ Upstream commit 94a4a4f ] When using "run_cmd <command> &", then "$!" refers to the PID of the subshell used to run <command>, not the command itself. Therefore nettest_pids actually doesn't contain the list of the nettest commands running in the background. So cleanup() can't kill them and the nettest processes run until completion (fortunately they have a 5s timeout). Fix this by defining a new command for running processes in the background, for which "$!" really refers to the PID of the command run. Also, double quote variables on the modified lines, to avoid shellcheck warnings. Fixes: ece1278 ("selftests: net: add ESP-in-UDP PMTU test") Signed-off-by: Guillaume Nault <gnault@redhat.com> Reviewed-by: Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 8b3d2fd commit dfd04b2

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

‎tools/testing/selftests/net/pmtu.sh‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,16 @@ run_cmd() {
374374
return $rc
375375
}
376376

377+
run_cmd_bg() {
378+
cmd="$*"
379+
380+
if [ "$VERBOSE" = "1" ]; then
381+
printf " COMMAND: %s &\n" "${cmd}"
382+
fi
383+
384+
$cmd 2>&1 &
385+
}
386+
377387
# Find the auto-generated name for this namespace
378388
nsname() {
379389
eval echo \$NS_$1
@@ -670,10 +680,10 @@ setup_nettest_xfrm() {
670680
[ ${1} -eq 6 ] && proto="-6" || proto=""
671681
port=${2}
672682

673-
run_cmd ${ns_a} nettest ${proto} -q -D -s -x -p ${port} -t 5 &
683+
run_cmd_bg "${ns_a}" nettest "${proto}" -q -D -s -x -p "${port}" -t 5
674684
nettest_pids="${nettest_pids} $!"
675685

676-
run_cmd ${ns_b} nettest ${proto} -q -D -s -x -p ${port} -t 5 &
686+
run_cmd_bg "${ns_b}" nettest "${proto}" -q -D -s -x -p "${port}" -t 5
677687
nettest_pids="${nettest_pids} $!"
678688
}
679689

0 commit comments

Comments
 (0)