From: Geliang Tang <tang…@kylinos.cn>
Introduce msk_is_mptcp() to check whether a socket is an MPTCP socket
(IPPROTO_MPTCP on SOCK_STREAM), modeled after sk_is_tcp(). Unlike
sk_is_mptcp() which tests a TCP subflow socket, this helper takes an
MPTCP socket directly.
The naming follows the convention of rsk_is_mptcp() to distinguish it
from sk_is_mptcp(). This helper will be used alongside sk_is_tcp() to
add MPTCP support for BPF sockmap, Landlock and in other places where
MPTCP socket type checking is going to be needed.
Signed-off-by: Geliang Tang <tang…@kylinos.cn>
Reviewed-by: Günther Noack <gnoa…@gmail.com>
Reviewed-by: Matthieu Baerts (NGI0) <matt…@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matt…@kernel.org>
---
include/net/mptcp.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/include/net/mptcp.h b/include/net/mptcp.h
index ad7005b574bb..53ec88673368 100644
--- a/include/net/mptcp.h
+++ b/include/net/mptcp.h
@@ -144,6 +144,13 @@ static inline bool rsk_drop_req(const struct request_sock *req)
return tcp_rsk(req)->is_mptcp && tcp_rsk(req)->drop_req;
}
+static inline bool msk_is_mptcp(const struct sock *sk)
+{
+ return sk_is_inet(sk) &&
+ sk->sk_type == SOCK_STREAM &&
+ sk->sk_protocol == IPPROTO_MPTCP;
+}
+
void mptcp_space(const struct sock *ssk, int *space, int *full_space);
bool mptcp_syn_options(struct sock *sk, const struct sk_buff *skb,
unsigned int *size, struct mptcp_out_options *opts);
@@ -255,6 +262,11 @@ static inline bool rsk_drop_req(const struct request_sock *req)
return false;
}
+static inline bool msk_is_mptcp(const struct sock *sk)
+{
+ return false;
+}
+
static inline bool mptcp_syn_options(struct sock *sk, const struct sk_buff *skb,
unsigned int *size,
struct mptcp_out_options *opts)
--
2.55.0