All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
To: khorenko@virtuozzo.com, vladimir.riabchun@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.2 7/9] ms/mptcp: handle first subflow closing consistently
Date: Thu, 19 Nov 2026 06:35:32 +0200	[thread overview]
Message-ID: <20261119044702.1218722-8-eva.kurchatova@virtuozzo.com> (raw)
In-Reply-To: <20261119044702.1218722-1-eva.kurchatova@virtuozzo.com>

From: Paolo Abeni <pabeni@redhat.com>

Currently, as soon as the PM closes a subflow, the msk stops accepting
data from it, even if the TCP socket could be still formally open in the
incoming direction, with the notable exception of the first subflow.

The root cause of such behavior is that code currently piggy back two
separate semantic on the subflow->disposable bit: the subflow context
must be released and that the subflow must stop accepting incoming
data.

The first subflow is never disposed, so it also never stop accepting
incoming data. Use a separate bit to mark the latter status and set such
bit in __mptcp_close_ssk() for all subflows.

Beyond making per subflow behaviour more consistent this will also
simplify the next patch.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20251121-net-next-mptcp-memcg-backlog-imp-v1-11-1f34b6c1e0b1@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(cherry picked from commit 0eeb372deebce6c25b9afc09e35d6c75a744299a)

Rebase note: close_event_done is a bool outside the bitfield in this
tree, and "ms/mptcp: move the stale logic out of retrans scheduler"
already dropped the stale bit, so __unused goes from 11 to 10 instead
of from 9 to 8.

https://virtuozzo.atlassian.net/browse/VSTOR-155321
Feature: fix ms/net

Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 net/mptcp/protocol.c | 14 +++++++++-----
 net/mptcp/protocol.h |  3 ++-
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 91c47ff3093c..e278f199a200 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -858,10 +858,10 @@ void mptcp_data_ready(struct sock *sk, struct sock *ssk)
 	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
 
 	/* The peer can send data while we are shutting down this
-	 * subflow at msk destruction time, but we must avoid enqueuing
+	 * subflow at subflow destruction time, but we must avoid enqueuing
 	 * more data to the msk receive queue
 	 */
-	if (unlikely(subflow->disposable))
+	if (unlikely(subflow->closing))
 		return;
 
 	mptcp_data_lock(sk);
@@ -2449,6 +2449,13 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
 	struct mptcp_sock *msk = mptcp_sk(sk);
 	bool dispose_it, need_push = false;
 
+	/* Do not pass RX data to the msk, even if the subflow socket is not
+	 * going to be freed (i.e. even for the first subflow on graceful
+	 * subflow close.
+	 */
+	lock_sock_nested(ssk, SINGLE_DEPTH_NESTING);
+	subflow->closing = 1;
+
 	/* If the first subflow moved to a close state before accept, e.g. due
 	 * to an incoming reset or listener shutdown, the subflow socket is
 	 * already deleted by inet_child_forget() and the mptcp socket can't
@@ -2459,7 +2466,6 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
 		/* ensure later check in mptcp_worker() will dispose the msk */
 		sock_set_flag(sk, SOCK_DEAD);
 		mptcp_set_close_tout(sk, tcp_jiffies32 - (mptcp_close_timeout(sk) + 1));
-		lock_sock_nested(ssk, SINGLE_DEPTH_NESTING);
 		mptcp_subflow_drop_ctx(ssk);
 		goto out_release;
 	}
@@ -2468,8 +2474,6 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
 	if (dispose_it)
 		list_del(&subflow->node);
 
-	lock_sock_nested(ssk, SINGLE_DEPTH_NESTING);
-
 	if (subflow->send_fastclose && ssk->sk_state != TCP_CLOSE)
 		tcp_set_state(ssk, TCP_CLOSE);
 
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 214efbf3e788..282176fe111d 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -531,10 +531,11 @@ struct mptcp_subflow_context {
 		send_infinite_map : 1,
 		remote_key_valid : 1,        /* received the peer key from */
 		disposable : 1,	    /* ctx can be free at ulp release time */
+		closing : 1,	    /* must not pass rx data to msk anymore */
 		valid_csum_seen : 1,        /* at least one csum validated */
 		is_mptfo : 1,	    /* subflow is doing TFO */
 		mpc_drop : 1,	    /* the MPC option has been dropped in a rtx */
-		__unused : 11;
+		__unused : 10;
 	bool	data_avail;
 	bool	scheduled;
 	bool	pm_listener;	    /* a listener managed by the kernel PM? */
-- 
2.56.1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  parent reply	other threads:[~2026-11-19  4:49 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  4:35 [Devel] [PATCH hci-8.2 0/9] ms/mptcp: backport fixes for dropped stream segments Eva Kurchatova
2026-11-19  4:35 ` [Devel] [PATCH hci-8.2 1/9] ms/tcp: Save lock_sock() for memcg in inet_csk_accept() Eva Kurchatova
2026-11-19  4:53   ` no-reply
2026-11-19 17:08   ` Konstantin Khorenko
2026-11-19  4:35 ` [Devel] [PATCH hci-8.2 2/9] ms/mptcp: Fix up subflow's memcg when CONFIG_SOCK_CGROUP_DATA=n Eva Kurchatova
2026-11-19  4:52   ` no-reply
2026-11-19 17:08   ` Konstantin Khorenko
2026-11-19  4:35 ` [Devel] [PATCH hci-8.2 3/9] ms/net: factor-out _sk_charge() helper Eva Kurchatova
2026-11-19  4:53   ` no-reply
2026-11-19 17:08   ` Konstantin Khorenko
2026-11-19  4:35 ` [Devel] [PATCH hci-8.2 4/9] ms/mptcp: factor-out cgroup data inherit helper Eva Kurchatova
2026-11-19  4:54   ` no-reply
2026-11-19 17:08   ` Konstantin Khorenko
2026-11-19  4:35 ` [Devel] [PATCH hci-8.2 5/9] ms/mptcp: grafting MPJ subflow earlier Eva Kurchatova
2026-11-19  4:59   ` no-reply
2026-11-19 17:08   ` Konstantin Khorenko
2026-11-19  4:35 ` [Devel] [PATCH hci-8.2 6/9] ms/mptcp: fix memcg accounting for passive sockets Eva Kurchatova
2026-11-19  4:58   ` no-reply
2026-11-19 17:08   ` Konstantin Khorenko
2026-11-19  4:35 ` Eva Kurchatova [this message]
2026-11-19  4:59   ` [Devel] [PATCH hci-8.2 7/9] ms/mptcp: handle first subflow closing consistently no-reply
2026-11-19 17:08   ` Konstantin Khorenko
2026-11-19  4:35 ` [Devel] [PATCH hci-8.2 8/9] ms/mptcp: borrow forward memory from subflow Eva Kurchatova
2026-11-19  5:03   ` no-reply
2026-11-19 17:08   ` Konstantin Khorenko
2026-11-19  4:35 ` [Devel] [PATCH hci-8.2 9/9] ms/mptcp: reclaim forward-allocated memory on RX path errors Eva Kurchatova
2026-11-19  5:01   ` no-reply
2026-11-19 17:08   ` Konstantin Khorenko
2026-11-19 17:08 ` [Devel] [PATCH hci-8.2 0/9] ms/mptcp: backport fixes for dropped stream segments Konstantin Khorenko
2026-11-19 17:08 ` Konstantin Khorenko

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=20261119044702.1218722-8-eva.kurchatova@virtuozzo.com \
    --to=eva.kurchatova@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=khorenko@virtuozzo.com \
    --cc=vladimir.riabchun@virtuozzo.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 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.