Skip to content

Commit 06a6f4e

Browse files
Geliang Tangintel-lab-lkp
authored andcommitted
mptcp: setsockopt support for TCP_MD5SIG
Supporting TCP_MD5 socket option is required when MPTCP is used by default when creating a socket, to keep the same behaviour as with TCP. TCP_MD5 is not compatible with MPTCP, and it will cause a fallback to TCP at the connection request, if MPTCP was requested. This then fixes a "regression" compared to TCP. This patch adds setsockopt support for TCP_MD5SIG and TCP_MD5SIG_EXT options. The implementation: - Allow setting these options (getsockopt remains unsupported) - Apply them only to the first subflow - Trigger fallback to TCP to maintain MD5 compatibility Note that getsockopt for these options remains unsupported, consistent with TCP. Closes: multipath-tcp/mptcp_net-next#575 Fixes: d9e4c12 ("mptcp: only admit explicitly supported sockopt") Signed-off-by: Geliang Tang <[email protected]>
1 parent ca5c827 commit 06a6f4e

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

net/mptcp/sockopt.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <net/tcp.h>
1414
#include <net/mptcp.h>
1515
#include "protocol.h"
16+
#include "mib.h"
1617

1718
#define MIN_INFO_OPTLEN_SIZE 16
1819
#define MIN_FULL_INFO_OPTLEN_SIZE 40
@@ -567,11 +568,12 @@ static bool mptcp_supported_sockopt(int level, int optname)
567568
case TCP_FASTOPEN_CONNECT:
568569
case TCP_FASTOPEN_KEY:
569570
case TCP_FASTOPEN_NO_COOKIE:
571+
/* MD5 will force a fallback to TCP: OK to set while not connected */
572+
case TCP_MD5SIG:
573+
case TCP_MD5SIG_EXT:
570574
return true;
571575
}
572576

573-
/* TCP_MD5SIG, TCP_MD5SIG_EXT are not supported, MD5 is not compatible with MPTCP */
574-
575577
/* TCP_REPAIR, TCP_REPAIR_QUEUE, TCP_QUEUE_SEQ, TCP_REPAIR_OPTIONS,
576578
* TCP_REPAIR_WINDOW are not supported, better avoid this mess
577579
*/
@@ -836,6 +838,19 @@ static int mptcp_setsockopt_sol_tcp(struct mptcp_sock *msk, int optname,
836838
case TCP_FASTOPEN_NO_COOKIE:
837839
return mptcp_setsockopt_first_sf_only(msk, SOL_TCP, optname,
838840
optval, optlen);
841+
#ifdef CONFIG_TCP_MD5SIG
842+
case TCP_MD5SIG:
843+
case TCP_MD5SIG_EXT:
844+
if (!((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)))
845+
return -EINVAL;
846+
ret = mptcp_setsockopt_first_sf_only(msk, SOL_TCP, optname,
847+
optval, optlen);
848+
if (ret)
849+
return ret;
850+
if (!__mptcp_try_fallback(msk, MPTCP_MIB_MD5SIGFALLBACK))
851+
return -EINVAL;
852+
return 0;
853+
#endif
839854
}
840855

841856
ret = mptcp_get_int_option(msk, optval, optlen, &val);

0 commit comments

Comments
 (0)