From nobody Sat Apr 11 12:45:17 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A265030FC36 for ; Fri, 10 Apr 2026 14:32:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775831534; cv=none; b=ZAQtOUzaAeoNt9f8IlhsKziuiGjy8w3Elxec35L5LTv2fB5xOmow3N16iEkur6asKS0EYQQYKjG5/XEprN1LEu5YPUvNEDvCi4p10l4XPnse8dsK8kStARpoBy16BSsJfZAYcxKTSN93ADK4XUAvWuyOF3nObpMR8USiKkEBSG4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775831534; c=relaxed/simple; bh=vRZJsZHOeLWoLa4dfnoRNMnj99bImcL0DAQbf/wmRVk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WQ/e4Zx2ObDER4pVXFDzv6CnyKdksir1mmLebIlbeUNWznLGX7SXq0kFakGp0g2kZd96S0BS8hifXMptyrOS2eKYS5n1u2BptbKhoMRRgqBtSbNtdEOn92TtcdOkiBGW9PgzxsOoe52PY6bM2h8S/fxhthMmlY6tluBoEQl2tuA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=maAmxFxy; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="maAmxFxy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 277A3C2BC9E; Fri, 10 Apr 2026 14:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775831534; bh=vRZJsZHOeLWoLa4dfnoRNMnj99bImcL0DAQbf/wmRVk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=maAmxFxyFY1kAZfAXdvJkTDXP5DRt81GoEZg0q9ZnUa7SrbbTn4EvbhMq00fyc4xP Tw+j4Yoyx7tKHX2XKOwcJ/SftS881Ywe0EB4dVuO0HV2HmYejBXwzz0oZPpNtodRzQ Z9Rj20MTdM6uYspgOYdZn+DsFGVm+wR2jbFoq30FzrLHBHXtFTAsP0vADtYjsKqtgd /EljZkKoYJN5BDXIpZNqdpz2yFwxLWTRLhI5QE0t9YDpevT6UIZxFjj863bgltZyKp 4qnCH7HegeOwO0rEV3FDvJ9fwdRCVBJD8AsA0q+eKB4PkS9ONx7aZpQUjYE8krRedC 0vnHGJofk0uPw== From: "Matthieu Baerts (NGI0)" Date: Fri, 10 Apr 2026 16:31:48 +0200 Subject: [PATCH mptcp-next v2 10/17] mptcp: pm: in-kernel: explicitly limit batches to array size Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260410-mptcp-inc-limits-v2-10-5402209f05d3@kernel.org> References: <20260410-mptcp-inc-limits-v2-0-5402209f05d3@kernel.org> In-Reply-To: <20260410-mptcp-inc-limits-v2-0-5402209f05d3@kernel.org> To: MPTCP Upstream Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5699; i=matttbe@kernel.org; h=from:subject:message-id; bh=vRZJsZHOeLWoLa4dfnoRNMnj99bImcL0DAQbf/wmRVk=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGDJvct63mrx10oSCzs9xIev0MxP8+5XOCRys5T0Z4qt+f b3fOxGjjlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgIlUizIyzM+cKhb57L3oDQNV vnTWHZmflvQsnve0Ly3DwfZuJP/O7Qz/615khO10L52gYnzxrJvuMv8HpVvZM3MjE6xafTM5D2n yAgA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 The in-kernel PM can create subflows in reply to ADD_ADDR by batch of maximum 8 subflows for the moment. Same when adding new "subflow" endpoints with the fullmesh flag. This limit is linked to the arrays used during these steps. There was no explicit limit to the arrays size (8), because the limit of extra subflows is the same (8). It seems safer to use an explicit limit, but also these two sizes are going to be different in the next commit. Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_kernel.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c index 7895fb5f982e..e9102c0f92f4 100644 --- a/net/mptcp/pm_kernel.c +++ b/net/mptcp/pm_kernel.c @@ -201,7 +201,8 @@ fill_remote_addr(struct mptcp_sock *msk, struct mptcp_a= ddr_info *local, static unsigned int fill_remote_addresses_fullmesh(struct mptcp_sock *msk, struct mptcp_addr_info *local, - struct mptcp_addr_info *addrs) + struct mptcp_addr_info *addrs, + int addrs_size) { u8 limit_extra_subflows =3D mptcp_pm_get_limit_extra_subflows(msk); bool deny_id0 =3D READ_ONCE(msk->pm.remote_deny_join_id0); @@ -236,7 +237,8 @@ fill_remote_addresses_fullmesh(struct mptcp_sock *msk, msk->pm.extra_subflows++; i++; =20 - if (msk->pm.extra_subflows >=3D limit_extra_subflows) + if (msk->pm.extra_subflows >=3D limit_extra_subflows || + i =3D=3D addrs_size) break; } =20 @@ -248,7 +250,8 @@ fill_remote_addresses_fullmesh(struct mptcp_sock *msk, */ static unsigned int fill_remote_addresses_vec(struct mptcp_sock *msk, struct mptcp_addr_info *= local, - bool fullmesh, struct mptcp_addr_info *addrs) + bool fullmesh, struct mptcp_addr_info *addrs, + int addrs_size) { /* Non-fullmesh: fill in the single entry corresponding to the primary * MPC subflow remote address, and return 1, corresponding to 1 entry. @@ -257,7 +260,7 @@ fill_remote_addresses_vec(struct mptcp_sock *msk, struc= t mptcp_addr_info *local, return fill_remote_addr(msk, local, addrs); =20 /* Fullmesh endpoint: fill all possible remote addresses */ - return fill_remote_addresses_fullmesh(msk, local, addrs); + return fill_remote_addresses_fullmesh(msk, local, addrs, addrs_size); } =20 static struct mptcp_pm_addr_entry * @@ -407,7 +410,8 @@ static void mptcp_pm_create_subflow_or_signal_addr(stru= ct mptcp_sock *msk) else /* local_addr_used is not decr for ID 0 */ msk->pm.local_addr_used++; =20 - nr =3D fill_remote_addresses_vec(msk, &local.addr, fullmesh, addrs); + nr =3D fill_remote_addresses_vec(msk, &local.addr, fullmesh, + addrs, ARRAY_SIZE(addrs)); if (nr =3D=3D 0) continue; =20 @@ -444,6 +448,7 @@ static unsigned int fill_local_addresses_vec_fullmesh(struct mptcp_sock *msk, struct mptcp_addr_info *remote, struct mptcp_pm_local *locals, + int locals_size, bool c_flag_case) { u8 limit_extra_subflows =3D mptcp_pm_get_limit_extra_subflows(msk); @@ -485,7 +490,8 @@ fill_local_addresses_vec_fullmesh(struct mptcp_sock *ms= k, msk->pm.extra_subflows++; i++; =20 - if (msk->pm.extra_subflows >=3D limit_extra_subflows) + if (msk->pm.extra_subflows >=3D limit_extra_subflows || + i =3D=3D locals_size) break; } rcu_read_unlock(); @@ -556,7 +562,8 @@ fill_local_laminar_endp(struct mptcp_sock *msk, struct = mptcp_addr_info *remote, static unsigned int fill_local_addresses_vec_c_flag(struct mptcp_sock *msk, struct mptcp_addr_info *remote, - struct mptcp_pm_local *locals) + struct mptcp_pm_local *locals, + int locals_size) { u8 limit_extra_subflows =3D mptcp_pm_get_limit_extra_subflows(msk); struct pm_nl_pernet *pernet =3D pm_nl_get_pernet_from_msk(msk); @@ -583,7 +590,8 @@ fill_local_addresses_vec_c_flag(struct mptcp_sock *msk, msk->pm.extra_subflows++; i++; =20 - if (msk->pm.extra_subflows >=3D limit_extra_subflows) + if (msk->pm.extra_subflows >=3D limit_extra_subflows || + i =3D=3D locals_size) break; } =20 @@ -617,13 +625,14 @@ fill_local_address_any(struct mptcp_sock *msk, struct= mptcp_addr_info *remote, */ static unsigned int fill_local_addresses_vec(struct mptcp_sock *msk, struct mptcp_addr_info *r= emote, - struct mptcp_pm_local *locals) + struct mptcp_pm_local *locals, int locals_size) { bool c_flag_case =3D remote->id && mptcp_pm_add_addr_c_flag_case(msk); =20 /* If there is at least one MPTCP endpoint with a fullmesh flag */ if (mptcp_pm_get_endp_fullmesh_max(msk)) return fill_local_addresses_vec_fullmesh(msk, remote, locals, + locals_size, c_flag_case); =20 /* If there is at least one MPTCP endpoint with a laminar flag */ @@ -634,7 +643,8 @@ fill_local_addresses_vec(struct mptcp_sock *msk, struct= mptcp_addr_info *remote, * limits are used -- accepting no ADD_ADDR -- and use subflow endpoints */ if (c_flag_case) - return fill_local_addresses_vec_c_flag(msk, remote, locals); + return fill_local_addresses_vec_c_flag(msk, remote, locals, + locals_size); =20 /* No special case: fill in the single 'IPADDRANY' local address */ return fill_local_address_any(msk, remote, &locals[0]); @@ -669,7 +679,7 @@ static void mptcp_pm_nl_add_addr_received(struct mptcp_= sock *msk) /* connect to the specified remote address, using whatever * local address the routing configuration will pick. */ - nr =3D fill_local_addresses_vec(msk, &remote, locals); + nr =3D fill_local_addresses_vec(msk, &remote, locals, ARRAY_SIZE(locals)); if (nr =3D=3D 0) return; =20 --=20 2.53.0