Commit 5f147476 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'selftests-pmtu-sh-fix-cleanup-of-processes-launched-in-subshell'

Guillaume Nault says:

====================
selftests: pmtu.sh: Fix cleanup of processes launched in subshell.

Depending on the options used, pmtu.sh may launch tcpdump and nettest
processes in the background. However it fails to clean them up after
the tests complete.

Patch 1 allows the cleanup() function to read the list of PIDs launched
by the tests.
Patch 2 fixes the way the nettest PIDs are retrieved.
====================

Link: https://lore.kernel.org/r/cover.1646776561.git.gnault@redhat.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents f80cfe2f 94a4a4fe
......@@ -374,6 +374,16 @@ run_cmd() {
return $rc
}
run_cmd_bg() {
cmd="$*"
if [ "$VERBOSE" = "1" ]; then
printf " COMMAND: %s &\n" "${cmd}"
fi
$cmd 2>&1 &
}
# Find the auto-generated name for this namespace
nsname() {
eval echo \$NS_$1
......@@ -670,10 +680,10 @@ setup_nettest_xfrm() {
[ ${1} -eq 6 ] && proto="-6" || proto=""
port=${2}
run_cmd ${ns_a} nettest ${proto} -q -D -s -x -p ${port} -t 5 &
run_cmd_bg "${ns_a}" nettest "${proto}" -q -D -s -x -p "${port}" -t 5
nettest_pids="${nettest_pids} $!"
run_cmd ${ns_b} nettest ${proto} -q -D -s -x -p ${port} -t 5 &
run_cmd_bg "${ns_b}" nettest "${proto}" -q -D -s -x -p "${port}" -t 5
nettest_pids="${nettest_pids} $!"
}
......@@ -865,7 +875,6 @@ setup_ovs_bridge() {
setup() {
[ "$(id -u)" -ne 0 ] && echo " need to run as root" && return $ksft_skip
cleanup
for arg do
eval setup_${arg} || { echo " ${arg} not supported"; return 1; }
done
......@@ -876,7 +885,7 @@ trace() {
for arg do
[ "${ns_cmd}" = "" ] && ns_cmd="${arg}" && continue
${ns_cmd} tcpdump -s 0 -i "${arg}" -w "${name}_${arg}.pcap" 2> /dev/null &
${ns_cmd} tcpdump --immediate-mode -s 0 -i "${arg}" -w "${name}_${arg}.pcap" 2> /dev/null &
tcpdump_pids="${tcpdump_pids} $!"
ns_cmd=
done
......@@ -1836,6 +1845,10 @@ run_test() {
unset IFS
# Since cleanup() relies on variables modified by this subshell, it
# has to run in this context.
trap cleanup EXIT
if [ "$VERBOSE" = "1" ]; then
printf "\n##########################################################################\n\n"
fi
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment