Skip to content

Commit 449e691

Browse files
Paolo Abenikuba-moo
authored andcommitted
mptcp: fix recvbuffer adjust on sleeping rcvmsg
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: 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> Link: https://patch.msgid.link/20241230-net-mptcp-rbuf-fixes-v1-1-8608af434ceb@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 260466b commit 449e691

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
@@ -1939,6 +1939,8 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
19391939
goto out;
19401940
}
19411941

1942+
static void mptcp_rcv_space_adjust(struct mptcp_sock *msk, int copied);
1943+
19421944
static int __mptcp_recvmsg_mskq(struct mptcp_sock *msk,
19431945
struct msghdr *msg,
19441946
size_t len, int flags,
@@ -1992,6 +1994,7 @@ static int __mptcp_recvmsg_mskq(struct mptcp_sock *msk,
19921994
break;
19931995
}
19941996

1997+
mptcp_rcv_space_adjust(msk, copied);
19951998
return copied;
19961999
}
19972000

@@ -2268,16 +2271,13 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
22682271
}
22692272

22702273
pr_debug("block timeout %ld\n", timeo);
2271-
mptcp_rcv_space_adjust(msk, copied);
22722274
err = sk_wait_data(sk, &timeo, NULL);
22732275
if (err < 0) {
22742276
err = copied ? : err;
22752277
goto out_err;
22762278
}
22772279
}
22782280

2279-
mptcp_rcv_space_adjust(msk, copied);
2280-
22812281
out_err:
22822282
if (cmsg_flags && copied >= 0) {
22832283
if (cmsg_flags & MPTCP_CMSG_TS)

0 commit comments

Comments
 (0)