Skip to content

Commit 27c843e

Browse files
Paolo Abenigregkh
authored andcommitted
mptcp: fix recvbuffer adjust on sleeping rcvmsg
commit 449e691 upstream. If the recvmsg() blocks after receiving some data - i.e. due to SO_RCVLOWAT - the MPTCP code will attempt multiple times to adjust the receive buffer size, wrongly accounting every time the cumulative of received data - instead of accounting only for the delta. Address the issue moving mptcp_rcv_space_adjust just after the data reception and passing it only the just received bytes. This also removes an unneeded difference between the TCP and MPTCP RX code path implementation. Fixes: 5813022 ("mptcp: error out earlier on disconnect") Cc: [email protected] Signed-off-by: Paolo Abeni <[email protected]> Reviewed-by: Mat Martineau <[email protected]> Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 53fe947 commit 27c843e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

net/mptcp/protocol.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,6 +1902,8 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
19021902
goto out;
19031903
}
19041904

1905+
static void mptcp_rcv_space_adjust(struct mptcp_sock *msk, int copied);
1906+
19051907
static int __mptcp_recvmsg_mskq(struct mptcp_sock *msk,
19061908
struct msghdr *msg,
19071909
size_t len, int flags,
@@ -1955,6 +1957,7 @@ static int __mptcp_recvmsg_mskq(struct mptcp_sock *msk,
19551957
break;
19561958
}
19571959

1960+
mptcp_rcv_space_adjust(msk, copied);
19581961
return copied;
19591962
}
19601963

@@ -2231,16 +2234,13 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
22312234
}
22322235

22332236
pr_debug("block timeout %ld\n", timeo);
2234-
mptcp_rcv_space_adjust(msk, copied);
22352237
err = sk_wait_data(sk, &timeo, NULL);
22362238
if (err < 0) {
22372239
err = copied ? : err;
22382240
goto out_err;
22392241
}
22402242
}
22412243

2242-
mptcp_rcv_space_adjust(msk, copied);
2243-
22442244
out_err:
22452245
if (cmsg_flags && copied >= 0) {
22462246
if (cmsg_flags & MPTCP_CMSG_TS)

0 commit comments

Comments
 (0)