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

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

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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) 2024 Meta Platforms, Inc. and affiliates. */
  3 #include <vmlinux.h>
  4 #include <bpf/bpf_helpers.h>
  5 #include <bpf/bpf_tracing.h>
  6 #include "../bpf_testmod/bpf_testmod.h"
  7 
  8 char _license[] SEC("license") = "GPL";
  9 
 10 int test_1_result = 0;
 11 int test_2_result = 0;
 12 
 13 SEC("struct_ops/test_1")
 14 int BPF_PROG(test_1)
 15 {
 16         test_1_result = 0xdeadbeef;
 17         return 0;
 18 }
 19 
 20 SEC("struct_ops/test_2")
 21 void BPF_PROG(test_2, int a, int b)
 22 {
 23         test_2_result = a + b;
 24 }
 25 
 26 SEC("?struct_ops/test_3")
 27 int BPF_PROG(test_3, int a, int b)
 28 {
 29         test_2_result = a + b + 3;
 30         return a + b + 3;
 31 }
 32 
 33 SEC(".struct_ops.link")
 34 struct bpf_testmod_ops testmod_1 = {
 35         .test_1 = (void *)test_1,
 36         .test_2 = (void *)test_2,
 37         .data = 0x1,
 38 };
 39 
 40 SEC("struct_ops/test_2")
 41 void BPF_PROG(test_2_v2, int a, int b)
 42 {
 43         test_2_result = a * b;
 44 }
 45 
 46 struct bpf_testmod_ops___v2 {
 47         int (*test_1)(void);
 48         void (*test_2)(int a, int b);
 49         int (*test_maybe_null)(int dummy, struct task_struct *task);
 50 };
 51 
 52 SEC(".struct_ops.link")
 53 struct bpf_testmod_ops___v2 testmod_2 = {
 54         .test_1 = (void *)test_1,
 55         .test_2 = (void *)test_2_v2,
 56 };
 57 
 58 struct bpf_testmod_ops___zeroed {
 59         int (*test_1)(void);
 60         void (*test_2)(int a, int b);
 61         int (*test_maybe_null)(int dummy, struct task_struct *task);
 62         void (*zeroed_op)(int a, int b);
 63         int zeroed;
 64 };
 65 
 66 SEC("struct_ops/test_3")
 67 int BPF_PROG(zeroed_op)
 68 {
 69         return 1;
 70 }
 71 
 72 SEC(".struct_ops.link")
 73 struct bpf_testmod_ops___zeroed testmod_zeroed = {
 74         .test_1 = (void *)test_1,
 75         .test_2 = (void *)test_2_v2,
 76         .zeroed_op = (void *)zeroed_op,
 77 };
 78 
 79 struct bpf_testmod_ops___incompatible {
 80         int (*test_1)(void);
 81         void (*test_2)(int *a);
 82         int data;
 83 };
 84 
 85 SEC(".struct_ops.link")
 86 struct bpf_testmod_ops___incompatible testmod_incompatible = {
 87         .test_1 = (void *)test_1,
 88         .test_2 = (void *)test_2,
 89         .data = 3,
 90 };
 91 

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