xref: /openbmc/linux/net/mptcp/bpf.c (revision 6c8c1406)
1 // SPDX-License-Identifier: GPL-2.0
2 /* Multipath TCP
3  *
4  * Copyright (c) 2020, Tessares SA.
5  * Copyright (c) 2022, SUSE.
6  *
7  * Author: Nicolas Rybowski <nicolas.rybowski@tessares.net>
8  */
9 
10 #define pr_fmt(fmt) "MPTCP: " fmt
11 
12 #include <linux/bpf.h>
13 #include "protocol.h"
14 
15 struct mptcp_sock *bpf_mptcp_sock_from_subflow(struct sock *sk)
16 {
17 	if (sk && sk_fullsock(sk) && sk->sk_protocol == IPPROTO_TCP && sk_is_mptcp(sk))
18 		return mptcp_sk(mptcp_subflow_ctx(sk)->conn);
19 
20 	return NULL;
21 }
22