All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH mptcp-net 0/4] mptcp: a few fixes
@ 2026-08-12 17:08 Paolo Abeni
  2026-08-12 17:08 ` [PATCH mptcp-net 1/4] mptcp: being below memory limit is a likely() condition Paolo Abeni
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Paolo Abeni @ 2026-08-12 17:08 UTC (permalink / raw)
  To: mptcp

This is mostly a follow-up to the recent OoO queue pruning series.
Explicitly targeting net as we have already a lot of patches pending for
net-next, and no need to rush IMHO.

First 2 patches addresses explicit comments from sashiko, 3rd one is a
somewhat unrelated cleanup I stumbled upon while implementing patch 4.

The last patch fixes another thing implided by sashiko while reviewing
the mentioned series.

Paolo Abeni (4):
  mptcp: being below memory limit is a likely() condition
  mptcp: avoid pruning for OoW data
  mptcp: remove unneeded READ_ONCE() annotation
  mptcp: do not reschedule the RTX timer for fallback sockets

 net/mptcp/options.c  |  4 ++--
 net/mptcp/protocol.c | 27 ++++++++++++++++-----------
 net/mptcp/protocol.h |  1 +
 3 files changed, 19 insertions(+), 13 deletions(-)

-- 
2.55.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH mptcp-net 1/4] mptcp: being below memory limit is a likely() condition
  2026-08-12 17:08 [PATCH mptcp-net 0/4] mptcp: a few fixes Paolo Abeni
@ 2026-08-12 17:08 ` Paolo Abeni
  2026-08-12 17:08 ` [PATCH mptcp-net 2/4] mptcp: avoid pruning for OoW data Paolo Abeni
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Paolo Abeni @ 2026-08-12 17:08 UTC (permalink / raw)
  To: mptcp

The current compiler hint annotation is wrong, due to inverted
logic in the previous revision of the relevant code.

Fixes: e468d371180d ("mptcp: implemented OoO queue pruning")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/mptcp/protocol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 68d766c0206e..f879b1061f2d 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -289,7 +289,7 @@ static void mptcp_prune_ofo_queue(struct sock *sk,
  */
 static bool mptcp_can_ingest(const struct sock *sk)
 {
-	return unlikely(sk_rmem_alloc_get(sk) <= READ_ONCE(sk->sk_rcvbuf)) ||
+	return likely(sk_rmem_alloc_get(sk) <= READ_ONCE(sk->sk_rcvbuf)) ||
 	       __mptcp_check_fallback(mptcp_sk(sk));
 }
 
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH mptcp-net 2/4] mptcp: avoid pruning for OoW data
  2026-08-12 17:08 [PATCH mptcp-net 0/4] mptcp: a few fixes Paolo Abeni
  2026-08-12 17:08 ` [PATCH mptcp-net 1/4] mptcp: being below memory limit is a likely() condition Paolo Abeni
@ 2026-08-12 17:08 ` Paolo Abeni
  2026-08-12 17:08 ` [PATCH mptcp-net 3/4] mptcp: remove unneeded READ_ONCE() annotation Paolo Abeni
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Paolo Abeni @ 2026-08-12 17:08 UTC (permalink / raw)
  To: mptcp

Pruning is expansive and destructive, do it only when we expect
to accept the skb triggering the cleanup.

Fixes: e468d371180d ("mptcp: implemented OoO queue pruning")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/mptcp/protocol.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index f879b1061f2d..2ee23e9411be 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -313,12 +313,6 @@ static void mptcp_data_queue_ofo(struct mptcp_sock *msk, struct sk_buff *skb)
 	u64 seq, end_seq, max_seq;
 	struct sk_buff *skb1;
 
-	if (!mptcp_try_rmem_schedule(sk, skb)) {
-		MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RCVPRUNED);
-		mptcp_drop(sk, skb);
-		return;
-	}
-
 	seq = MPTCP_SKB_CB(skb)->map_seq;
 	end_seq = MPTCP_SKB_CB(skb)->end_seq;
 	max_seq = atomic64_read(&msk->rcv_wnd_sent);
@@ -335,6 +329,12 @@ static void mptcp_data_queue_ofo(struct mptcp_sock *msk, struct sk_buff *skb)
 		return;
 	}
 
+	if (!mptcp_try_rmem_schedule(sk, skb)) {
+		MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RCVPRUNED);
+		mptcp_drop(sk, skb);
+		return;
+	}
+
 	p = &msk->out_of_order_queue.rb_node;
 	MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_OFOQUEUE);
 	if (RB_EMPTY_ROOT(&msk->out_of_order_queue)) {
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH mptcp-net 3/4] mptcp: remove unneeded READ_ONCE() annotation
  2026-08-12 17:08 [PATCH mptcp-net 0/4] mptcp: a few fixes Paolo Abeni
  2026-08-12 17:08 ` [PATCH mptcp-net 1/4] mptcp: being below memory limit is a likely() condition Paolo Abeni
  2026-08-12 17:08 ` [PATCH mptcp-net 2/4] mptcp: avoid pruning for OoW data Paolo Abeni
@ 2026-08-12 17:08 ` Paolo Abeni
  2026-08-12 17:08 ` [PATCH mptcp-net 4/4] mptcp: do not reschedule the RTX timer for fallback sockets Paolo Abeni
  2026-08-12 20:54 ` [PATCH mptcp-net 0/4] mptcp: a few fixes Matthieu Baerts
  4 siblings, 0 replies; 6+ messages in thread
From: Paolo Abeni @ 2026-08-12 17:08 UTC (permalink / raw)
  To: mptcp

The subflow->fully_established flag is always written under the subflow
socket lock. Reading such value under the same lock does not require any
ONCE annotation.

Fixes: 581c8cbfa934 ("mptcp: annotate data-races around subflow->fully_established")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/mptcp/options.c  | 4 ++--
 net/mptcp/protocol.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index 97da22668dbe..11bad5670d06 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -529,7 +529,7 @@ static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb,
 		return false;
 
 	/* MPC/MPJ needed only on 3rd ack packet, DATA_FIN and TCP shutdown take precedence */
-	if (READ_ONCE(subflow->fully_established) || snd_data_fin_enable ||
+	if (subflow->fully_established || snd_data_fin_enable ||
 	    subflow->snd_isn != TCP_SKB_CB(skb)->seq ||
 	    sk->sk_state != TCP_ESTABLISHED)
 		return false;
@@ -980,7 +980,7 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk,
 	/* here we can process OoO, in-window pkts, only in-sequence 4th ack
 	 * will make the subflow fully established
 	 */
-	if (likely(READ_ONCE(subflow->fully_established))) {
+	if (likely(subflow->fully_established)) {
 		/* on passive sockets, check for 3rd ack retransmission
 		 * note that msk is always set by subflow_syn_recv_sock()
 		 * for mp_join subflows
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 2ee23e9411be..b311fe30c785 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -3912,7 +3912,7 @@ static void schedule_3rdack_retransmission(struct sock *ssk)
 	struct tcp_sock *tp = tcp_sk(ssk);
 	unsigned long timeout;
 
-	if (READ_ONCE(mptcp_subflow_ctx(ssk)->fully_established))
+	if (mptcp_subflow_ctx(ssk)->fully_established)
 		return;
 
 	/* reschedule with a timeout above RTT, as we must look only for drop */
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH mptcp-net 4/4] mptcp: do not reschedule the RTX timer for fallback sockets
  2026-08-12 17:08 [PATCH mptcp-net 0/4] mptcp: a few fixes Paolo Abeni
                   ` (2 preceding siblings ...)
  2026-08-12 17:08 ` [PATCH mptcp-net 3/4] mptcp: remove unneeded READ_ONCE() annotation Paolo Abeni
@ 2026-08-12 17:08 ` Paolo Abeni
  2026-08-12 20:54 ` [PATCH mptcp-net 0/4] mptcp: a few fixes Matthieu Baerts
  4 siblings, 0 replies; 6+ messages in thread
From: Paolo Abeni @ 2026-08-12 17:08 UTC (permalink / raw)
  To: mptcp

On fallback socket the retrans timer is a quite convoluted no-op, but
currently nothing prevents the MPTCP core to keep rescheduling it.

Additionally gate RTX timer reset to the msk not being fallen back to
TCP yet. To avoid adding multiple tests in fast-path, use a new flags
bit for such condition.

Fixes: b51f9b80c032 ("mptcp: introduce MPTCP retransmission timer")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
In fact so convoluted that sashiko thinks otherwise. Sashiko:
in case of fallback there could be a single active subflow; it can't
become stale
---
 net/mptcp/protocol.c | 11 ++++++++---
 net/mptcp/protocol.h |  1 +
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index b311fe30c785..f22d64ab1c53 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -96,6 +96,7 @@ bool __mptcp_try_fallback(struct mptcp_sock *msk, int fb_mib)
 
 	msk->allow_subflows = false;
 	set_bit(MPTCP_FALLBACK_DONE, &msk->flags);
+	set_bit(MPTCP_RTX_DISABLED, &msk->flags);
 	__MPTCP_INC_STATS(net, fb_mib);
 	spin_unlock_bh(&msk->fallback_lock);
 	return true;
@@ -1121,13 +1122,14 @@ static bool mptcp_rtx_timer_pending(struct sock *sk)
 
 static void mptcp_reset_rtx_timer(struct sock *sk)
 {
+	struct mptcp_sock *msk = mptcp_sk(sk);
 	unsigned long tout;
 
-	/* prevent rescheduling on close */
-	if (unlikely(inet_sk_state_load(sk) == TCP_CLOSE))
+	/* Prevent rescheduling on close and in case of fallback. */
+	if (test_bit(MPTCP_RTX_DISABLED, &msk->flags))
 		return;
 
-	tout = mptcp_sk(sk)->timer_ival;
+	tout = msk->timer_ival;
 	sk_reset_timer(sk, &sk->mptcp_retransmit_timer, jiffies + tout);
 }
 
@@ -3360,6 +3362,9 @@ void mptcp_set_state(struct sock *sk, int state)
 		 * transition from TCP_SYN_RECV to TCP_CLOSE_WAIT.
 		 */
 		break;
+	case TCP_CLOSE:
+		set_bit(MPTCP_RTX_DISABLED, &mptcp_sk(sk)->flags);
+		fallthrough;
 	default:
 		if (oldstate == TCP_ESTABLISHED || oldstate == TCP_CLOSE_WAIT)
 			MPTCP_DEC_STATS(sock_net(sk), MPTCP_MIB_CURRESTAB);
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 7e168e450fb0..f9300d644ff3 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -116,6 +116,7 @@
 #define MPTCP_WORK_RTX		1
 #define MPTCP_FALLBACK_DONE	2
 #define MPTCP_WORK_CLOSE_SUBFLOW 3
+#define MPTCP_RTX_DISABLED	4
 
 /* MPTCP socket release cb flags */
 #define MPTCP_PUSH_PENDING	1
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH mptcp-net 0/4] mptcp: a few fixes
  2026-08-12 17:08 [PATCH mptcp-net 0/4] mptcp: a few fixes Paolo Abeni
                   ` (3 preceding siblings ...)
  2026-08-12 17:08 ` [PATCH mptcp-net 4/4] mptcp: do not reschedule the RTX timer for fallback sockets Paolo Abeni
@ 2026-08-12 20:54 ` Matthieu Baerts
  4 siblings, 0 replies; 6+ messages in thread
From: Matthieu Baerts @ 2026-08-12 20:54 UTC (permalink / raw)
  To: Paolo Abeni; +Cc: mptcp

Hi Paolo,

Thank you for the fixes!

12 Aug 2026 19:08:30 Paolo Abeni <pabeni@redhat.com>:

> This is mostly a follow-up to the recent OoO queue pruning series.
> Explicitly targeting net as we have already a lot of patches pending for
> net-next, and no need to rush IMHO.

(I hope it was OK for me to send a few small cleanup patches)

> First 2 patches addresses explicit comments from sashiko, 3rd one is a
> somewhat unrelated cleanup I stumbled upon while implementing patch 4.
>
> The last patch fixes another thing implided by sashiko while reviewing
> the mentioned series.

When reading this, it sounds like there should be 5 patches but only 4
have been shared. Just to be sure: is everything there?

Cheers,
Matt

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-08-12 20:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-12 17:08 [PATCH mptcp-net 0/4] mptcp: a few fixes Paolo Abeni
2026-08-12 17:08 ` [PATCH mptcp-net 1/4] mptcp: being below memory limit is a likely() condition Paolo Abeni
2026-08-12 17:08 ` [PATCH mptcp-net 2/4] mptcp: avoid pruning for OoW data Paolo Abeni
2026-08-12 17:08 ` [PATCH mptcp-net 3/4] mptcp: remove unneeded READ_ONCE() annotation Paolo Abeni
2026-08-12 17:08 ` [PATCH mptcp-net 4/4] mptcp: do not reschedule the RTX timer for fallback sockets Paolo Abeni
2026-08-12 20:54 ` [PATCH mptcp-net 0/4] mptcp: a few fixes Matthieu Baerts

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.