diff mbox series

Squash-to: "mptcp: wake-up readers only for in sequence data"

Message ID 8c07c4b90aac3f1d3bdd64c5ba8f5c83372005a1.1623074917.git.pabeni@redhat.com (mailing list archive)
State Accepted, archived
Commit 4fa051adcfd8796f755806257b234c3cfe5df6d1
Delegated to: Matthieu Baerts
Headers show
Series Squash-to: "mptcp: wake-up readers only for in sequence data" | expand

Commit Message

Paolo Abeni June 7, 2021, 2:08 p.m. UTC
We need to flip the DATA_READY bit under the mptcp_data_lock()
(or before acquiring it, as the old code did), or the BH could
end-up flipping the bit after that the user-space already
flushed the just-appended data.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/mptcp/protocol.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Matthieu Baerts June 7, 2021, 2:57 p.m. UTC | #1
Hi Paolo, Mat,

On 07/06/2021 16:08, Paolo Abeni wrote:
> We need to flip the DATA_READY bit under the mptcp_data_lock()
> (or before acquiring it, as the old code did), or the BH could
> end-up flipping the bit after that the user-space already
> flushed the just-appended data.
> 
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Thank you for the patch!

@Mat: I hope you don't mind if I already apply it to fix issues/201 and
apply other patches!

- b2427404975d: "squashed" in "mptcp: wake-up readers only for in
sequence data"
- Results: 3c5535f65726..e5d80c7af352

Builds and tests are now in progress:

https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20210607T145646
https://github.com/multipath-tcp/mptcp_net-next/actions/workflows/build-validation.yml?query=branch:export/20210607T145646

Cheers,
Matt
Mat Martineau June 7, 2021, 4:45 p.m. UTC | #2
On Mon, 7 Jun 2021, Matthieu Baerts wrote:

> Hi Paolo, Mat,
>
> On 07/06/2021 16:08, Paolo Abeni wrote:
>> We need to flip the DATA_READY bit under the mptcp_data_lock()
>> (or before acquiring it, as the old code did), or the BH could
>> end-up flipping the bit after that the user-space already
>> flushed the just-appended data.
>>
>> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
>
> Thank you for the patch!
>
> @Mat: I hope you don't mind if I already apply it to fix issues/201 and
> apply other patches!

No problem!

>
> - b2427404975d: "squashed" in "mptcp: wake-up readers only for in
> sequence data"
> - Results: 3c5535f65726..e5d80c7af352
>
> Builds and tests are now in progress:
>
> https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20210607T145646
> https://github.com/multipath-tcp/mptcp_net-next/actions/workflows/build-validation.yml?query=branch:export/20210607T145646

--
Mat Martineau
Intel
diff mbox series

Patch

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 8e7cf4c480a6..8ef60e415d9a 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -687,8 +687,6 @@  static bool move_skbs_to_msk(struct mptcp_sock *msk, struct sock *ssk)
 	if (inet_sk_state_load(sk) == TCP_CLOSE)
 		return false;
 
-	mptcp_data_lock(sk);
-
 	__mptcp_move_skbs_from_subflow(msk, ssk, &moved);
 	__mptcp_ofo_queue(msk);
 	if (unlikely(ssk->sk_err)) {
@@ -705,8 +703,6 @@  static bool move_skbs_to_msk(struct mptcp_sock *msk, struct sock *ssk)
 	 */
 	if (mptcp_pending_data_fin(sk, NULL))
 		mptcp_schedule_work(sk);
-	mptcp_data_unlock(sk);
-
 	return moved > 0;
 }
 
@@ -733,10 +729,12 @@  void mptcp_data_ready(struct sock *sk, struct sock *ssk)
 		return;
 
 	/* Wake-up the reader only for in-sequence data */
+	mptcp_data_lock(sk);
 	if (move_skbs_to_msk(msk, ssk)) {
 		set_bit(MPTCP_DATA_READY, &msk->flags);
 		sk->sk_data_ready(sk);
 	}
+	mptcp_data_unlock(sk);
 }
 
 static bool mptcp_do_flush_join_list(struct mptcp_sock *msk)