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

!9861 MPTCP Upstream part 13

Merge Pull Request from: @geliangtang 
 
Two BPF patches used by MPTCP BPF selftests.
Two MPTCP selftests fixes. 
 
Link:https://gitee.com/openeuler/kernel/pulls/9861

 

Reviewed-by: default avatarYue Haibing <yuehaibing@huawei.com>
Signed-off-by: default avatarZhang Peng <zhangpeng362@huawei.com>
parents 6494f4c7 37902a9b
Loading
Loading
Loading
Loading
+15 −20
Original line number Diff line number Diff line
@@ -7531,6 +7531,17 @@ static struct btf *btf_get_module_btf(const struct module *module)
	return btf;
}

static int check_btf_kconfigs(const struct module *module, const char *feature)
{
	if (!module && IS_ENABLED(CONFIG_DEBUG_INFO_BTF)) {
		pr_err("missing vmlinux BTF, cannot register %s\n", feature);
		return -ENOENT;
	}
	if (module && IS_ENABLED(CONFIG_DEBUG_INFO_BTF_MODULES))
		pr_warn("missing module BTF, cannot register %s\n", feature);
	return 0;
}

BPF_CALL_4(bpf_btf_find_by_name_kind, char *, name, int, name_sz, u32, kind, int, flags)
{
	struct btf *btf = NULL;
@@ -7891,15 +7902,8 @@ static int __register_btf_kfunc_id_set(enum btf_kfunc_hook hook,
	int ret, i;

	btf = btf_get_module_btf(kset->owner);
	if (!btf) {
		if (!kset->owner && IS_ENABLED(CONFIG_DEBUG_INFO_BTF)) {
			pr_err("missing vmlinux BTF, cannot register kfuncs\n");
			return -ENOENT;
		}
		if (kset->owner && IS_ENABLED(CONFIG_DEBUG_INFO_BTF_MODULES))
			pr_warn("missing module BTF, cannot register kfuncs\n");
		return 0;
	}
	if (!btf)
		return check_btf_kconfigs(kset->owner, "kfunc");
	if (IS_ERR(btf))
		return PTR_ERR(btf);

@@ -7999,17 +8003,8 @@ int register_btf_id_dtor_kfuncs(const struct btf_id_dtor_kfunc *dtors, u32 add_c
	int ret;

	btf = btf_get_module_btf(owner);
	if (!btf) {
		if (!owner && IS_ENABLED(CONFIG_DEBUG_INFO_BTF)) {
			pr_err("missing vmlinux BTF, cannot register dtor kfuncs\n");
			return -ENOENT;
		}
		if (owner && IS_ENABLED(CONFIG_DEBUG_INFO_BTF_MODULES)) {
			pr_err("missing module BTF, cannot register dtor kfuncs\n");
			return -ENOENT;
		}
		return 0;
	}
	if (!btf)
		return check_btf_kconfigs(owner, "dtor kfuncs");
	if (IS_ERR(btf))
		return PTR_ERR(btf);

+29 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ flush_pids()

	ip netns pids "${ns}" | xargs --no-run-if-empty kill -SIGUSR1 &>/dev/null

	for _ in $(seq 10); do
	for _ in $(seq $((timeout_poll * 10))); do
		[ -z "$(ip netns pids "${ns}")" ] && break
		sleep 0.1
	done
@@ -91,6 +91,15 @@ chk_msk_nr()
	__chk_msk_nr "grep -c token:" "$@"
}

chk_listener_nr()
{
	local expected=$1
	local msg="$2"

	__chk_nr "ss -inmlHMON $ns | wc -l" "$expected" "$msg - mptcp" 0
	__chk_nr "ss -inmlHtON $ns | wc -l" "$expected" "$msg - subflows"
}

wait_msk_nr()
{
	local condition="grep -c token:"
@@ -289,5 +298,24 @@ flush_pids
chk_msk_inuse 0 "many->0"
chk_msk_cestab 0 "many->0"

chk_listener_nr 0 "no listener sockets"
NR_SERVERS=100
for I in $(seq 1 $NR_SERVERS); do
	ip netns exec $ns ./mptcp_connect -p $((I + 20001)) \
		-t ${timeout_poll} -l 0.0.0.0 >/dev/null 2>&1 &
done

for I in $(seq 1 $NR_SERVERS); do
	mptcp_lib_wait_local_port_listen $ns $((I + 20001))
done

chk_listener_nr $NR_SERVERS "many listener sockets"

# graceful termination
for I in $(seq 1 $NR_SERVERS); do
	echo a | ip netns exec $ns ./mptcp_connect -p $((I + 20001)) 127.0.0.1 >/dev/null 2>&1 &
done
flush_pids

mptcp_lib_result_print_all_tap
exit $ret
+21 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ readonly KSFT_SKIP=4
readonly KSFT_TEST="${MPTCP_LIB_KSFT_TEST:-$(basename "${0}" .sh)}"

MPTCP_LIB_SUBTESTS=()
MPTCP_LIB_SUBTESTS_DUPLICATED=0

# only if supported (or forced) and not disabled, see no-color.org
if { [ -t 1 ] || [ "${SELFTESTS_MPTCP_LIB_COLOR_FORCE:-}" = "1" ]; } &&
@@ -146,12 +147,26 @@ mptcp_lib_kversion_ge() {
	mptcp_lib_fail_if_expected_feature "kernel version ${1} lower than ${v}"
}

__mptcp_lib_result_check_duplicated() {
	local subtest

	for subtest in "${MPTCP_LIB_SUBTESTS[@]}"; do
		if [[ "${subtest}" == *" - ${KSFT_TEST}: ${*%% #*}" ]]; then
			MPTCP_LIB_SUBTESTS_DUPLICATED=1
			mptcp_lib_print_err "Duplicated entry: ${*}"
			break
		fi
	done
}

__mptcp_lib_result_add() {
	local result="${1}"
	shift

	local id=$((${#MPTCP_LIB_SUBTESTS[@]} + 1))

	__mptcp_lib_result_check_duplicated "${*}"

	MPTCP_LIB_SUBTESTS+=("${result} ${id} - ${KSFT_TEST}: ${*}")
}

@@ -206,6 +221,12 @@ mptcp_lib_result_print_all_tap() {
	for subtest in "${MPTCP_LIB_SUBTESTS[@]}"; do
		printf "%s\n" "${subtest}"
	done

	if [ "${MPTCP_LIB_SUBTESTS_DUPLICATED}" = 1 ] &&
	   mptcp_lib_expect_all_features; then
		mptcp_lib_print_err "Duplicated test entries"
		exit ${KSFT_FAIL}
	fi
}

# get the value of keyword $1 in the line marked by keyword $2