Message ID | 20240509-upstream-net-next-20240509-mptcp-tcp_is_mptcp-v1-1-f846df999202@kernel.org (mailing list archive) |
---|---|
State | Accepted |
Commit | c084ebd77a00b1a16d9daa57b6ecdfdf1f43c78a |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next] tcp: socket option to check for MPTCP fallback to TCP | expand |
Hello: This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <kuba@kernel.org>: On Thu, 09 May 2024 20:10:10 +0200 you wrote: > A way for an application to know if an MPTCP connection fell back to TCP > is to use getsockopt(MPTCP_INFO) and look for errors. The issue with > this technique is that the same errors -- EOPNOTSUPP (IPv4) and > ENOPROTOOPT (IPv6) -- are returned if there was a fallback, *or* if the > kernel doesn't support this socket option. The userspace then has to > look at the kernel version to understand what the errors mean. > > [...] Here is the summary with links: - [net-next] tcp: socket option to check for MPTCP fallback to TCP https://git.kernel.org/netdev/net-next/c/c084ebd77a00 You are awesome, thank you!
diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h index c07e9f90c084..dbf896f3146c 100644 --- a/include/uapi/linux/tcp.h +++ b/include/uapi/linux/tcp.h @@ -135,6 +135,8 @@ enum { #define TCP_AO_GET_KEYS 41 /* List MKT(s) */ #define TCP_AO_REPAIR 42 /* Get/Set SNEs and ISNs */ +#define TCP_IS_MPTCP 43 /* Is MPTCP being used? */ + #define TCP_REPAIR_ON 1 #define TCP_REPAIR_OFF 0 #define TCP_REPAIR_OFF_NO_WP -1 /* Turn off without window probes */ diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index e1f0efbb29d6..231ff63ba81d 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -4363,6 +4363,9 @@ int do_tcp_getsockopt(struct sock *sk, int level, return err; } + case TCP_IS_MPTCP: + val = 0; + break; default: return -ENOPROTOOPT; } diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index 1fea43f5b6f3..eaa3b79651a4 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -1348,6 +1348,8 @@ static int mptcp_getsockopt_sol_tcp(struct mptcp_sock *msk, int optname, return mptcp_put_int_option(msk, optval, optlen, msk->nodelay); case TCP_NOTSENT_LOWAT: return mptcp_put_int_option(msk, optval, optlen, msk->notsent_lowat); + case TCP_IS_MPTCP: + return mptcp_put_int_option(msk, optval, optlen, 1); } return -EOPNOTSUPP; }