Skip to content

Commit cbdb6a4

Browse files
Paolo Abenigregkh
authored andcommitted
mptcp: fix recvbuffer adjust on sleeping rcvmsg
commit 449e6912a2522af672e99992e1201a454910864e 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: 581302298524 ("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 09ba953 commit cbdb6a4

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
@@ -1917,6 +1917,8 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
19171917
goto out;
19181918
}
19191919

1920+
static void mptcp_rcv_space_adjust(struct mptcp_sock *msk, int copied);
1921+
19201922
static int __mptcp_recvmsg_mskq(struct mptcp_sock *msk,
19211923
struct msghdr *msg,
19221924
size_t len, int flags,
@@ -1968,6 +1970,7 @@ static int __mptcp_recvmsg_mskq(struct mptcp_sock *msk,
19681970
break;
19691971
}
19701972

1973+
mptcp_rcv_space_adjust(msk, copied);
19711974
return copied;
19721975
}
19731976

@@ -2246,16 +2249,13 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
22462249
}
22472250

22482251
pr_debug("block timeout %ld\n", timeo);
2249-
mptcp_rcv_space_adjust(msk, copied);
22502252
err = sk_wait_data(sk, &timeo, NULL);
22512253
if (err < 0) {
22522254
err = copied ? : err;
22532255
goto out_err;
22542256
}
22552257
}
22562258

2257-
mptcp_rcv_space_adjust(msk, copied);
2258-
22592259
out_err:
22602260
if (cmsg_flags && copied >= 0) {
22612261
if (cmsg_flags & MPTCP_CMSG_TS)

0 commit comments

Comments
 (0)