From: netdev-bot+sashiko@kernel.org
To: matttbe@kernel.org
Cc: martineau@kernel.org, geliang@kernel.org, davem@davemloft.net,
edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
willemb@google.com, horms@kernel.org, dcaratti@redhat.com,
netdev@vger.kernel.org, mptcp@lists.linux.dev, mason@kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH net 2/9] mptcp: keep an orphan while it can send its data
Date: Thu, 03 Dec 2026 21:51:49 +0000 [thread overview]
Message-ID: <179633470902.3146.5343522154219240904@kernel.org> (raw)
In-Reply-To: <20261202-net-mptcp-misc-fixes-7-4-rc7-v1-2-9f03efcb1a17@kernel.org>
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 1 · Low: 2
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The fix does not cover MPTCP connections that fell back to TCP
(plain TCP peer), so they still get the reset this commit claims to…
- [Medium] Unbounded orphan lifetime controlled by the remote peer
(baseline decision: resolved later in the series).
- [Low] The new timer restart in mptcp_check_send_data_fin() can
overwrite a deliberately backdated close timeout.
- [Low] mptcp_orphan_keep() evaluates `tcp_jiffies32 -
READ_ONCE(tcp_sk(ssk)->rcv_tstamp) < 2 * TCP_RTO_MAX` under the msk…
--
mptcp: keep an orphan while it can send its data
This commit keeps an orphaned MPTCP socket alive past its close timeout
while data is still pending and an active subflow recently received an
ACK. In that case mptcp_worker() re-arms the timeout and pushes the
pending data again, and the close timeout is also restarted when the
DATA_FIN is sent for an orphan.
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/647
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index d6a07fa4b4e4c..82a0cbe38192e 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -2814,6 +2814,28 @@ static bool mptcp_close_tout_expired(const struct sock *sk)
> inet_csk(sk)->icsk_mtup.probe_timestamp + mptcp_close_timeout(sk));
> }
>
> +/* Before its DATA_FIN, keep an orphan while a subflow can send its data */
> +static bool mptcp_orphan_keep(struct sock *sk)
> +{
> + struct mptcp_sock *msk = mptcp_sk(sk);
> + struct mptcp_subflow_context *subflow;
> +
> + if (!sock_flag(sk, SOCK_DEAD) || msk->snd_nxt == msk->write_seq)
> + return false;
[Severity: High]
Does this cover connections that fell back to plain TCP? The
snd_nxt == write_seq check only counts data still queued at the MPTCP
level. It does not count data that is already in the subflow's TCP
write queue but has not been sent.
On fallback, mptcp_check_allowed_size() doesn't apply the peer window:
net/mptcp/protocol.c:mptcp_check_allowed_size() {
...
if (__mptcp_check_fallback(msk))
return avail_size;
...
}
So the whole tail can move into msk->first as soon as it fits in the
subflow sndbuf, even while the peer window is closed.
__mptcp_push_pending() then calls mptcp_check_send_data_fin(). That
sets snd_nxt = write_seq, restarts the close timeout (the new code
further below) and calls mptcp_subflow_shutdown(). On fallback, that
queues the TCP FIN behind the undelivered data and simulates the
DATA_FIN ack:
net/mptcp/protocol.c:mptcp_subflow_shutdown() {
...
if (__mptcp_check_fallback(mptcp_sk(sk))) {
pr_debug("Fallback\n");
ssk->sk_shutdown |= how;
tcp_shutdown(ssk, how);
...
WRITE_ONCE(mptcp_sk(sk)->snd_una, mptcp_sk(sk)->snd_nxt);
...
}
>From then on, mptcp_orphan_keep() can never return true. When the
restarted TCP_TIMEWAIT_LEN expires:
mptcp_worker()
mptcp_do_fastclose() /* sets fastclosing, returns early on fallback */
__mptcp_close_ssk(sk, ssk, subflow, 0)
__mptcp_subflow_disconnect(ssk, subflow, fastclosing)
tcp_disconnect(ssk, 0) /* RST, write queue purged */
Take an MPTCP server with a plain TCP client. The server writes data
that fits in the subflow sndbuf, then calls close(), and the client
pauses for more than 60 seconds. Would the client still get ECONNRESET
and lose the tail?
That is the symptom the commit message describes as fixed ("TCP
delivered everything, as MPTCP now does"). The same logic is still
there at the end of the series.
Should the keep check also account for data queued in the subflows on
fallback, or should fallback orphans be left to TCP's orphan handling?
> +
> + mptcp_for_each_subflow(msk, subflow) {
> + struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
> +
> + /* a live peer acks at least the probes, every TCP_RTO_MAX */
> + if (__mptcp_subflow_active(subflow) &&
> + tcp_jiffies32 - READ_ONCE(tcp_sk(ssk)->rcv_tstamp) <
> + 2 * TCP_RTO_MAX)
> + return true;
[Severity: Low]
Can this unsigned subtraction underflow? tcp_ack() writes
tp->rcv_tstamp in softirq, under the subflow lock:
tp->rcv_tstamp = tcp_jiffies32;
This check runs under the msk socket lock only, and the order of the
two loads here is unspecified. Consider this sequence:
- the worker loads tcp_jiffies32 (T)
- jiffies ticks
- another CPU processes an ACK and stores rcv_tstamp = T + 1
- the worker loads rcv_tstamp
The difference is then 0xffffffff, so a subflow that has just received
an ACK is treated as not live. If it is the only active subflow, the
orphan is fastclosed.
Would taking a single tcp_jiffies32 snapshot and using a signed
comparison avoid this? mptcp_close_tout_expired() just above already
uses time_after32().
> + }
> +
> + return false;
> +}
> +
[ ... ]
> @@ -3151,6 +3173,11 @@ static void mptcp_worker(struct work_struct *work)
> if (test_and_clear_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags))
> __mptcp_close_subflow(sk);
>
> + if (mptcp_close_tout_expired(sk) && mptcp_orphan_keep(sk)) {
> + mptcp_start_tout_timer(sk);
> + __mptcp_push_pending(sk, 0);
> + }
[Severity: Medium]
With only this patch applied, what limits how long an orphan can be
kept? Each time the close timeout expires, it is re-armed here as long
as these hold:
- snd_nxt != write_seq
- an active subflow got any ACK within 2 * TCP_RTO_MAX
There is no cap, no orphan count check and no memory pressure check.
A peer that advertises a zero window and acks the probes could keep
the msk and its send buffers pinned forever. The commit message notes
that "nothing limits how long the peer can keep its window closed".
The TCP orphan limits in tcp_probe_timer() (tcp_orphan_retries() and
tcp_out_of_resources()) don't apply, because the subflows are not
SOCK_DEAD. __mptcp_close() also doesn't count MPTCP orphans in
tcp_orphan_count.
This seems to be fixed later in the series:
- "mptcp: limit an orphan probing a zero window" adds
mptcp_subflow_probe_timed_out()
- "mptcp: count orphans as TCP does" adds tcp_orphan_count_inc() and
mptcp_orphan_oom()
Since this patch has Cc: stable, could it be backported without those
follow-ups?
> if (mptcp_close_tout_expired(sk)) {
> struct mptcp_subflow_context *subflow, *tmp;
>
[ ... ]
> @@ -3392,6 +3419,10 @@ static void mptcp_check_send_data_fin(struct sock *sk)
>
> WRITE_ONCE(msk->snd_nxt, msk->write_seq);
>
> + /* an orphan's close timeout is for the DATA_FIN exchange */
> + if (sock_flag(sk, SOCK_DEAD))
> + mptcp_start_tout_timer(sk);
[Severity: Low]
Can this restart overwrite a close timeout that was backdated on
purpose? When the last subflow of an orphan is closed while msk->first
is already in TCP_CLOSE, __mptcp_close_ssk() does:
if (sock_flag(sk, SOCK_DEAD)) {
/* let the worker close and destroy the orphan */
mptcp_set_close_tout(sk, tcp_jiffies32 -
(mptcp_close_timeout(sk) + 1));
mptcp_schedule_work(sk);
There are two ways this can run before mptcp_check_send_data_fin():
- inside mptcp_worker() itself, earlier in the same run, via
mptcp_pm_worker()->mptcp_pm_rm_addr_recv()->
mptcp_pm_rm_addr_or_subflow()->mptcp_close_ssk()
- from netlink PM paths such as mptcp_pm_nl_subflow_destroy_doit(),
before the worker runs
A DATA_FIN may still be pending at that point. For example,
__mptcp_subflow_push_pending() pushed the last data and only scheduled
the worker, and all the data was DATA_ACKed. In that case, the new
mptcp_start_tout_timer() call resets probe_timestamp to now. Then
mptcp_close_tout_expired() is false and the state is not TCP_CLOSE, so
__mptcp_destroy_sock() is skipped.
Would the orphan then stay around for another TCP_TIMEWAIT_LEN with no
usable subflow, instead of being destroyed in this worker run as it
was before? This code is unchanged at the end of the series.
> +
> mptcp_for_each_subflow(msk, subflow) {
> struct sock *tcp_sk = mptcp_subflow_tcp_sock(subflow);
>
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202-net-mptcp-misc-fixes-7-4-rc7-v1-0-9f03efcb1a17%40kernel.org
next prev parent reply other threads:[~2026-12-03 21:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 21:29 [PATCH net 0/9] mptcp: misc fixes for v7.4-rc7 Matthieu Baerts (NGI0)
2026-12-02 21:29 ` [PATCH net 1/9] mptcp: pm: kernel: c-flag: keep local_addr_used in sync Matthieu Baerts (NGI0)
2026-12-02 21:29 ` [PATCH net 2/9] mptcp: keep an orphan while it can send its data Matthieu Baerts (NGI0)
2026-12-03 21:51 ` netdev-bot+sashiko [this message]
2026-12-02 21:29 ` [PATCH net 3/9] mptcp: limit an orphan probing a zero window Matthieu Baerts (NGI0)
2026-12-03 21:51 ` netdev-bot+sashiko
2026-12-02 21:29 ` [PATCH net 4/9] mptcp: count orphans as TCP does Matthieu Baerts (NGI0)
2026-12-03 21:51 ` netdev-bot+sashiko
2026-12-02 21:29 ` [PATCH net 5/9] mptcp: return EOF after a DATA_FIN, " Matthieu Baerts (NGI0)
2026-12-03 21:51 ` netdev-bot+sashiko
2026-12-02 21:29 ` [PATCH net 6/9] mptcp: wake up blocked senders when no sf left Matthieu Baerts (NGI0)
2026-12-03 21:51 ` netdev-bot+sashiko
2026-12-02 21:29 ` [PATCH net 7/9] mptcp: reclaim forward memory after coalescing skbs Matthieu Baerts (NGI0)
2026-12-03 21:51 ` netdev-bot+sashiko
2026-12-02 21:29 ` [PATCH net 8/9] mptcp: don't charge a shared page twice at accept() Matthieu Baerts (NGI0)
2026-12-02 21:29 ` [PATCH net 9/9] mptcp: don't charge the backlog " Matthieu Baerts (NGI0)
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=179633470902.3146.5343522154219240904@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=davem@davemloft.net \
--cc=dcaratti@redhat.com \
--cc=edumazet@kernel.org \
--cc=geliang@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=martineau@kernel.org \
--cc=mason@kernel.org \
--cc=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
--cc=willemb@google.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox