[PATCH mptcp-next 1/2] mptcp: add msk_is_mptcp() helper

Günther Noack gnoack3000 at gmail.com
Wed Oct 14 05:13:36 UTC 2026


On Tue, Oct 13, 2026 at 02:56:46PM +0800, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang at 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 subflow socket, this helper takes an
> MPTCP parent socket directly.
> 
> The naming follows the convention of rsk_is_mptcp() to distinguish it
> from sk_is_mptcp(). This helper will be used in net/core/sock_map.c
> alongside sk_is_tcp() to add MPTCP support for BPF sockmap, and in
> other places where MPTCP parent socket type checking is needed.
> 
> Signed-off-by: Geliang Tang <tanggeliang at kylinos.cn>
> ---
>  include/net/mptcp.h | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/include/net/mptcp.h b/include/net/mptcp.h
> index 30f0e8ba88a8..8943d9f2b48b 100644
> --- a/include/net/mptcp.h
> +++ b/include/net/mptcp.h
> @@ -150,6 +150,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);
> @@ -261,6 +268,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
> 

Reviewed-by: Günther Noack <gnoack3000 at gmail.com>

Thank you Geliang!  This is exactly the helper we'd need for the
Landlock MPTCP patch as well, and I'll happily rebase my patch set on
that and use this more central helper!

(Landlock is currently a bit bottlenecked on code reviews, so that
review is moving a bit slower, but we'll get to it.)

–Günther



More information about the Linux-security-module-archive mailing list