Commit cfe85a26 authored by Geliang Tang's avatar Geliang Tang
Browse files

selftests: mptcp: more operations in ns_init/exit

mainline inclusion
from mainline-v6.9-rc1
commit df8d3ba55b4fa1d6aed8449971ee50757cb0732f
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=df8d3ba55b4fa1d6aed8449971ee50757cb0732f



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

Set more the default sysctl values in mptcp_lib_ns_init(). It is fine to
do that everywhere, because they could be overridden latter if needed.

mptcp_lib_ns_exit() now also try to remove temp netns files used for the
stats even for selftests not using them. That's fine to do that because
these files have a unique name.

Signed-off-by: default avatarGeliang Tang <tanggeliang@kylinos.cn>
Reviewed-by: default avatarMatthieu Baerts (NGI0) <matttbe@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-5-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 2db40725
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -142,10 +142,6 @@ cleanup()
	rm -f "$sin" "$sout"
	rm -f "$capout"

	local netns
	for netns in "$ns1" "$ns2" "$ns3" "$ns4";do
		rm -f /tmp/$netns.{nstat,out}
	done
	mptcp_lib_ns_exit "${ns1}" "${ns2}" "${ns3}" "${ns4}"
}

+0 −7
Original line number Diff line number Diff line
@@ -90,10 +90,7 @@ init_partial()

	local netns
	for netns in "$ns1" "$ns2"; do
		ip netns exec $netns sysctl -q net.mptcp.enabled=1
		ip netns exec $netns sysctl -q net.mptcp.pm_type=0 2>/dev/null || true
		ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0
		ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0
		if $checksum; then
			ip netns exec $netns sysctl -q net.mptcp.checksum_enabled=1
		fi
@@ -138,10 +135,6 @@ cleanup_partial()
{
	rm -f "$capout"

	local netns
	for netns in "$ns1" "$ns2"; do
		rm -f /tmp/$netns.{nstat,out}
	done
	mptcp_lib_ns_exit "${ns1}" "${ns2}"
}

+4 −0
Original line number Diff line number Diff line
@@ -396,6 +396,9 @@ mptcp_lib_ns_init() {

		ip netns add "${!netns}" || exit ${KSFT_SKIP}
		ip -net "${!netns}" link set lo up
		ip netns exec "${!netns}" sysctl -q net.mptcp.enabled=1
		ip netns exec "${!netns}" sysctl -q net.ipv4.conf.all.rp_filter=0
		ip netns exec "${!netns}" sysctl -q net.ipv4.conf.default.rp_filter=0
	done
}

@@ -403,5 +406,6 @@ mptcp_lib_ns_exit() {
	local netns
	for netns in "${@}"; do
		ip netns del "${netns}"
		rm -f /tmp/"${netns}".{nstat,out}
	done
}
+0 −7
Original line number Diff line number Diff line
@@ -40,13 +40,6 @@ init()
{
	mptcp_lib_ns_init ns1 ns2 ns_sbox

	local netns
	for netns in "$ns1" "$ns2" "$ns_sbox";do
		ip netns exec $netns sysctl -q net.mptcp.enabled=1
		ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0
		ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0
	done

	local i
	for i in `seq 1 4`; do
		ip link add ns1eth$i netns "$ns1" type veth peer name ns2eth$i netns "$ns2"
+0 −1
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ mptcp_lib_check_tools ip
trap cleanup EXIT

mptcp_lib_ns_init ns1
ip netns exec $ns1 sysctl -q net.mptcp.enabled=1

check()
{
Loading