xref: /linux/tools/testing/selftests/bpf/progs/struct_ops_module.c (revision bd765cc910127ee8ed6cd83dae0f0bfbca69d71e)
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 int BPF_PROG(test_2, int a, int b)
20 {
21 	test_2_result = a + b;
22 	return a + b;
23 }
24 
25 SEC(".struct_ops.link")
26 struct bpf_testmod_ops testmod_1 = {
27 	.test_1 = (void *)test_1,
28 	.test_2 = (void *)test_2,
29 };
30 
31