From patchwork Mon Oct 21 15:14:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13844310 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 B70631FA24E; Mon, 21 Oct 2024 15:14:32 +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=1729523672; cv=none; b=E3/Gm/mR/wrB1P4NCSDO8NMIXtPh4mB0EO9C0wU2ai1WRxQ9oRl7N/R80JOFbeaUBNITMq8+0KbHgh5ZwwzbkvZ+38+jTcVoCCiuehpYYvwX8VVN3swzYaaG0PTzHg/glOk3+u55Q8IBV374RcNSBAMFUQYkK531RLX7tqAkIqc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729523672; c=relaxed/simple; bh=UGwRH+uD/CUajxibX4q7O5V5qsIa9cWrqqplz3NZlWU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=u0D96JD9Y/TRqgnnqeu7z6pRIBm8eus6/HYsOj5bnSxmIev0Nqy+xnK06EvtG5UiMSXVGeLALtqvxA+4+U5OKsuzts+LifUmomTFT6ja37C6IkC7LNTjfrJdQREPoZormsHbly+RQA8cBqgQ28DX4JQdorCpxs/D215sdllspQs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=k+Zfgz91; 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="k+Zfgz91" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FA0FC4CEE7; Mon, 21 Oct 2024 15:14:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729523672; bh=UGwRH+uD/CUajxibX4q7O5V5qsIa9cWrqqplz3NZlWU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=k+Zfgz91VX2q3gHte1I6HFS/yKLMJZd7pTTA36WSBA5TmOPq5nQY6GT2iYSemXMs0 t6J5eVsZWQZpEOY5/HSbLN/cpDt9lT4m8B+eUMvj7MZzLrtdvxd6C3qXfckPxxudTU DKrF38rwmclnRD0M4OH837nNFGQXizXDQ2dzxa0LyjqGL7MHu8RvNzHVKnmMYN0tvE LMZQ3kZ5qAcE7yDWIjSW+Q+LSYI0B2SEu6P72q7GD0Leuch8KqnLHJBcJUhIL8xMYN DJO9vFGGI8Ma8//Xh7fT2Lo3Hdq1C7eKVUjvm7GSm3PioZudBdh+CMFhX74Ispnm5j cyXQ0Vm4Bh5qw== From: "Matthieu Baerts (NGI0)" Date: Mon, 21 Oct 2024 17:14:03 +0200 Subject: [PATCH net-next 1/4] mptcp: pm: send ACK on non-stale subflows Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241021-net-next-mptcp-misc-6-13-v1-1-1ef02746504a@kernel.org> References: <20241021-net-next-mptcp-misc-6-13-v1-0-1ef02746504a@kernel.org> In-Reply-To: <20241021-net-next-mptcp-misc-6-13-v1-0-1ef02746504a@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1436; i=matttbe@kernel.org; h=from:subject:message-id; bh=UGwRH+uD/CUajxibX4q7O5V5qsIa9cWrqqplz3NZlWU=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnFm/Sv9u0ka3ZTg3C8CUZaNIRQZ6Kvcx4QsLD+ QdUPDeUyr6JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZxZv0gAKCRD2t4JPQmmg c3NjEACFHVmaaaxHbLMTLmnOA4RGieRwkOwDxMFhV41OPCiZb8UmEiEgjnSs9n64Z3dfe2VKzMX abk6v2Fe+sd38qpFiis4v5iBKCUDmtGZAGJN3wh+NyNWIQSi9Q6rXDHGw12kSOuWKiuIZov/Cur CyCNx2pVeuycquXq+M1koD4SWqh1wBY24VrwAzS0woJqcLx4/LMBzytFBRrw/PvnfIPpVv3RGRU jHYfkCtbJA0MAYs1CO0AdKxGneMPauI5VIk0thdY373Czx2z91e2IDZecMifu60fUg7kBh8qmZc 9iYLjIgTCBL88gfmXx3976oHoYmA+FPfH0QjOofxeiZlugpkbM7R0AT6uGYEdOYWAh8aqRRdkzy hVu9eT9rlNTGy3l2OROxln714CD23WWLaKku8FleL0zsqnaqS2VtueerydXXKI7Jf2/0SChdeiF Vh/gpMiDjMa1t1UvvUQFoQjIbLCbrKGSZxhuxOYV5/a172hSqjTfpNYMDHZYtYUgITQtDvM+KkM hPY0N/xBspwLnnyUS3OV1FRJeEMDaI1SPMp2SoGnLMiTKUrD9riD9sm9zaVZz1cVsvy9yA97HR8 CJO3wEoCXZz8kbIx0ezsFjdNfoSDrp/UlmC+W1teQXmSNoo1heaPVYUpFFygZ2KblM694RnXpnf fQq7mykZufeFuCg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 If the subflow is considered as "staled", it is better to avoid it to send an ACK carrying an ADD_ADDR or RM_ADDR. Another subflow, if any, will then be selected. Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_netlink.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index db586a5b3866f66a24431d7f2cab566f89102885..618289aac0ab7f558d55d8b2ebb00dc62fc72f88 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -781,7 +781,7 @@ bool mptcp_pm_nl_is_init_remote_addr(struct mptcp_sock *msk, void mptcp_pm_nl_addr_send_ack(struct mptcp_sock *msk) { - struct mptcp_subflow_context *subflow; + struct mptcp_subflow_context *subflow, *alt = NULL; msk_owned_by_me(msk); lockdep_assert_held(&msk->pm.lock); @@ -792,10 +792,18 @@ void mptcp_pm_nl_addr_send_ack(struct mptcp_sock *msk) mptcp_for_each_subflow(msk, subflow) { if (__mptcp_subflow_active(subflow)) { - mptcp_pm_send_ack(msk, subflow, false, false); - break; + if (!subflow->stale) { + mptcp_pm_send_ack(msk, subflow, false, false); + return; + } + + if (!alt) + alt = subflow; } } + + if (alt) + mptcp_pm_send_ack(msk, alt, false, false); } int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk, From patchwork Mon Oct 21 15:14:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13844311 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 7D2DA1F9410; Mon, 21 Oct 2024 15:14:35 +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=1729523675; cv=none; b=r6pjtziY42uTkpUTVhxb+Urbbu4twSC1KDsIfkRonvmkzcDELCQxHJgQZMnE1pT7geQXLpbUHt0rIrtbpCpIzlQhQDrXZJT4IiGcCQXWsgggNmWUYgx83ZoSwy+yLoam5vXmcaoYZr6xVLd36A/52tVlEckGJLtTjobop+XJYwM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729523675; c=relaxed/simple; bh=vWvfcGb12DAvG2TbXrEaAfKBZiWX/4a2tEa1csyld2M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LvC7xfvtbXrTQ/Z54YzKTXorle90ncM3ZDz3l9xVLXFhudXh295kSomSSDeCZLvEiLyOJSBe83Cqzc8wfFZbVX4iiEJx2c9klF5LmSWUHa4i97bbm1F4bvUkUFHF7eOGXfQyC76/LbLUQ7TiilBOoUwET0/dAup0CdVCRZdPAy0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QVIj5Nas; 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="QVIj5Nas" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E231C4CEE9; Mon, 21 Oct 2024 15:14:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729523675; bh=vWvfcGb12DAvG2TbXrEaAfKBZiWX/4a2tEa1csyld2M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=QVIj5Nas6qg2VuGaA6lYMSp4x7AKP7uCXodmDOLIqWeorU7a9uAEWRuLfpoyzQdyI AtvRwqgfQMmo2swkv0EN/Eh6onC6b3GzPV12lMQV8N3u5LelYgDcDxnFCNvzRfT+u/ fJAQ6AhecnEmgzXA5HOABTxF2EjQfiq2KhDZ5Bb5L28HMHQsHzQVqwOyQlqUqvzFe5 ivHI8aKaHfgHr2fljyFd4rv7nF/Vvmupjl0JR9S69aLhBHakuASwNrFvOfPeoilD7E /Eg3ewf2CfI5Ah9vJ/6n4Gbl625gb4Ss0FG1UYP3iQ/hXVYpuHD8GkBwT9uRKvoMyq nozhB2V+ZR6Ww== From: "Matthieu Baerts (NGI0)" Date: Mon, 21 Oct 2024 17:14:04 +0200 Subject: [PATCH net-next 2/4] mptcp: annotate data-races around subflow->fully_established Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241021-net-next-mptcp-misc-6-13-v1-2-1ef02746504a@kernel.org> References: <20241021-net-next-mptcp-misc-6-13-v1-0-1ef02746504a@kernel.org> In-Reply-To: <20241021-net-next-mptcp-misc-6-13-v1-0-1ef02746504a@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Gang Yan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5751; i=matttbe@kernel.org; h=from:subject:message-id; bh=vNuVsHRC0SorCnDtGnHFJS65pDzO9H/fv+K3NOkTUQ8=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnFm/Sd0aZnbkx11rc+2lc/1xp6j6LPLwKct9KL YC+zEHLE9CJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZxZv0gAKCRD2t4JPQmmg c+N0D/9NpROylZw9WFV8780QF5og6BYKr816P4j+R9/UYOEcwLUCnVrRQkp4NRT0ojQdroqAYuf dGrNepr4/WY/1HOQezTFEDdb7TlUk7/4xAX//YdHPJb4yD80E9IaYFhNTU0Qqzokw5K1ChKhQLY WksOm0O23jEXQjIywIojAZ4j1gPxuO7m674YzHBcMauIjeks72YwyriWRdOFfTvz7tAIu7N8Hzq ZmsevHIJnjp5gX0Zh3icItCnDC5WY3rFoInLX/MUwTpVK08FnTwTiJJCs5yn7ojHcsrGFFc5gGc qsxXJyHPITL7fKO3NXD07rHVy0hnPBgI7DK/7bcbakMpm96w4SrVSwkn6IbLFKdTmWNDrMSjd+P 8akZ+jx3S1kko/AtKhiYU8IIquqJWMfR3BcUB0Gt18KC3/ubFJfM16LXZm/8uklXRE3sCZXb553 zJfGcrtTOD2fApJlddjBg1q0DXZ753Tq6uHFE5h5Zw9WpuaiI7dFLeRf9lkVgqivLV6t1tJQyrH EDDauSWdxdtXNUN14hMutyCLwyCf1aNYm5vsb1hdO646IGgvvHA6FJrQ9yAOkpoG60LyGvCtS5H Y0URh/Kw4ZvlOWiycIykB3bQK8ZJ5SGJW4iRRIdk39R/Y1HfYhFDH2alEqNhi0uRXUYaBEG1Yms YrJbgH3QGq40Jng== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Gang Yan We introduce the same handling for potential data races with the 'fully_established' flag in subflow as previously done for msk->fully_established. Additionally, we make a crucial change: convert the subflow's 'fully_established' from 'bit_field' to 'bool' type. This is necessary because methods for avoiding data races don't work well with 'bit_field'. Specifically, the 'READ_ONCE' needs to know the size of the variable being accessed, which is not supported in 'bit_field'. Also, 'test_bit' expect the address of 'bit_field'. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/516 Signed-off-by: Gang Yan Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/diag.c | 2 +- net/mptcp/options.c | 4 ++-- net/mptcp/protocol.c | 2 +- net/mptcp/protocol.h | 6 +++--- net/mptcp/subflow.c | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/net/mptcp/diag.c b/net/mptcp/diag.c index 2d3efb405437d85c0bca70d7a92ca3a7363365e1..02205f7994d752cc505991efdf7aa0bbbfd830db 100644 --- a/net/mptcp/diag.c +++ b/net/mptcp/diag.c @@ -47,7 +47,7 @@ static int subflow_get_info(struct sock *sk, struct sk_buff *skb) flags |= MPTCP_SUBFLOW_FLAG_BKUP_REM; if (sf->request_bkup) flags |= MPTCP_SUBFLOW_FLAG_BKUP_LOC; - if (sf->fully_established) + if (READ_ONCE(sf->fully_established)) flags |= MPTCP_SUBFLOW_FLAG_FULLY_ESTABLISHED; if (sf->conn_finished) flags |= MPTCP_SUBFLOW_FLAG_CONNECTED; diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 370c3836b7712f4ca97c99d35a20e88e85a33d70..1603b3702e2207f191fdeef2b29ea2f05fd2b910 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -461,7 +461,7 @@ static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb, return false; /* MPC/MPJ needed only on 3rd ack packet, DATA_FIN and TCP shutdown take precedence */ - if (subflow->fully_established || snd_data_fin_enable || + if (READ_ONCE(subflow->fully_established) || snd_data_fin_enable || subflow->snd_isn != TCP_SKB_CB(skb)->seq || sk->sk_state != TCP_ESTABLISHED) return false; @@ -930,7 +930,7 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk, /* here we can process OoO, in-window pkts, only in-sequence 4th ack * will make the subflow fully established */ - if (likely(subflow->fully_established)) { + if (likely(READ_ONCE(subflow->fully_established))) { /* on passive sockets, check for 3rd ack retransmission * note that msk is always set by subflow_syn_recv_sock() * for mp_join subflows diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 1f5c63eb21f0db92341ec941cfe2aec919cdd3de..a6c9661a4c45a00e982d0f68f21621c3cf33469b 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3511,7 +3511,7 @@ static void schedule_3rdack_retransmission(struct sock *ssk) struct tcp_sock *tp = tcp_sk(ssk); unsigned long timeout; - if (mptcp_subflow_ctx(ssk)->fully_established) + if (READ_ONCE(mptcp_subflow_ctx(ssk)->fully_established)) return; /* reschedule with a timeout above RTT, as we must look only for drop */ diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 568a72702b080d7610425ce5c3a409c7b88da13a..a93e661ef5c435155066ce9cc109092661f0711c 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -513,7 +513,6 @@ struct mptcp_subflow_context { request_bkup : 1, mp_capable : 1, /* remote is MPTCP capable */ mp_join : 1, /* remote is JOINing */ - fully_established : 1, /* path validated */ pm_notified : 1, /* PM hook called for established status */ conn_finished : 1, map_valid : 1, @@ -532,10 +531,11 @@ struct mptcp_subflow_context { is_mptfo : 1, /* subflow is doing TFO */ close_event_done : 1, /* has done the post-closed part */ mpc_drop : 1, /* the MPC option has been dropped in a rtx */ - __unused : 8; + __unused : 9; bool data_avail; bool scheduled; bool pm_listener; /* a listener managed by the kernel PM? */ + bool fully_established; /* path validated */ u32 remote_nonce; u64 thmac; u32 local_nonce; @@ -780,7 +780,7 @@ static inline bool __tcp_can_send(const struct sock *ssk) static inline bool __mptcp_subflow_active(struct mptcp_subflow_context *subflow) { /* can't send if JOIN hasn't completed yet (i.e. is usable for mptcp) */ - if (subflow->request_join && !subflow->fully_established) + if (subflow->request_join && !READ_ONCE(subflow->fully_established)) return false; return __tcp_can_send(mptcp_subflow_tcp_sock(subflow)); diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 6170f2fff71e4f9d64837f2ebf4d81bba224fafb..860903e0642255cf9efb39da9e24c39f6547481f 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -800,7 +800,7 @@ void __mptcp_subflow_fully_established(struct mptcp_sock *msk, const struct mptcp_options_received *mp_opt) { subflow_set_remote_key(msk, subflow, mp_opt); - subflow->fully_established = 1; + WRITE_ONCE(subflow->fully_established, true); WRITE_ONCE(msk->fully_established, true); if (subflow->is_mptfo) @@ -2062,7 +2062,7 @@ static void subflow_ulp_clone(const struct request_sock *req, } else if (subflow_req->mp_join) { new_ctx->ssn_offset = subflow_req->ssn_offset; new_ctx->mp_join = 1; - new_ctx->fully_established = 1; + WRITE_ONCE(new_ctx->fully_established, true); new_ctx->remote_key_valid = 1; new_ctx->backup = subflow_req->backup; new_ctx->request_bkup = subflow_req->request_bkup; From patchwork Mon Oct 21 15:14:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13844312 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 38FAA1FAF14; Mon, 21 Oct 2024 15:14:37 +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=1729523678; cv=none; b=o0qVaSo3dvJKp8nIS8ii7b3JXj4LYtM/6IHCViE7UM/9heUCspsk5I60cXFtb2YDqcmWRMaUBDgcI7iLWiozY+yHF5c5fBvEOfYYvUyIdHINhosL2L8YPi/r2GqfFesGaHynItMUWvrdjuLRA0zW6g920QKi3RHoioxl14xN3So= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729523678; c=relaxed/simple; bh=M4gPPP8WBXV2kHlMXNqnYefCKiRRE1r3jiRrHS8QQmA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=c4fnwncnzSYgy9RL4CNt0caD+1Z23X/t/UBAzq1vbThAk5X2fzsQrum1MOKc8CWMYGkEq6c1gvgi+jT1kgaRC9XVONvwmViG+ZH/WHRvgt9MgNOuWDZwBlw3ORxELKMgzNSf9s65uzh6HRlmo3k7Iiiw6Pnp2Kx7T6OE4WA2wr4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tULXF4Pl; 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="tULXF4Pl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE5FAC4CECD; Mon, 21 Oct 2024 15:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729523677; bh=M4gPPP8WBXV2kHlMXNqnYefCKiRRE1r3jiRrHS8QQmA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tULXF4PlMYT4RoeEWgrCWZ9q0Xkl34N7eNw8fkwZe5Keu1H1LmgPPu0HzVbkqtric bhVp1E/8LzSM53RlaXgAHW/7b49KaAxlmc6ysX+C2V7gdE2hCcOHeYIp7o+nYxNeQY cJMRCxagBeZgNZZXxht7vGCpLwyVJYPwdTvMWzVSVgmEX0sCCWMa07mJqumQ9gAeqC 1SPaxDYjbkGCKtUUrjvPSpkFZ1ehTZ1pUfMsVm/1cY1WjKiDxqR+dcOmtibFez7bLE mkbSymIt+WRsjNjDX92a7vIdNIFOLZ77GrmKAM5ly+gK+YAKav8hkk9D+hELbjP+QF tUFDwewV4Y5jA== From: "Matthieu Baerts (NGI0)" Date: Mon, 21 Oct 2024 17:14:05 +0200 Subject: [PATCH net-next 3/4] mptcp: implement mptcp_pm_connection_closed Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241021-net-next-mptcp-misc-6-13-v1-3-1ef02746504a@kernel.org> References: <20241021-net-next-mptcp-misc-6-13-v1-0-1ef02746504a@kernel.org> In-Reply-To: <20241021-net-next-mptcp-misc-6-13-v1-0-1ef02746504a@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2077; i=matttbe@kernel.org; h=from:subject:message-id; bh=agrTHeEkp+bsi6wma1yUOugua1XDIq5XGUvPVwsQ3+k=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnFm/SQvVEebUgTCd82ssFUoEPFz6smHVpKZ/Pk UyhjloWt/aJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZxZv0gAKCRD2t4JPQmmg c49zEADvPuiwMVcKElM7GNwUwbEu7noL7c/L6GXYXcrb6+MZAorpoXwN3z+xqVSwm9FMczBOK7+ Ys5KAtNxNkM8shpkbGkMK2sDVmjhpjHbzSkfeCHXpDzaDAkZmqiyrNQEpmGrfLRae8i8QgtfvtW kvi7cNv6zhP/drhAe2SqN4ruuUs/zk+qnO3pm9S0LFOJ34oYgy+kkqSYwDWMOuUsr+ZOldgMCFK FgjzlWOJlIle5d/ruGHnMEWDWPYsTHe9Bfnds/xGEobvhm+4WBN7is0Zn1Vm+1kBHgkO+madb2f fmeCWmDsyoYOHH7ewiUD6HW8OZdh89HJwvmQ5eo0oOyxqLB9UV01mXWuBbe9vD3Rt62Zao5UAY7 UpM/fJuG5j33qwKhxubGdRDLW9GmnPnrmYDg6y+5JErw3pd67XMnI8zRYQQWGA9EEUMclxKlES/ EcZbkB3qGDWqXOkNLQLdnu8LBqkDIQZEAKRRUzBZA9FaJpnW11P6rzvHnTofRZS2ZhWns7LMMYy VYUGTwdrlTyGAC3cZW0sTOz4Zw2EQnbG5vqO8lDpXo4TwC358VLR9+AlgBDnVt03qpuIPHwG3Ya 6UTaWITn9uMEmSQ68LiKCp9jn4B+2qbSUvRJ1U4MHkH+jd21nF0io+GUsW9GXn1YzFvKQJpFL0u lj4ufNdaBVZnLvA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang The MPTCP path manager event handler mptcp_pm_connection_closed interface has been added in the commit 1b1c7a0ef7f3 ("mptcp: Add path manager interface") but it was an empty function from then on. With such name, it sounds good to invoke mptcp_event with the MPTCP_EVENT_CLOSED event type from it. It also removes a bit of duplicated code. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm.c | 3 +++ net/mptcp/protocol.c | 6 ++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 620264c75dc2e3b79927c5db44ec6ce84d83590b..16c336c519403d0147c5a3ffe301d0238c5b250a 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -154,6 +154,9 @@ void mptcp_pm_fully_established(struct mptcp_sock *msk, const struct sock *ssk) void mptcp_pm_connection_closed(struct mptcp_sock *msk) { pr_debug("msk=%p\n", msk); + + if (msk->token) + mptcp_event(MPTCP_EVENT_CLOSED, msk, NULL, GFP_KERNEL); } void mptcp_pm_subflow_established(struct mptcp_sock *msk) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index a6c9661a4c45a00e982d0f68f21621c3cf33469b..e978e05ec8d1357c4d40cd9830f7dd82a68cf4bf 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3139,8 +3139,7 @@ bool __mptcp_close(struct sock *sk, long timeout) sock_hold(sk); pr_debug("msk=%p state=%d\n", sk, sk->sk_state); - if (msk->token) - mptcp_event(MPTCP_EVENT_CLOSED, msk, NULL, GFP_KERNEL); + mptcp_pm_connection_closed(msk); if (sk->sk_state == TCP_CLOSE) { __mptcp_destroy_sock(sk); @@ -3206,8 +3205,7 @@ static int mptcp_disconnect(struct sock *sk, int flags) mptcp_stop_rtx_timer(sk); mptcp_stop_tout_timer(sk); - if (msk->token) - mptcp_event(MPTCP_EVENT_CLOSED, msk, NULL, GFP_KERNEL); + mptcp_pm_connection_closed(msk); /* msk->subflow is still intact, the following will not free the first * subflow From patchwork Mon Oct 21 15:14:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts (NGI0)" X-Patchwork-Id: 13844313 X-Patchwork-Delegate: matthieu.baerts@tessares.net 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 A681C1F9EA4; Mon, 21 Oct 2024 15:14:40 +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=1729523680; cv=none; b=EqRvD+u7/Et8DDcQNEKZdgh74vbtymbOPAfemlALvI9x64UrPYGkekp8QY9XIGRpOX5mDya8TO8EIWxJHvOpRy8pfUcB3YETWUCImae+npoKOJ962JZjMrh6Gm4XjkL+Yvu7faa7qaQpnm34/p/JPBPLMZCs29gfBk2BDjMxIWE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729523680; c=relaxed/simple; bh=4sqNqcl6enA2uep5yPbqNRkltc0niKW2hhqA/FLbO5s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=U80xk8svMVm76zPkjC5wRCxGTdsccJR4IlzMwHec0h04wd++K4oKzmVj04/Ha2omHQg1+2KqGtMTph9NXdU6rkPQsS8JBgrDvb0sREiHcE86ygz8bvY7FxGHJgbMpcpMrme55ahOL21l1h4fMcFkBb/cUPNpMZK2xSNCkyt7pAY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=H6dBmo4B; 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="H6dBmo4B" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41C6FC4CEE6; Mon, 21 Oct 2024 15:14:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729523680; bh=4sqNqcl6enA2uep5yPbqNRkltc0niKW2hhqA/FLbO5s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=H6dBmo4Bul+vk/CYUyLi43MWU4cp9Ypmuvx6iBWBdhcgBtV392XpeR1MX6qXFtJOb oyChvjaLNC/fMTa3CJwzSolCXx7skGo/RfJPst8dASmnVWpaIb6Yl46Qi9xgb1O7Gb 47oSYZi6WgrxEZOGxYYNaKlJIzRgbfgrTxnKMkR4qxudgC38zQu+Oh5inTu2ELrA4B 3fuPetX1ZYUHEXclM0K/ZVVT5x5nJaqgMhe5UUjdTCAYRiimh1Z37Gt8DlgnCJhm6O YlKTFOjQymuKAXFv7JD/hoiQBUJc5NeqpisuBk59SCQhIbv9EKmWVdjVy1GgZAyIyI FBtV6EAEUK/XA== From: "Matthieu Baerts (NGI0)" Date: Mon, 21 Oct 2024 17:14:06 +0200 Subject: [PATCH net-next 4/4] mptcp: use "middlebox interference" RST when no DSS Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241021-net-next-mptcp-misc-6-13-v1-4-1ef02746504a@kernel.org> References: <20241021-net-next-mptcp-misc-6-13-v1-0-1ef02746504a@kernel.org> In-Reply-To: <20241021-net-next-mptcp-misc-6-13-v1-0-1ef02746504a@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" , Davide Caratti X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2222; i=matttbe@kernel.org; h=from:subject:message-id; bh=kl9DK7HD7r1EeUzN5KT2dnyn50jJCyFp2AMSo9gs1og=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnFm/TO9aj5czQ2jOGmTdUgveys84TK2SLiS6BN 8U7BbZRd3OJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZxZv0wAKCRD2t4JPQmmg c3nCEACyOlH8DW5LM8a1tjOtVTJFSV8slTWiHnS/Rr+DiPD206bxZCOhH5QLBp4HRezF3NZh5LB lDq0+XMAwJ39M4AIm5W0YDPlTk2pN5WvM3P41iKFoy2Yn3M1BLm4lv7GYq9tHYj1YUVjJifmowM McGAMmBANwz5iZ2gbLolwPXZVpAJutMYRb3enPAgEJKKQVq6HeL46eiS1qS5yylIWP6aZBd/Lib Rf3Mjf3Vtv3KJQ/luPGNIVgHrGQ8NzkZc0bJbGUKJxPx/AZtYayJ6y6PAyO0sAc2sT+u5Ksl0Fg oF9waAxr6JJM+2Va2DMLFvPIfbvd28CCdY10r4AAYG+PxfBoSMHctGE6oW8aW67OZBTKUvqox+k O0/Mg/KznETAbfF55G/67iYBn1kx6AgTVgFWfPx2kpYw4FOQMKgsAtTbE1poPK3ei7lprFQ1Izp jZGFbpMwfmozqMqgFTmkDD+KONkqTq0b+Vt4LbOplklaFox5+zonvCShoVYRFJWN38tRpa+yy6e lg7gOv63KhC/jivoKDkXp1FiQZapvk0ygawmp1vF72qBo3xcuW7tO3XZn+SeA9+um7L4S6isF+n 5qtt3SSP24woGDN2h23KOJO0SPd89dxnCBYwiYjarfQZnxsmCRB3ZuFJoK47Msx48c49ejk9Tl3 wp6F3x6Ou17Hr2A== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Davide Caratti RFC8684 suggests use of "Middlebox interference (code 0x06)" in case of fully established subflow that carries data at TCP level with no DSS sub-option. This is generally the case when mpext is NULL or mpext->use_map is 0: use a dedicated value of 'mapping_status' and use it before closing the socket in subflow_check_data_avail(). Link: https://github.com/multipath-tcp/mptcp_net-next/issues/518 Signed-off-by: Davide Caratti Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/subflow.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 860903e0642255cf9efb39da9e24c39f6547481f..07352b15f145832572a4203ab4d0427c37675e94 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -971,7 +971,8 @@ enum mapping_status { MAPPING_EMPTY, MAPPING_DATA_FIN, MAPPING_DUMMY, - MAPPING_BAD_CSUM + MAPPING_BAD_CSUM, + MAPPING_NODSS }; static void dbg_bad_map(struct mptcp_subflow_context *subflow, u32 ssn) @@ -1128,8 +1129,9 @@ static enum mapping_status get_mapping_status(struct sock *ssk, return MAPPING_EMPTY; } + /* If the required DSS has likely been dropped by a middlebox */ if (!subflow->map_valid) - return MAPPING_INVALID; + return MAPPING_NODSS; goto validate_seq; } @@ -1343,7 +1345,7 @@ static bool subflow_check_data_avail(struct sock *ssk) status = get_mapping_status(ssk, msk); trace_subflow_check_data_avail(status, skb_peek(&ssk->sk_receive_queue)); if (unlikely(status == MAPPING_INVALID || status == MAPPING_DUMMY || - status == MAPPING_BAD_CSUM)) + status == MAPPING_BAD_CSUM || status == MAPPING_NODSS)) goto fallback; if (status != MAPPING_OK) @@ -1396,7 +1398,9 @@ static bool subflow_check_data_avail(struct sock *ssk) * subflow_error_report() will introduce the appropriate barriers */ subflow->reset_transient = 0; - subflow->reset_reason = MPTCP_RST_EMPTCP; + subflow->reset_reason = status == MAPPING_NODSS ? + MPTCP_RST_EMIDDLEBOX : + MPTCP_RST_EMPTCP; reset: WRITE_ONCE(ssk->sk_err, EBADMSG);