diff mbox series

[net] mptcp: fix bogus sendmsg() return code under pressure

Message ID 63d451ecf32a5eb3c2d49ccc5468734be1898a61.1596214315.git.pabeni@redhat.com
State Accepted, archived
Delegated to: Matthieu Baerts
Headers show
Series [net] mptcp: fix bogus sendmsg() return code under pressure | expand

Commit Message

Paolo Abeni July 31, 2020, 4:53 p.m. UTC
In case of memory pressure, mptcp_sendmsg() may call
sk_stream_wait_memory() after succesfully xmitting some
bytes. If the latter fails we currently return to the
user-space the error code, ignoring the succeful xmit.

Address the issue always checking for the xmitted bytes
before mptcp_sendmsg() completes.

Fixes: f296234c98a8 ("mptcp: Add handling of incoming MP_JOIN requests")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/mptcp/protocol.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
---
needed for upcoming multiple subflow xmit, I hope to sent this
upstream soon

Comments

Matthieu Baerts Aug. 3, 2020, 3:30 p.m. UTC | #1
Hi Paolo,

On 31/07/2020 18:53, Paolo Abeni wrote:
> In case of memory pressure, mptcp_sendmsg() may call
> sk_stream_wait_memory() after succesfully xmitting some
> bytes. If the latter fails we currently return to the
> user-space the error code, ignoring the succeful xmit.
> 
> Address the issue always checking for the xmitted bytes
> before mptcp_sendmsg() completes.

Thank you for the patch! It looks good to me!

Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>

Cheers,
Matt
Matthieu Baerts Aug. 3, 2020, 4:14 p.m. UTC | #2
Hi Paolo,

On 03/08/2020 17:30, Matthieu Baerts wrote:
> Hi Paolo,
> 
> On 31/07/2020 18:53, Paolo Abeni wrote:
>> In case of memory pressure, mptcp_sendmsg() may call
>> sk_stream_wait_memory() after succesfully xmitting some
>> bytes. If the latter fails we currently return to the
>> user-space the error code, ignoring the succeful xmit.
>>
>> Address the issue always checking for the xmitted bytes
>> before mptcp_sendmsg() completes.
> 
> Thank you for the patch! It looks good to me!
> 
> Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>

The commit is now in the "export" branch and validated by the CI. The 
results are the same as before your commit: the same 2 tests are failing 
(diag.sh and packetdrill's dss tests as described on GitHub).

Then please go ahead by sending this patch to -net! :)

Cheers,
Matt
diff mbox series

Patch

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 650fae3e6e6d..3b9ae98c67bb 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -984,7 +984,6 @@  static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 
 	mptcp_set_timeout(sk, ssk);
 	if (copied) {
-		ret = copied;
 		tcp_push(ssk, msg->msg_flags, mss_now, tcp_sk(ssk)->nonagle,
 			 size_goal);
 
@@ -997,7 +996,7 @@  static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 	release_sock(ssk);
 out:
 	release_sock(sk);
-	return ret;
+	return copied ? : ret;
 }
 
 static void mptcp_wait_data(struct sock *sk, long *timeo)