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

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

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ 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.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */
  3 
  4 #include <vmlinux.h>
  5 #include <bpf/bpf_tracing.h>
  6 #include <bpf/bpf_helpers.h>
  7 
  8 struct bpf_testmod_struct_arg_1 {
  9         int a;
 10 };
 11 struct bpf_testmod_struct_arg_2 {
 12         long a;
 13         long b;
 14 };
 15 
 16 struct bpf_testmod_struct_arg_3 {
 17         int a;
 18         int b[];
 19 };
 20 
 21 long t1_a_a, t1_a_b, t1_b, t1_c, t1_ret, t1_nregs;
 22 __u64 t1_reg0, t1_reg1, t1_reg2, t1_reg3;
 23 long t2_a, t2_b_a, t2_b_b, t2_c, t2_ret;
 24 long t3_a, t3_b, t3_c_a, t3_c_b, t3_ret;
 25 long t4_a_a, t4_b, t4_c, t4_d, t4_e_a, t4_e_b, t4_ret;
 26 long t5_ret;
 27 int t6;
 28 
 29 SEC("fentry/bpf_testmod_test_struct_arg_1")
 30 int BPF_PROG2(test_struct_arg_1, struct bpf_testmod_struct_arg_2, a, int, b, int, c)
 31 {
 32         t1_a_a = a.a;
 33         t1_a_b = a.b;
 34         t1_b = b;
 35         t1_c = c;
 36         return 0;
 37 }
 38 
 39 SEC("fexit/bpf_testmod_test_struct_arg_1")
 40 int BPF_PROG2(test_struct_arg_2, struct bpf_testmod_struct_arg_2, a, int, b, int, c, int, ret)
 41 {
 42         t1_nregs =  bpf_get_func_arg_cnt(ctx);
 43         /* a.a */
 44         bpf_get_func_arg(ctx, 0, &t1_reg0);
 45         /* a.b */
 46         bpf_get_func_arg(ctx, 1, &t1_reg1);
 47         /* b */
 48         bpf_get_func_arg(ctx, 2, &t1_reg2);
 49         t1_reg2 = (int)t1_reg2;
 50         /* c */
 51         bpf_get_func_arg(ctx, 3, &t1_reg3);
 52         t1_reg3 = (int)t1_reg3;
 53 
 54         t1_ret = ret;
 55         return 0;
 56 }
 57 
 58 SEC("fentry/bpf_testmod_test_struct_arg_2")
 59 int BPF_PROG2(test_struct_arg_3, int, a, struct bpf_testmod_struct_arg_2, b, int, c)
 60 {
 61         t2_a = a;
 62         t2_b_a = b.a;
 63         t2_b_b = b.b;
 64         t2_c = c;
 65         return 0;
 66 }
 67 
 68 SEC("fexit/bpf_testmod_test_struct_arg_2")
 69 int BPF_PROG2(test_struct_arg_4, int, a, struct bpf_testmod_struct_arg_2, b, int, c, int, ret)
 70 {
 71         t2_ret = ret;
 72         return 0;
 73 }
 74 
 75 SEC("fentry/bpf_testmod_test_struct_arg_3")
 76 int BPF_PROG2(test_struct_arg_5, int, a, int, b, struct bpf_testmod_struct_arg_2, c)
 77 {
 78         t3_a = a;
 79         t3_b = b;
 80         t3_c_a = c.a;
 81         t3_c_b = c.b;
 82         return 0;
 83 }
 84 
 85 SEC("fexit/bpf_testmod_test_struct_arg_3")
 86 int BPF_PROG2(test_struct_arg_6, int, a, int, b, struct bpf_testmod_struct_arg_2, c, int, ret)
 87 {
 88         t3_ret = ret;
 89         return 0;
 90 }
 91 
 92 SEC("fentry/bpf_testmod_test_struct_arg_4")
 93 int BPF_PROG2(test_struct_arg_7, struct bpf_testmod_struct_arg_1, a, int, b,
 94              int, c, int, d, struct bpf_testmod_struct_arg_2, e)
 95 {
 96         t4_a_a = a.a;
 97         t4_b = b;
 98         t4_c = c;
 99         t4_d = d;
100         t4_e_a = e.a;
101         t4_e_b = e.b;
102         return 0;
103 }
104 
105 SEC("fexit/bpf_testmod_test_struct_arg_4")
106 int BPF_PROG2(test_struct_arg_8, struct bpf_testmod_struct_arg_1, a, int, b,
107              int, c, int, d, struct bpf_testmod_struct_arg_2, e, int, ret)
108 {
109         t4_ret = ret;
110         return 0;
111 }
112 
113 SEC("fentry/bpf_testmod_test_struct_arg_5")
114 int BPF_PROG2(test_struct_arg_9)
115 {
116         return 0;
117 }
118 
119 SEC("fexit/bpf_testmod_test_struct_arg_5")
120 int BPF_PROG2(test_struct_arg_10, int, ret)
121 {
122         t5_ret = ret;
123         return 0;
124 }
125 
126 SEC("fentry/bpf_testmod_test_struct_arg_6")
127 int BPF_PROG2(test_struct_arg_11, struct bpf_testmod_struct_arg_3 *, a)
128 {
129         t6 = a->b[0];
130         return 0;
131 }
132 
133 char _license[] SEC("license") = "GPL";
134 

~ [ 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