Commit d8f3d842 authored by Matthieu Baerts (NGI0)'s avatar Matthieu Baerts (NGI0) Committed by Wen Zhiwei
Browse files

mptcp: pm: fullmesh: select the right ID later

stable inclusion
from stable-v6.6.48
commit b762e1e301bd10300b43f3dfc9d6032ad8c4cb02
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAWEBV

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=b762e1e301bd10300b43f3dfc9d6032ad8c4cb02



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

commit 09355f7abb9fbfc1a240be029837921ea417bf4f upstream.

When reacting upon the reception of an ADD_ADDR, the in-kernel PM first
looks for fullmesh endpoints. If there are some, it will pick them,
using their entry ID.

It should set the ID 0 when using the endpoint corresponding to the
initial subflow, it is a special case imposed by the MPTCP specs.

Note that msk->mpc_endpoint_id might not be set when receiving the first
ADD_ADDR from the server. So better to compare the addresses.

Fixes: 1a0d6136 ("mptcp: local addresses fullmesh")
Cc: stable@vger.kernel.org
Reviewed-by: default avatarMat Martineau <martineau@kernel.org>
Signed-off-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20240819-net-mptcp-pm-reusing-id-v1-12-38035d40de5b@kernel.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarWen Zhiwei <wenzhiwei@kylinos.cn>
parent 06ef4ad8
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -654,6 +654,7 @@ static unsigned int fill_local_addresses_vec(struct mptcp_sock *msk,
{
	struct sock *sk = (struct sock *)msk;
	struct mptcp_pm_addr_entry *entry;
	struct mptcp_addr_info mpc_addr;
	struct pm_nl_pernet *pernet;
	unsigned int subflows_max;
	int i = 0;
@@ -661,6 +662,8 @@ static unsigned int fill_local_addresses_vec(struct mptcp_sock *msk,
	pernet = pm_nl_get_pernet_from_msk(msk);
	subflows_max = mptcp_pm_get_subflows_max(msk);

	mptcp_local_address((struct sock_common *)msk, &mpc_addr);

	rcu_read_lock();
	list_for_each_entry_rcu(entry, &pernet->local_addr_list, list) {
		if (!(entry->flags & MPTCP_PM_ADDR_FLAG_FULLMESH))
@@ -671,7 +674,13 @@ static unsigned int fill_local_addresses_vec(struct mptcp_sock *msk,

		if (msk->pm.subflows < subflows_max) {
			msk->pm.subflows++;
			addrs[i++] = entry->addr;
			addrs[i] = entry->addr;

			/* Special case for ID0: set the correct ID */
			if (mptcp_addresses_equal(&entry->addr, &mpc_addr, entry->addr.port))
				addrs[i].id = 0;

			i++;
		}
	}
	rcu_read_unlock();