Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1// SPDX-License-Identifier: GPL-2.0
2
3#include <vmlinux.h>
4#include <bpf/bpf_tracing.h>
5#include "bpf_misc.h"
6#include "../test_kmods/bpf_testmod.h"
7#include "../test_kmods/bpf_testmod_kfunc.h"
8
9char _license[] SEC("license") = "GPL";
10
11#define bpf_kfunc_multi_st_ops_test_1(args) bpf_kfunc_multi_st_ops_test_1(args, st_ops_id)
12int st_ops_id;
13
14int test_pid;
15int test_err;
16
17#define MAP2_MAGIC 4567
18
19SEC("struct_ops")
20int BPF_PROG(test_1, struct st_ops_args *args)
21{
22 return MAP2_MAGIC;
23}
24
25SEC("tp_btf/sys_enter")
26int BPF_PROG(sys_enter, struct pt_regs *regs, long id)
27{
28 struct st_ops_args args = {};
29 struct task_struct *task;
30 int ret;
31
32 task = bpf_get_current_task_btf();
33 if (!test_pid || task->pid != test_pid)
34 return 0;
35
36 ret = bpf_kfunc_multi_st_ops_test_1(&args);
37 if (ret != MAP2_MAGIC)
38 test_err++;
39
40 return 0;
41}
42
43SEC("syscall")
44int syscall_prog(void *ctx)
45{
46 struct st_ops_args args = {};
47 int ret;
48
49 ret = bpf_kfunc_multi_st_ops_test_1(&args);
50 if (ret != MAP2_MAGIC)
51 test_err++;
52
53 return 0;
54}
55
56SEC(".struct_ops.link")
57struct bpf_testmod_multi_st_ops st_ops_map = {
58 .test_1 = (void *)test_1,
59};