From nobody Sat Dec 21 13:11:36 2024 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 6CA4C1BB32; Mon, 21 Aug 2023 22:25:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72BDDC43395; Mon, 21 Aug 2023 22:25:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692656724; bh=Miq3TLRI/pTEoF1BRBHAq+glR+w1Dr/v8PRF9aArIpk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=bMj7gzI37ZuRwKhK9iobu3o5mAacB7hXDB/EIVIC3Y2xpDx8M8yp8KKmPnl7PbVyw bZrY3tk8cRfzYKVfTZquRhQ/trkLXGkyHDeY34AYOQy3xnDPA9QP6Pebc1wvmP9tfn Q7mEmAKqdbKDtk2vwPav8ChniRM55RyKj9cI4tsKeHDp/9FkzSCjKKCuQQHcqDFndI foFB5FpebIU6feZfbo1JgZE2Cm0xLnNGBzPN2vfB7F5pUmiYFI+SyQ9WqOXEdyBdGJ JFlyZnCKwbw/z9a/SHFOO4X+XSe/cZ3qtV0l+0tRvE+MxFmO5SSkS9LBdRUxOZV9OE JS9e6GK501uyg== From: Mat Martineau Date: Mon, 21 Aug 2023 15:25:20 -0700 Subject: [PATCH net-next 09/10] mptcp: use get_retrans wrapper 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: <20230821-upstream-net-next-20230818-v1-9-0c860fb256a8@kernel.org> References: <20230821-upstream-net-next-20230818-v1-0-0c860fb256a8@kernel.org> In-Reply-To: <20230821-upstream-net-next-20230818-v1-0-0c860fb256a8@kernel.org> To: Matthieu Baerts , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, Geliang Tang , Mat Martineau X-Mailer: b4 0.12.3 From: Geliang Tang This patch adds the multiple subflows support for __mptcp_retrans(). Use get_retrans() wrapper instead of mptcp_subflow_get_retrans() in it. Check the subflow scheduled flags to test which subflow or subflows are picked by the scheduler, use them to send data. Move msk_owned_by_me() and fallback checks into get_retrans() wrapper from mptcp_subflow_get_retrans(). Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang Signed-off-by: Mat Martineau --- net/mptcp/protocol.c | 65 ++++++++++++++++++++++++++++++------------------= ---- net/mptcp/sched.c | 6 +++++ 2 files changed, 43 insertions(+), 28 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 77e94ee82859..61590ff2b9ee 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2233,11 +2233,6 @@ struct sock *mptcp_subflow_get_retrans(struct mptcp_= sock *msk) struct mptcp_subflow_context *subflow; int min_stale_count =3D INT_MAX; =20 - msk_owned_by_me(msk); - - if (__mptcp_check_fallback(msk)) - return NULL; - mptcp_for_each_subflow(msk, subflow) { struct sock *ssk =3D mptcp_subflow_tcp_sock(subflow); =20 @@ -2515,16 +2510,17 @@ static void mptcp_check_fastclose(struct mptcp_sock= *msk) static void __mptcp_retrans(struct sock *sk) { struct mptcp_sock *msk =3D mptcp_sk(sk); + struct mptcp_subflow_context *subflow; struct mptcp_sendmsg_info info =3D {}; struct mptcp_data_frag *dfrag; - size_t copied =3D 0; struct sock *ssk; - int ret; + int ret, err; + u16 len =3D 0; =20 mptcp_clean_una_wakeup(sk); =20 /* first check ssk: need to kick "stale" logic */ - ssk =3D mptcp_subflow_get_retrans(msk); + err =3D mptcp_sched_get_retrans(msk); dfrag =3D mptcp_rtx_head(sk); if (!dfrag) { if (mptcp_data_fin_enabled(msk)) { @@ -2543,32 +2539,45 @@ static void __mptcp_retrans(struct sock *sk) goto reset_timer; } =20 - if (!ssk) + if (err) goto reset_timer; =20 - lock_sock(ssk); + mptcp_for_each_subflow(msk, subflow) { + if (READ_ONCE(subflow->scheduled)) { + u16 copied =3D 0; =20 - /* limit retransmission to the bytes already sent on some subflows */ - info.sent =3D 0; - info.limit =3D READ_ONCE(msk->csum_enabled) ? dfrag->data_len : dfrag->al= ready_sent; - while (info.sent < info.limit) { - ret =3D mptcp_sendmsg_frag(sk, ssk, dfrag, &info); - if (ret <=3D 0) - break; + mptcp_subflow_set_scheduled(subflow, false); =20 - MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RETRANSSEGS); - copied +=3D ret; - info.sent +=3D ret; - } - if (copied) { - dfrag->already_sent =3D max(dfrag->already_sent, info.sent); - msk->bytes_retrans +=3D copied; - tcp_push(ssk, 0, info.mss_now, tcp_sk(ssk)->nonagle, - info.size_goal); - WRITE_ONCE(msk->allow_infinite_fallback, false); + ssk =3D mptcp_subflow_tcp_sock(subflow); + + lock_sock(ssk); + + /* limit retransmission to the bytes already sent on some subflows */ + info.sent =3D 0; + info.limit =3D READ_ONCE(msk->csum_enabled) ? dfrag->data_len : + dfrag->already_sent; + while (info.sent < info.limit) { + ret =3D mptcp_sendmsg_frag(sk, ssk, dfrag, &info); + if (ret <=3D 0) + break; + + MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RETRANSSEGS); + copied +=3D ret; + info.sent +=3D ret; + } + if (copied) { + len =3D max(copied, len); + tcp_push(ssk, 0, info.mss_now, tcp_sk(ssk)->nonagle, + info.size_goal); + WRITE_ONCE(msk->allow_infinite_fallback, false); + } + + release_sock(ssk); + } } =20 - release_sock(ssk); + msk->bytes_retrans +=3D len; + dfrag->already_sent =3D max(dfrag->already_sent, len); =20 reset_timer: mptcp_check_and_set_pending(sk); diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c index 078b5d44978d..cac1cc1fa3b0 100644 --- a/net/mptcp/sched.c +++ b/net/mptcp/sched.c @@ -136,6 +136,12 @@ int mptcp_sched_get_retrans(struct mptcp_sock *msk) struct mptcp_subflow_context *subflow; struct mptcp_sched_data data; =20 + msk_owned_by_me(msk); + + /* the following check is moved out of mptcp_subflow_get_retrans */ + if (__mptcp_check_fallback(msk)) + return -EINVAL; + mptcp_for_each_subflow(msk, subflow) { if (READ_ONCE(subflow->scheduled)) return 0; --=20 2.41.0