~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/progs/mptcp_sock.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /* Copyright (c) 2020, Tessares SA. */
  3 /* Copyright (c) 2022, SUSE. */
  4 
  5 #include "bpf_tracing_net.h"
  6 #include <bpf/bpf_helpers.h>
  7 #include <bpf/bpf_tracing.h>
  8 
  9 char _license[] SEC("license") = "GPL";
 10 __u32 token = 0;
 11 
 12 struct mptcp_storage {
 13         __u32 invoked;
 14         __u32 is_mptcp;
 15         struct sock *sk;
 16         __u32 token;
 17         struct sock *first;
 18         char ca_name[TCP_CA_NAME_MAX];
 19 };
 20 
 21 struct {
 22         __uint(type, BPF_MAP_TYPE_SK_STORAGE);
 23         __uint(map_flags, BPF_F_NO_PREALLOC);
 24         __type(key, int);
 25         __type(value, struct mptcp_storage);
 26 } socket_storage_map SEC(".maps");
 27 
 28 SEC("sockops")
 29 int _sockops(struct bpf_sock_ops *ctx)
 30 {
 31         struct mptcp_storage *storage;
 32         struct mptcp_sock *msk;
 33         int op = (int)ctx->op;
 34         struct tcp_sock *tsk;
 35         struct bpf_sock *sk;
 36         bool is_mptcp;
 37 
 38         if (op != BPF_SOCK_OPS_TCP_CONNECT_CB)
 39                 return 1;
 40 
 41         sk = ctx->sk;
 42         if (!sk)
 43                 return 1;
 44 
 45         tsk = bpf_skc_to_tcp_sock(sk);
 46         if (!tsk)
 47                 return 1;
 48 
 49         is_mptcp = bpf_core_field_exists(tsk->is_mptcp) ? tsk->is_mptcp : 0;
 50         if (!is_mptcp) {
 51                 storage = bpf_sk_storage_get(&socket_storage_map, sk, 0,
 52                                              BPF_SK_STORAGE_GET_F_CREATE);
 53                 if (!storage)
 54                         return 1;
 55 
 56                 storage->token = 0;
 57                 __builtin_memset(storage->ca_name, 0, TCP_CA_NAME_MAX);
 58                 storage->first = NULL;
 59         } else {
 60                 msk = bpf_skc_to_mptcp_sock(sk);
 61                 if (!msk)
 62                         return 1;
 63 
 64                 storage = bpf_sk_storage_get(&socket_storage_map, msk, 0,
 65                                              BPF_SK_STORAGE_GET_F_CREATE);
 66                 if (!storage)
 67                         return 1;
 68 
 69                 storage->token = msk->token;
 70                 __builtin_memcpy(storage->ca_name, msk->ca_name, TCP_CA_NAME_MAX);
 71                 storage->first = msk->first;
 72         }
 73         storage->invoked++;
 74         storage->is_mptcp = is_mptcp;
 75         storage->sk = (struct sock *)sk;
 76 
 77         return 1;
 78 }
 79 
 80 SEC("fentry/mptcp_pm_new_connection")
 81 int BPF_PROG(trace_mptcp_pm_new_connection, struct mptcp_sock *msk,
 82              const struct sock *ssk, int server_side)
 83 {
 84         if (!server_side)
 85                 token = msk->token;
 86 
 87         return 0;
 88 }
 89 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php