On Fri, 2 Dec 2022, Geliang Tang wrote:
> 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 sock_owned_by_me() check and fallback check into get_retrans()
> wrapper from mptcp_subflow_get_retrans().
>
> Signed-off-by: Geliang Tang <geliang.tang@suse.com>
> ---
> net/mptcp/protocol.c | 67 ++++++++++++++++++++++++++------------------
> net/mptcp/sched.c | 6 ++++
> 2 files changed, 45 insertions(+), 28 deletions(-)
>
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index cef6086c7f40..7d7048b0774f 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -2254,11 +2254,6 @@ struct sock *mptcp_subflow_get_retrans(struct mptcp_sock *msk)
> struct mptcp_subflow_context *subflow;
> int min_stale_count = INT_MAX;
>
> - sock_owned_by_me((const struct sock *)msk);
> -
> - if (__mptcp_check_fallback(msk))
> - return NULL;
> -
> mptcp_for_each_subflow(msk, subflow) {
> struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
>
> @@ -2528,16 +2523,17 @@ static void mptcp_check_fastclose(struct mptcp_sock *msk)
> static void __mptcp_retrans(struct sock *sk)
> {
> struct mptcp_sock *msk = mptcp_sk(sk);
> + struct mptcp_subflow_context *subflow;
> struct mptcp_sendmsg_info info = {};
> struct mptcp_data_frag *dfrag;
> - size_t copied = 0;
> struct sock *ssk;
> - int ret;
> + int ret, err;
> + u16 len = 0;
>
> mptcp_clean_una_wakeup(sk);
>
> /* first check ssk: need to kick "stale" logic */
> - ssk = mptcp_subflow_get_retrans(msk);
> + err = mptcp_sched_get_retrans(msk);
> dfrag = mptcp_rtx_head(sk);
> if (!dfrag) {
> if (mptcp_data_fin_enabled(msk)) {
> @@ -2556,31 +2552,46 @@ static void __mptcp_retrans(struct sock *sk)
> goto reset_timer;
> }
>
> - if (!ssk)
> + if (err)
> goto reset_timer;
>
> - lock_sock(ssk);
> + mptcp_for_each_subflow(msk, subflow) {
> + if (READ_ONCE(subflow->scheduled)) {
> + u16 copied = 0;
>
> - /* limit retransmission to the bytes already sent on some subflows */
> - info.sent = 0;
> - info.limit = READ_ONCE(msk->csum_enabled) ? dfrag->data_len : dfrag->already_sent;
> - while (info.sent < info.limit) {
> - ret = mptcp_sendmsg_frag(sk, ssk, dfrag, &info);
> - if (ret <= 0)
> - break;
> + ssk = mptcp_subflow_tcp_sock(subflow);
> + if (!ssk)
> + goto reset_timer;
>
> - MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RETRANSSEGS);
> - copied += ret;
> - info.sent += ret;
> - }
> - if (copied) {
> - dfrag->already_sent = max(dfrag->already_sent, info.sent);
> - tcp_push(ssk, 0, info.mss_now, tcp_sk(ssk)->nonagle,
> - info.size_goal);
> - WRITE_ONCE(msk->allow_infinite_fallback, false);
> - }
> + lock_sock(ssk);
>
> - release_sock(ssk);
> + /* limit retransmission to the bytes already sent on some subflows */
> + info.sent = 0;
> + info.limit = READ_ONCE(msk->csum_enabled) ? dfrag->data_len :
> + dfrag->already_sent;
> + while (info.sent < info.limit) {
> + ret = mptcp_sendmsg_frag(sk, ssk, dfrag, &info);
> + if (ret <= 0)
> + break;
> +
> + MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RETRANSSEGS);
> + copied += ret;
> + info.sent += ret;
> + }
> + if (copied) {
> + len = 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);
> +
> + msk->last_snd = ssk;
> + mptcp_subflow_set_scheduled(subflow, false);
Like patch 2, the scheduled bit should always be cleared (on success and
on error).
- Mat
> + }
> + }
> + dfrag->already_sent = max(dfrag->already_sent, len);
>
> reset_timer:
> mptcp_check_and_set_pending(sk);
> diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c
> index 18518a81afb3..c55f2f1cb7ac 100644
> --- a/net/mptcp/sched.c
> +++ b/net/mptcp/sched.c
> @@ -156,6 +156,12 @@ int mptcp_sched_get_retrans(struct mptcp_sock *msk)
> struct mptcp_subflow_context *subflow;
> struct mptcp_sched_data data;
>
> + sock_owned_by_me((const struct sock *)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;
> --
> 2.35.3
>
>
>
--
Mat Martineau
Intel