Commit bf715c40 authored by Matthieu Baerts (NGI0)'s avatar Matthieu Baerts (NGI0) Committed by Geliang Tang
Browse files

selftests: userspace pm: avoid relaunching pm events

mainline inclusion
from mainline-v6.9-rc1
commit c66fb480a3302577f657a5d4f5308312bf1b52f8
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I9VYQ9
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=c66fb480a3302577f657a5d4f5308312bf1b52f8



--------------------------------

'make_connection' is launched twice: once for IPv4, once for IPv6.

But then, the "pm_nl_ctl events" was launched a first time, killed, then
relaunched after for no particular reason.

We can then move this code, and the generation of the temp file to
exchange, to the init part, and remove extra conditions that no longer
needed.

Reviewed-by: default avatarMat Martineau <martineau@kernel.org>
Signed-off-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://lore.kernel.org/r/20240306-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v2-12-bc79e6e5e6a0@kernel.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Reviewed-by: default avatarJackie Liu <liuyun01@kylinos.cn>
Signed-off-by: default avatarGeliang Tang <tanggeliang@kylinos.cn>
parent 4365f716
Loading
Loading
Loading
Loading
+13 −16
Original line number Diff line number Diff line
@@ -149,17 +149,23 @@ ip -net "$ns2" addr add dead:beef:1::2/64 dev ns2eth1 nodad
ip -net "$ns2" addr add dead:beef:2::2/64 dev ns2eth1 nodad
ip -net "$ns2" link set ns2eth1 up

file=$(mktemp)
mptcp_lib_make_file "$file" 2 1

# Capture netlink events over the two network namespaces running
# the MPTCP client and server
client_evts=$(mktemp)
mptcp_lib_events "${ns2}" "${client_evts}" client_evts_pid
server_evts=$(mktemp)
mptcp_lib_events "${ns1}" "${server_evts}" server_evts_pid
sleep 0.5

print_title "Init"
print_test "Created network namespaces ns1, ns2"
test_pass

make_connection()
{
	if [ -z "$file" ]; then
		file=$(mktemp)
	fi
	mptcp_lib_make_file "$file" 2 1

	local is_v6=$1
	local app_port=$app4_port
	local connect_addr="10.0.1.1"
@@ -175,17 +181,8 @@ make_connection()
		is_v6="v4"
	fi

	# Capture netlink events over the two network namespaces running
	# the MPTCP client and server
	if [ -z "$client_evts" ]; then
		client_evts=$(mktemp)
	fi
	mptcp_lib_events "${ns2}" "${client_evts}" client_evts_pid
	if [ -z "$server_evts" ]; then
		server_evts=$(mktemp)
	fi
	mptcp_lib_events "${ns1}" "${server_evts}" server_evts_pid
	sleep 0.5
	:>"$client_evts"
	:>"$server_evts"

	# Run the server
	ip netns exec "$ns1" \