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

!9301 MPTCP Upstream part 8

Merge Pull Request from: @geliangtang 
 
mptcp: More selftest coverage and code cleanup for net-next

Patches 1-2 and 4-5 add selftest coverage (and an associated subflow
counter in the kernel) to validate the recently-updated handling of
subflows with ID 0.

Patch 3 renames a label in the userspace path manager for clarity.
 
 
Link:https://gitee.com/openeuler/kernel/pulls/9301

 

Reviewed-by: default avatarYue Haibing <yuehaibing@huawei.com>
Signed-off-by: default avatarZhang Peng <zhangpeng362@huawei.com>
parents 468c9468 68205b2a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ struct mptcp_info {
	__u64	mptcpi_bytes_sent;
	__u64	mptcpi_bytes_received;
	__u64	mptcpi_bytes_acked;
	__u8	mptcpi_subflows_total;
};

/* MPTCP Reset reason codes, rfc8684 */
+4 −4
Original line number Diff line number Diff line
@@ -288,12 +288,12 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)

	if (!mptcp_pm_is_userspace(msk)) {
		GENL_SET_ERR_MSG(info, "invalid request; userspace PM not selected");
		goto remove_err;
		goto out;
	}

	if (id_val == 0) {
		err = mptcp_userspace_pm_remove_id_zero_address(msk, info);
		goto remove_err;
		goto out;
	}

	lock_sock(sk);
@@ -308,7 +308,7 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
	if (!match) {
		GENL_SET_ERR_MSG(info, "address with specified id not found");
		release_sock(sk);
		goto remove_err;
		goto out;
	}

	list_move(&match->list, &free_list);
@@ -322,7 +322,7 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
	}

	err = 0;
 remove_err:
out:
	sock_put(sk);
	return err;
}
+9 −0
Original line number Diff line number Diff line
@@ -1087,6 +1087,15 @@ static inline void __mptcp_do_fallback(struct mptcp_sock *msk)
	set_bit(MPTCP_FALLBACK_DONE, &msk->flags);
}

static inline bool __mptcp_has_initial_subflow(const struct mptcp_sock *msk)
{
	struct sock *ssk = READ_ONCE(msk->first);

	return ssk && ((1 << inet_sk_state_load(ssk)) &
		       (TCPF_ESTABLISHED | TCPF_SYN_SENT |
			TCPF_SYN_RECV | TCPF_LISTEN));
}

static inline void mptcp_do_fallback(struct sock *ssk)
{
	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
+2 −0
Original line number Diff line number Diff line
@@ -938,6 +938,8 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info)
	info->mptcpi_bytes_sent = msk->bytes_sent;
	info->mptcpi_bytes_received = msk->bytes_received;
	info->mptcpi_bytes_retrans = msk->bytes_retrans;
	info->mptcpi_subflows_total = info->mptcpi_subflows +
		__mptcp_has_initial_subflow(msk);
	unlock_sock_fast(sk, slow);
}
EXPORT_SYMBOL_GPL(mptcp_diag_fill_info);
+69 −0
Original line number Diff line number Diff line
@@ -3469,6 +3469,75 @@ userspace_tests()
		kill_events_pids
		mptcp_lib_kill_wait $tests_pid
	fi

	# userspace pm create id 0 subflow
	if reset_with_events "userspace pm create id 0 subflow" &&
	   continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then
		set_userspace_pm $ns2
		pm_nl_set_limits $ns1 0 1
		speed=5 \
			run_tests $ns1 $ns2 10.0.1.1 &
		local tests_pid=$!
		wait_mpj $ns2
		chk_mptcp_info subflows 0 subflows 0
		chk_subflows_total 1 1
		userspace_pm_add_sf $ns2 10.0.3.2 0
		chk_join_nr 1 1 1
		chk_mptcp_info subflows 1 subflows 1
		chk_subflows_total 2 2
		kill_events_pids
		wait $tests_pid
	fi

	# userspace pm remove initial subflow
	if reset_with_events "userspace pm remove initial subflow" &&
	   continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then
		set_userspace_pm $ns2
		pm_nl_set_limits $ns1 0 1
		speed=5 \
			run_tests $ns1 $ns2 10.0.1.1 &
		local tests_pid=$!
		wait_mpj $ns2
		userspace_pm_add_sf $ns2 10.0.3.2 20
		chk_join_nr 1 1 1
		chk_mptcp_info subflows 1 subflows 1
		chk_subflows_total 2 2
		userspace_pm_rm_sf $ns2 10.0.1.2
		# we don't look at the counter linked to the RM_ADDR but
		# to the one linked to the subflows that have been removed
		chk_rm_nr 0 1
		chk_rst_nr 0 0 invert
		chk_mptcp_info subflows 1 subflows 1
		chk_subflows_total 1 1
		kill_events_pids
		wait $tests_pid
	fi

	# userspace pm send RM_ADDR for ID 0
	if reset_with_events "userspace pm send RM_ADDR for ID 0" &&
	   continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then
		set_userspace_pm $ns1
		pm_nl_set_limits $ns2 1 1
		speed=5 \
			run_tests $ns1 $ns2 10.0.1.1 &
		local tests_pid=$!
		wait_mpj $ns1
		userspace_pm_add_addr $ns1 10.0.2.1 10
		chk_join_nr 1 1 1
		chk_add_nr 1 1
		chk_mptcp_info subflows 1 subflows 1
		chk_subflows_total 2 2
		chk_mptcp_info add_addr_signal 1 add_addr_accepted 1
		userspace_pm_rm_addr $ns1 0
		# we don't look at the counter linked to the subflows that
		# have been removed but to the one linked to the RM_ADDR
		chk_rm_nr 1 0 invert
		chk_rst_nr 0 0 invert
		chk_mptcp_info subflows 1 subflows 1
		chk_subflows_total 1 1
		kill_events_pids
		wait $tests_pid
	fi
}

endpoint_tests()