Skip to content

Commit ce5f6f7

Browse files
matttbekuba-moo
authored andcommitted
mptcp: sockopt: info: stop early if no buffer
Up to recently, it has been recommended to use getsockopt(MPTCP_INFO) to check if a fallback to TCP happened, or if the client requested to use MPTCP. In this case, the userspace app is only interested by the returned value of the getsocktop() call, and can then give 0 for the option length, and NULL for the buffer address. An easy optimisation is then to stop early, and avoid filling a local buffer -- which now requires two different locks -- if it is not needed. Reviewed-by: Mat Martineau <[email protected]> Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> Signed-off-by: Mat Martineau <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent bd11dc4 commit ce5f6f7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

net/mptcp/sockopt.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,10 @@ static int mptcp_getsockopt_info(struct mptcp_sock *msk, char __user *optval, in
999999
if (get_user(len, optlen))
10001000
return -EFAULT;
10011001

1002+
/* When used only to check if a fallback to TCP happened. */
1003+
if (len == 0)
1004+
return 0;
1005+
10021006
len = min_t(unsigned int, len, sizeof(struct mptcp_info));
10031007

10041008
mptcp_diag_fill_info(msk, &m_info);

0 commit comments

Comments
 (0)