All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
To: mptcp@lists.linux.dev, Mat Martineau <martineau@kernel.org>,
	 Geliang Tang <geliang@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	 Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>, Florian Westphal <fw@strlen.de>,
	 Kishen Maloor <kishen.maloor@intel.com>,
	Shuah Khan <shuah@kernel.org>,
	 Peter Krystad <peter.krystad@linux.intel.com>,
	 Christoph Paasch <cpaasch@apple.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-kselftest@vger.kernel.org,
	 "Matthieu Baerts (NGI0)" <matttbe@kernel.org>,
	stable@vger.kernel.org
Subject: [PATCH net 06/10] mptcp: fix potential wake-up event loss
Date: Fri, 23 Feb 2024 17:14:16 +0100	[thread overview]
Message-ID: <20240223-upstream-net-20240223-misc-fixes-v1-6-162e87e48497@kernel.org> (raw)
In-Reply-To: <20240223-upstream-net-20240223-misc-fixes-v1-0-162e87e48497@kernel.org>

From: Paolo Abeni <pabeni@redhat.com>

After the blamed commit below, the send buffer auto-tuning can
happen after that the mptcp_propagate_sndbuf() completes - via
the delegated action infrastructure.

We must check for write space even after such change or we risk
missing the wake-up event.

Fixes: 8005184fd1ca ("mptcp: refactor sndbuf auto-tuning")
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/protocol.h | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 631a7f445f34..07f6242afc1a 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -790,6 +790,16 @@ static inline bool mptcp_data_fin_enabled(const struct mptcp_sock *msk)
 	       READ_ONCE(msk->write_seq) == READ_ONCE(msk->snd_nxt);
 }
 
+static inline void mptcp_write_space(struct sock *sk)
+{
+	if (sk_stream_is_writeable(sk)) {
+		/* pairs with memory barrier in mptcp_poll */
+		smp_mb();
+		if (test_and_clear_bit(MPTCP_NOSPACE, &mptcp_sk(sk)->flags))
+			sk_stream_write_space(sk);
+	}
+}
+
 static inline void __mptcp_sync_sndbuf(struct sock *sk)
 {
 	struct mptcp_subflow_context *subflow;
@@ -808,6 +818,7 @@ static inline void __mptcp_sync_sndbuf(struct sock *sk)
 
 	/* the msk max wmem limit is <nr_subflows> * tcp wmem[2] */
 	WRITE_ONCE(sk->sk_sndbuf, new_sndbuf);
+	mptcp_write_space(sk);
 }
 
 /* The called held both the msk socket and the subflow socket locks,
@@ -838,16 +849,6 @@ static inline void mptcp_propagate_sndbuf(struct sock *sk, struct sock *ssk)
 	local_bh_enable();
 }
 
-static inline void mptcp_write_space(struct sock *sk)
-{
-	if (sk_stream_is_writeable(sk)) {
-		/* pairs with memory barrier in mptcp_poll */
-		smp_mb();
-		if (test_and_clear_bit(MPTCP_NOSPACE, &mptcp_sk(sk)->flags))
-			sk_stream_write_space(sk);
-	}
-}
-
 void mptcp_destroy_common(struct mptcp_sock *msk, unsigned int flags);
 
 #define MPTCP_TOKEN_MAX_RETRIES	4

-- 
2.43.0


  parent reply	other threads:[~2024-02-23 16:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-23 16:14 [PATCH net 00/10] mptcp: more misc. fixes for v6.8 Matthieu Baerts (NGI0)
2024-02-23 16:14 ` [PATCH net 01/10] mptcp: map v4 address to v6 when destroying subflow Matthieu Baerts (NGI0)
2024-02-23 16:14 ` [PATCH net 02/10] selftests: mptcp: rm subflow with v4/v4mapped addr Matthieu Baerts (NGI0)
2024-02-23 16:14 ` [PATCH net 03/10] mptcp: avoid printing warning once on client side Matthieu Baerts (NGI0)
2024-02-23 16:14 ` [PATCH net 04/10] mptcp: push at DSS boundaries Matthieu Baerts (NGI0)
2024-02-23 16:14 ` [PATCH net 05/10] mptcp: fix snd_wnd initialization for passive socket Matthieu Baerts (NGI0)
2024-02-23 16:35   ` [PATCH net 05/10] mptcp: fix snd_wnd initialization for passive socket: manual merge Matthieu Baerts
2024-02-23 16:14 ` Matthieu Baerts (NGI0) [this message]
2024-02-23 16:14 ` [PATCH net 07/10] selftests: mptcp: join: add ss mptcp support check Matthieu Baerts (NGI0)
2024-02-23 16:14 ` [PATCH net 08/10] mptcp: fix double-free on socket dismantle Matthieu Baerts (NGI0)
2024-02-23 16:14 ` [PATCH net 09/10] mptcp: fix possible deadlock in subflow diag Matthieu Baerts (NGI0)
2024-02-23 16:14 ` [PATCH net 10/10] selftests: mptcp: explicitly trigger the listener diag code-path Matthieu Baerts (NGI0)
2024-02-26 17:58   ` Simon Horman
2024-03-01 14:37   ` Jakub Kicinski
2024-03-01 15:10     ` Matthieu Baerts
2024-03-01 18:24       ` Matthieu Baerts
2024-03-01 18:55         ` Jakub Kicinski
2024-02-27  3:10 ` [PATCH net 00/10] mptcp: more misc. fixes for v6.8 patchwork-bot+netdevbpf

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=20240223-upstream-net-20240223-misc-fixes-v1-6-162e87e48497@kernel.org \
    --to=matttbe@kernel.org \
    --cc=cpaasch@apple.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=geliang@kernel.org \
    --cc=kishen.maloor@intel.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martineau@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=peter.krystad@linux.intel.com \
    --cc=shuah@kernel.org \
    --cc=stable@vger.kernel.org \
    /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.