xref: /linux/tools/testing/selftests/bpf/progs/struct_ops_module.c (revision 4e887471e8e3a513607495d18333c44f59a82c5a)
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_2_result = 0;
11 
12 SEC("struct_ops/test_1")
13 int BPF_PROG(test_1)
14 {
15 	return 0xdeadbeef;
16 }
17 
18 SEC("struct_ops/test_2")
19 void BPF_PROG(test_2, int a, int b)
20 {
21 	test_2_result = a + b;
22 }
23 
24 SEC("struct_ops/test_3")
25 int BPF_PROG(test_3, int a, int b)
26 {
27 	test_2_result = a + b + 3;
28 	return a + b + 3;
29 }
30 
31 SEC(".struct_ops.link")
32 struct bpf_testmod_ops testmod_1 = {
33 	.test_1 = (void *)test_1,
34 	.test_2 = (void *)test_2,
35 	.data = 0x1,
36 };
37 
38