Unverified Commit d4893cbf authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!13251 MPTCP Upstream part 21

Merge Pull Request from: @geliangtang 
 
Patches from v6.9-rc1. 
 
Link:https://gitee.com/openeuler/kernel/pulls/13251

 

Reviewed-by: default avatarYue Haibing <yuehaibing@huawei.com>
Signed-off-by: default avatarZhang Peng <zhangpeng362@huawei.com>
parents 858ff3fe bf715c40
Loading
Loading
Loading
Loading
+14 −21
Original line number Diff line number Diff line
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0

# Double quotes to prevent globbing and word splitting is recommended in new
# code but we accept it, especially because there were too many before having
# address all other issues detected by shellcheck.
#shellcheck disable=SC2086

. "$(dirname "${0}")/mptcp_lib.sh"

sec=$(date +%s)
rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
ns="ns1-$rndh"
ksft_skip=4
ns=""
test_cnt=1
timeout_poll=30
timeout_test=$((timeout_poll * 2 + 1))
@@ -26,25 +28,17 @@ flush_pids()
	done
}

# This function is used in the cleanup trap
#shellcheck disable=SC2317
cleanup()
{
	ip netns pids "${ns}" | xargs --no-run-if-empty kill -SIGKILL &>/dev/null

	ip netns del $ns
	mptcp_lib_ns_exit "${ns}"
}

mptcp_lib_check_mptcp

ip -Version > /dev/null 2>&1
if [ $? -ne 0 ];then
	echo "SKIP: Could not run test without ip tool"
	exit $ksft_skip
fi
ss -h | grep -q MPTCP
if [ $? -ne 0 ];then
	echo "SKIP: ss tool does not support MPTCP"
	exit $ksft_skip
fi
mptcp_lib_check_tools ip ss

get_msk_inuse()
{
@@ -186,7 +180,7 @@ chk_msk_inuse()
	expected=$((expected + listen_nr))

	for _ in $(seq 10); do
		if [ $(get_msk_inuse) -eq $expected ];then
		if [ "$(get_msk_inuse)" -eq $expected ]; then
			break
		fi
		sleep 0.1
@@ -224,8 +218,7 @@ wait_connected()
}

trap cleanup EXIT
ip netns add $ns
ip -n $ns link set dev lo up
mptcp_lib_ns_init ns

echo "a" | \
	timeout ${timeout_test} \
@@ -273,7 +266,7 @@ chk_msk_inuse 0 "1->0"
chk_msk_cestab 0 "1->0"

NR_CLIENTS=100
for I in `seq 1 $NR_CLIENTS`; do
for I in $(seq 1 $NR_CLIENTS); do
	echo "a" | \
		timeout ${timeout_test} \
			ip netns exec $ns \
@@ -282,7 +275,7 @@ for I in `seq 1 $NR_CLIENTS`; do
done
mptcp_lib_wait_local_port_listen $ns $((NR_CLIENTS + 10001))

for I in `seq 1 $NR_CLIENTS`; do
for I in $(seq 1 $NR_CLIENTS); do
	echo "b" | \
		timeout ${timeout_test} \
			ip netns exec $ns \
+11 −24
Original line number Diff line number Diff line
@@ -125,12 +125,10 @@ while getopts "$optstring" option;do
	esac
done

sec=$(date +%s)
rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
ns1="ns1-$rndh"
ns2="ns2-$rndh"
ns3="ns3-$rndh"
ns4="ns4-$rndh"
ns1=""
ns2=""
ns3=""
ns4=""

TEST_COUNT=0
TEST_GROUP=""
@@ -144,21 +142,12 @@ cleanup()
	rm -f "$sin" "$sout"
	rm -f "$capout"

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

mptcp_lib_check_mptcp
mptcp_lib_check_kallsyms

ip -Version > /dev/null 2>&1
if [ $? -ne 0 ];then
	echo "SKIP: Could not run test without ip tool"
	exit $ksft_skip
fi
mptcp_lib_check_tools ip

sin=$(mktemp)
sout=$(mktemp)
@@ -169,10 +158,7 @@ cin_disconnect="$cin".disconnect
cout_disconnect="$cout".disconnect
trap cleanup EXIT

for i in "$ns1" "$ns2" "$ns3" "$ns4";do
	ip netns add $i || exit $ksft_skip
	ip -net $i link set lo up
done
mptcp_lib_ns_init ns1 ns2 ns3 ns4

#  "$ns1"              ns2                    ns3                     ns4
# ns1eth2    ns2eth1   ns2eth3      ns3eth2   ns3eth4       ns4eth3
@@ -263,8 +249,8 @@ fi

check_mptcp_disabled()
{
	local disabled_ns="ns_disabled-$rndh"
	ip netns add ${disabled_ns} || exit $ksft_skip
	local disabled_ns
	mptcp_lib_ns_init disabled_ns

	# net.mptcp.enabled should be enabled by default
	if [ "$(ip netns exec ${disabled_ns} sysctl net.mptcp.enabled | awk '{ print $3 }')" -ne 1 ]; then
@@ -278,7 +264,7 @@ 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
	ip netns delete ${disabled_ns}
	mptcp_lib_ns_exit "${disabled_ns}"

	if [ ${err} -eq 0 ]; then
		echo -e "New MPTCP socket cannot be blocked via sysctl\t\t[ FAIL ]"
@@ -360,6 +346,7 @@ do_transfer()

	if $capture; then
		local capuser
		local rndh="${connector_ns:4}"
		if [ -z $SUDO_USER ] ; then
			capuser=""
		else
+9 −51
Original line number Diff line number Diff line
@@ -86,21 +86,11 @@ init_partial()
{
	capout=$(mktemp)

	local sec rndh
	sec=$(date +%s)
	rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)

	ns1="ns1-$rndh"
	ns2="ns2-$rndh"
	mptcp_lib_ns_init ns1 ns2

	local netns
	for netns in "$ns1" "$ns2"; do
		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.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
@@ -145,45 +135,15 @@ cleanup_partial()
{
	rm -f "$capout"

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

check_tools()
{
	mptcp_lib_check_mptcp
	mptcp_lib_check_kallsyms

	if ! ip -Version &> /dev/null; then
		echo "SKIP: Could not run test without ip tool"
		exit $ksft_skip
	fi

	if ! ss -h | grep -q MPTCP; then
		echo "SKIP: ss tool does not support MPTCP"
		exit $ksft_skip
	fi

	# Use the legacy version if available to support old kernel versions
	if iptables-legacy -V &> /dev/null; then
		iptables="iptables-legacy"
		ip6tables="ip6tables-legacy"
	elif ! iptables -V &> /dev/null; then
		echo "SKIP: Could not run all tests without iptables tool"
		exit $ksft_skip
	elif ! ip6tables -V &> /dev/null; then
		echo "SKIP: Could not run all tests without ip6tables tool"
		exit $ksft_skip
	fi
	mptcp_lib_ns_exit "${ns1}" "${ns2}"
}

init() {
	init=1

	check_tools
	mptcp_lib_check_mptcp
	mptcp_lib_check_kallsyms
	mptcp_lib_check_tools ip ss "${iptables}" "${ip6tables}"

	sin=$(mktemp)
	sout=$(mktemp)
@@ -470,12 +430,8 @@ reset_with_events()
{
	reset "${1}" || return 1

	:> "$evts_ns1"
	:> "$evts_ns2"
	ip netns exec $ns1 ./pm_nl_ctl events >> "$evts_ns1" 2>&1 &
	evts_ns1_pid=$!
	ip netns exec $ns2 ./pm_nl_ctl events >> "$evts_ns2" 2>&1 &
	evts_ns2_pid=$!
	mptcp_lib_events "${ns1}" "${evts_ns1}" evts_ns1_pid
	mptcp_lib_events "${ns2}" "${evts_ns2}" evts_ns2_pid
}

reset_with_tcp_filter()
@@ -649,7 +605,9 @@ wait_mpj()
kill_events_pids()
{
	mptcp_lib_kill_wait $evts_ns1_pid
	evts_ns1_pid=0
	mptcp_lib_kill_wait $evts_ns2_pid
	evts_ns2_pid=0
}

pm_nl_set_limits()
+68 −0
Original line number Diff line number Diff line
@@ -353,3 +353,71 @@ mptcp_lib_check_output() {
		return 1
	fi
}

mptcp_lib_check_tools() {
	local tool

	for tool in "${@}"; do
		case "${tool}" in
		"ip")
			if ! ip -Version &> /dev/null; then
				mptcp_lib_print_warn "SKIP: Could not run test without ip tool"
				exit ${KSFT_SKIP}
			fi
			;;
		"ss")
			if ! ss -h | grep -q MPTCP; then
				mptcp_lib_print_warn "SKIP: ss tool does not support MPTCP"
				exit ${KSFT_SKIP}
			fi
			;;
		"iptables"* | "ip6tables"*)
			if ! "${tool}" -V &> /dev/null; then
				mptcp_lib_print_warn "SKIP: Could not run all tests without ${tool}"
				exit ${KSFT_SKIP}
			fi
			;;
		*)
			mptcp_lib_print_err "Internal error: unsupported tool: ${tool}"
			exit ${KSFT_FAIL}
			;;
		esac
	done
}
mptcp_lib_ns_init() {
	local sec rndh

	sec=$(date +%s)
	rndh=$(printf %x "${sec}")-$(mktemp -u XXXXXX)

	local netns
	for netns in "${@}"; do
		eval "${netns}=${netns}-${rndh}"

		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
}

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}"
	declare -n pid="${3}"

	:>"${evts}"

	mptcp_lib_kill_wait "${pid:-0}"
	ip netns exec "${ns}" ./pm_nl_ctl events >> "${evts}" 2>&1 &
	pid=$!
}
+16 −39
Original line number Diff line number Diff line
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0

# Double quotes to prevent globbing and word splitting is recommended in new
# code but we accept it, especially because there were too many before having
# address all other issues detected by shellcheck.
#shellcheck disable=SC2086

. "$(dirname "${0}")/mptcp_lib.sh"

ret=0
@@ -8,17 +13,14 @@ sin=""
sout=""
cin=""
cout=""
ksft_skip=4
timeout_poll=30
timeout_test=$((timeout_poll * 2 + 1))
iptables="iptables"
ip6tables="ip6tables"

sec=$(date +%s)
rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
ns1="ns1-$rndh"
ns2="ns2-$rndh"
ns_sbox="ns_sbox-$rndh"
ns1=""
ns2=""
ns_sbox=""

add_mark_rules()
{
@@ -40,17 +42,10 @@ add_mark_rules()

init()
{
	local netns
	for netns in "$ns1" "$ns2" "$ns_sbox";do
		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
	mptcp_lib_ns_init ns1 ns2 ns_sbox

	local i
	for i in `seq 1 4`; do
	for i in $(seq 1 4); do
		ip link add ns1eth$i netns "$ns1" type veth peer name ns2eth$i netns "$ns2"
		ip -net "$ns1" addr add 10.0.$i.1/24 dev ns1eth$i
		ip -net "$ns1" addr add dead:beef:$i::1/64 dev ns1eth$i nodad
@@ -77,36 +72,18 @@ init()
	add_mark_rules $ns2 2
}

# This function is used in the cleanup trap
#shellcheck disable=SC2317
cleanup()
{
	local netns
	for netns in "$ns1" "$ns2" "$ns_sbox"; do
		ip netns del $netns
	done
	mptcp_lib_ns_exit "${ns1}" "${ns2}" "${ns_sbox}"
	rm -f "$cin" "$cout"
	rm -f "$sin" "$sout"
}

mptcp_lib_check_mptcp
mptcp_lib_check_kallsyms

ip -Version > /dev/null 2>&1
if [ $? -ne 0 ];then
	echo "SKIP: Could not run test without ip tool"
	exit $ksft_skip
fi

# Use the legacy version if available to support old kernel versions
if iptables-legacy -V &> /dev/null; then
	iptables="iptables-legacy"
	ip6tables="ip6tables-legacy"
elif ! iptables -V &> /dev/null; then
	echo "SKIP: Could not run all tests without iptables tool"
	exit $ksft_skip
elif ! ip6tables -V &> /dev/null; then
	echo "SKIP: Could not run all tests without ip6tables tool"
	exit $ksft_skip
fi
mptcp_lib_check_tools ip "${iptables}" "${ip6tables}"

check_mark()
{
@@ -286,12 +263,12 @@ do_tcpinq_test()
	local lret=$?
	if [ $lret -ne 0 ];then
		ret=$lret
		echo "FAIL: mptcp_inq $@" 1>&2
		echo "FAIL: mptcp_inq $*" 1>&2
		mptcp_lib_result_fail "TCP_INQ: $*"
		return $lret
	fi

	echo "PASS: TCP_INQ cmsg/ioctl $@"
	echo "PASS: TCP_INQ cmsg/ioctl $*"
	mptcp_lib_result_pass "TCP_INQ: $*"
	return $lret
}
Loading