Skip to content

Commit

Permalink
selftests: mptcp: use cleanup_all_ns helper in lib.sh
Browse files Browse the repository at this point in the history
This patch uses cleanup_all_ns() helper defined in lib.sh instead of
all mptcp_lib_ns_exit() in mptcp seltests. And drop this duplicate
mptcp helper in mptcp_lib.sh.

In mptcp_connect.sh, drop mptcp_lib_ns_exit in check_mptcp_disabled()
directly, this "disabled_ns" will be deleted by cleanup_all_ns() in
cleanup(), together with "ns1 - ns4".

In mptcp_join.sh, drop mptcp_lib_ns_exit in cleanup_partial() directly,
each existing namespace will delete automaticly in setup_ns(), only
adding cleanup_all_ns in cleanup() is enough.

Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
Geliang Tang authored and intel-lab-lkp committed May 23, 2024
1 parent 5bf6df5 commit fbb77c3
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 17 deletions.
2 changes: 1 addition & 1 deletion tools/testing/selftests/net/mptcp/diag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ cleanup()
{
ip netns pids "${ns1}" | xargs --no-run-if-empty kill -SIGKILL &>/dev/null

mptcp_lib_ns_exit "${ns1}"
cleanup_all_ns
}

mptcp_lib_check_mptcp
Expand Down
3 changes: 1 addition & 2 deletions tools/testing/selftests/net/mptcp/mptcp_connect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ cleanup()
rm -f "$sin" "$sout"
rm -f "$capout"

mptcp_lib_ns_exit "${ns1}" "${ns2}" "${ns3}" "${ns4}"
cleanup_all_ns
}

mptcp_lib_check_mptcp
Expand Down Expand Up @@ -271,7 +271,6 @@ check_mptcp_disabled()
local err=0
LC_ALL=C ip netns exec ${disabled_ns} ./mptcp_connect -p 10000 -s MPTCP 127.0.0.1 < "$cin" 2>&1 | \
grep -q "^socket: Protocol not available$" && err=1
mptcp_lib_ns_exit "${disabled_ns}"

if [ ${err} -eq 0 ]; then
mptcp_lib_pr_fail "New MPTCP socket cannot be blocked via sysctl"
Expand Down
3 changes: 1 addition & 2 deletions tools/testing/selftests/net/mptcp/mptcp_join.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ init_shapers()
cleanup_partial()
{
rm -f "$capout"

mptcp_lib_ns_exit "${ns1}" "${ns2}"
}

init() {
Expand Down Expand Up @@ -166,6 +164,7 @@ cleanup()
rm -rf $evts_ns1 $evts_ns2
rm -f "$err"
cleanup_partial
cleanup_all_ns
}

print_check()
Expand Down
8 changes: 0 additions & 8 deletions tools/testing/selftests/net/mptcp/mptcp_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -424,14 +424,6 @@ mptcp_lib_ns_init() {
done
}

mptcp_lib_ns_exit() {
local netns
for netns in "${@}"; do
ip netns del "${netns}"
rm -f /tmp/"${netns}".{nstat,out}
done
}

mptcp_lib_events() {
local ns="${1}"
local evts="${2}"
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ init()
#shellcheck disable=SC2317
cleanup()
{
mptcp_lib_ns_exit "${ns1}" "${ns2}" "${ns_sbox}"
cleanup_all_ns
rm -f "$cin" "$cout"
rm -f "$sin" "$sout"
}
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/net/mptcp/pm_netlink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ err=$(mktemp)
cleanup()
{
rm -f "${err}"
mptcp_lib_ns_exit "${ns1}"
cleanup_all_ns
}

mptcp_lib_check_mptcp
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/net/mptcp/simult_flows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ cleanup()
rm -f "$large" "$small"
rm -f "$capout"

mptcp_lib_ns_exit "${ns1}" "${ns2}" "${ns3}"
cleanup_all_ns
}

mptcp_lib_check_mptcp
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/net/mptcp/userspace_pm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ cleanup()
mptcp_lib_kill_wait $pid
done

mptcp_lib_ns_exit "${ns1}" "${ns2}"
cleanup_all_ns

rm -rf $file $client_evts $server_evts

Expand Down

0 comments on commit fbb77c3

Please sign in to comment.