All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH net 6/7] mptcp: don't send a FIN before the pending data on fallback
Date: Tue, 17 Nov 2026 22:09:16 +0000	[thread overview]
Message-ID: <sashiko-outbox-219732@kernel.org> (raw)
In-Reply-To: <20261116-net-mptcp-misc-fixes-7-4-rc4-v1-6-bf7656de653e@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] mptcp: unadvanced snd_nxt in mptcp_try_fallback() with
  reinjected data
- [Medium] mptcp: missing pending data push after fallback in
  subflow_check_data_avail()
--

commit 7f5ccb63dcef4623a742b8e41a51358adb229738
Author: Matthieu Baerts (NGI0) <matttbe@kernel.org>

mptcp: don't send a FIN before the pending data on fallback

This commit avoids shutting down the subflow at fallback time when unsent
data is still pending in the MPTCP write queue, so that a TCP FIN is not
sent before the pending data.

> diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
> index 011e73d04ee60..7d226ee38315d 100644
> --- a/net/mptcp/protocol.h
> +++ b/net/mptcp/protocol.h
> @@ -1333,7 +1333,11 @@ static inline bool mptcp_try_fallback(struct sock *ssk, int fb_mib)
>  	msk = mptcp_sk(sk);
>  	if (!__mptcp_try_fallback(msk, fb_mib))
>  		return false;
> -	if (READ_ONCE(msk->snd_data_fin_enable) && !(ssk->sk_shutdown & SEND_SHUTDOWN)) {
> +
> +	/* no FIN before new data: see mptcp_check_send_data_fin() */
> +	if (READ_ONCE(msk->snd_data_fin_enable) &&
> +	    !before64(READ_ONCE(msk->snd_nxt) + 1, READ_ONCE(msk->write_seq)) &&
> +	    !(ssk->sk_shutdown & SEND_SHUTDOWN)) {
>  		gfp_t saved_allocation = ssk->sk_allocation;
>  
>  		/* we are in a atomic (BH) scope, override ssk default for data

[Severity: Medium]
Can mptcp_try_fallback() leave msk->snd_nxt at msk->write_seq - 1 when
reinjected data is still in msk->first_pending?

If an unjoined additional subflow closes and __mptcp_close_ssk() calls
__mptcp_retransmit_pending_data(), msk->first_pending is reset while
msk->snd_nxt stays at msk->write_seq.  If the application then shuts down
the write side before the initial subflow re-pushes that reinjected data,
__mptcp_wr_shutdown() increments msk->write_seq by 1, and
mptcp_check_send_data_fin() returns early without advancing msk->snd_nxt:

net/mptcp/protocol.c:mptcp_check_send_data_fin() {
	if (!msk->snd_data_fin_enable || msk->snd_nxt + 1 != msk->write_seq ||
	    mptcp_send_head(sk))
		return;

	WRITE_ONCE(msk->snd_nxt, msk->write_seq);
    ...
}

When mptcp_try_fallback() runs next, msk->snd_nxt + 1 == msk->write_seq
holds, so it sets SEND_SHUTDOWN on ssk without advancing msk->snd_nxt to
msk->write_seq.  Setting SEND_SHUTDOWN stops __subflow_push_pending() from
pushing the reinjected data and calling mptcp_check_send_data_fin().  On
subsequent packets, mptcp_incoming_options() only advances msk->snd_una to
READ_ONCE(msk->snd_nxt) (msk->write_seq - 1), so
mptcp_pending_data_fin_ack() never sees msk->snd_una == msk->write_seq and
a half-closed MPTCP socket stays stuck in TCP_FIN_WAIT1.

[Severity: Medium]
Does skipping tcp_shutdown() here stall connection termination when
fallback is triggered after the handshake in subflow_check_data_avail() or
mptcp_dss_corruption()?

When unsent data is queued and the socket has been shut down,
mptcp_try_fallback() now defers the FIN, relying on the caller to push the
pending data so mptcp_check_send_data_fin() can send the FIN afterward.
Unlike check_fully_established(), subflow_check_data_avail() and
mptcp_dss_corruption() run after mptcp_incoming_options() has already
finished (and returned early when OPTION_MPTCP_DSS was absent), and neither
calls __mptcp_check_push() after mptcp_try_fallback():

net/mptcp/subflow.c:subflow_check_data_avail() {
    ...
		if (!mptcp_try_fallback(ssk, MPTCP_MIB_DSSFALLBACK)) {
			/* fatal protocol error, close the socket */
			subflow->reset_transient = 0;
			subflow->reset_reason = MPTCP_RST_EMPTCP;
			goto reset;
		}
    ...
}

If the head of msk->rtx_queue also has unacknowledged already-sent data,
__mptcp_retrans() sees the fallback in __mptcp_push_retrans() and jumps to
clear_scheduled without calling mptcp_check_and_set_pending(sk).  If the
peer sends no more packets, the pending data and the deferred FIN are never
transmitted.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261116-net-mptcp-misc-fixes-7-4-rc4-v1-0-bf7656de653e@kernel.org?part=6

  reply	other threads:[~2026-11-17 22:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 22:06 [PATCH net 0/7] mptcp: misc fixes for v7.4-rc4 Matthieu Baerts (NGI0)
2026-11-16 22:06 ` [PATCH net 1/7] mptcp: do not use a raised snd_wnd for the send window Matthieu Baerts (NGI0)
2026-11-16 22:06 ` [PATCH net 2/7] mptcp: push pending data after a sendmsg copy fault Matthieu Baerts (NGI0)
2026-11-17 22:09   ` sashiko-bot
2026-11-17 22:29   ` netdev-bot+sashiko
2026-11-16 22:06 ` [PATCH net 3/7] mptcp: use sk instead of casting msk in check_fully_established() Matthieu Baerts (NGI0)
2026-11-16 22:06 ` [PATCH net 4/7] mptcp: push queued data on passive TFO subflows becoming established Matthieu Baerts (NGI0)
2026-11-17 22:29   ` netdev-bot+sashiko
2026-11-16 22:06 ` [PATCH net 5/7] mptcp: push queued data on subflows falling back at the handshake Matthieu Baerts (NGI0)
2026-11-17 22:09   ` sashiko-bot
2026-11-17 22:29   ` netdev-bot+sashiko
2026-11-16 22:06 ` [PATCH net 6/7] mptcp: don't send a FIN before the pending data on fallback Matthieu Baerts (NGI0)
2026-11-17 22:09   ` sashiko-bot [this message]
2026-11-17 22:29   ` netdev-bot+sashiko
2026-11-16 22:06 ` [PATCH net 7/7] mptcp: fix dummy mapping of overlapping segments Matthieu Baerts (NGI0)
2026-11-17 22:29   ` netdev-bot+sashiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-219732@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=matttbe@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.