xref: /linux/tools/testing/selftests/bpf/progs/struct_ops_autocreate2.c (revision eb01fe7abbe2d0b38824d2a93fdb4cc3eaf2ccc1)
1 // SPDX-License-Identifier: GPL-2.0
2 
3 #include <linux/bpf.h>
4 #include <bpf/bpf_helpers.h>
5 #include <bpf/bpf_tracing.h>
6 
7 char _license[] SEC("license") = "GPL";
8 
9 int test_1_result = 0;
10 
11 SEC("?struct_ops/test_1")
12 int BPF_PROG(foo)
13 {
14 	test_1_result = 42;
15 	return 0;
16 }
17 
18 SEC("?struct_ops/test_1")
19 int BPF_PROG(bar)
20 {
21 	test_1_result = 24;
22 	return 0;
23 }
24 
25 struct bpf_testmod_ops {
26 	int (*test_1)(void);
27 };
28 
29 SEC(".struct_ops.link")
30 struct bpf_testmod_ops testmod_1 = {
31 	.test_1 = (void *)bar
32 };
33