1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2020, Tessares SA. */
3 /* Copyright (c) 2022, SUSE. */
6 #include <bpf/bpf_helpers.h>
7 #include "bpf_tcp_helpers.h"
9 char _license[] SEC("license") = "GPL";
12 struct mptcp_storage {
19 __uint(type, BPF_MAP_TYPE_SK_STORAGE);
20 __uint(map_flags, BPF_F_NO_PREALLOC);
22 __type(value, struct mptcp_storage);
23 } socket_storage_map SEC(".maps");
26 int _sockops(struct bpf_sock_ops *ctx)
28 struct mptcp_storage *storage;
29 struct mptcp_sock *msk;
30 int op = (int)ctx->op;
35 if (op != BPF_SOCK_OPS_TCP_CONNECT_CB)
42 tsk = bpf_skc_to_tcp_sock(sk);
46 is_mptcp = bpf_core_field_exists(tsk->is_mptcp) ? tsk->is_mptcp : 0;
48 storage = bpf_sk_storage_get(&socket_storage_map, sk, 0,
49 BPF_SK_STORAGE_GET_F_CREATE);
55 msk = bpf_skc_to_mptcp_sock(sk);
59 storage = bpf_sk_storage_get(&socket_storage_map, msk, 0,
60 BPF_SK_STORAGE_GET_F_CREATE);
64 storage->token = msk->token;
67 storage->is_mptcp = is_mptcp;
72 SEC("fentry/mptcp_pm_new_connection")
73 int BPF_PROG(trace_mptcp_pm_new_connection, struct mptcp_sock *msk,
74 const struct sock *ssk, int server_side)