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
8char _license[] SEC("license") = "GPL";
9
10int test_1_result = 0;
11int test_2_result = 0;
12
13SEC("struct_ops/test_1")
14int BPF_PROG(test_1)
15{
16	test_1_result = 0xdeadbeef;
17	return 0;
18}
19
20SEC("struct_ops/test_2")
21void BPF_PROG(test_2, int a, int b)
22{
23	test_2_result = a + b;
24}
25
26SEC("struct_ops/test_3")
27int BPF_PROG(test_3, int a, int b)
28{
29	test_2_result = a + b + 3;
30	return a + b + 3;
31}
32
33SEC(".struct_ops.link")
34struct bpf_testmod_ops testmod_1 = {
35	.test_1 = (void *)test_1,
36	.test_2 = (void *)test_2,
37	.data = 0x1,
38};
39
40SEC("struct_ops/test_2")
41void BPF_PROG(test_2_v2, int a, int b)
42{
43	test_2_result = a * b;
44}
45
46struct 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
52SEC(".struct_ops.link")
53struct bpf_testmod_ops___v2 testmod_2 = {
54	.test_1 = (void *)test_1,
55	.test_2 = (void *)test_2_v2,
56};
57