1 // SPDX-License-Identifier: GPL-2.0
2
3 #include "vmlinux.h"
4 #include <bpf/bpf_helpers.h>
5 #include <bpf/bpf_tracing.h>
6
7 struct {
8 __uint(type, BPF_MAP_TYPE_ARRAY);
9 __uint(max_entries, 8);
10 __type(key, __u32);
11 __type(value, __u64);
12 } test_array SEC(".maps");
13
14 unsigned int triggered;
15
test_cb(struct bpf_map * map,__u32 * key,__u64 * val,void * data)16 static __u64 test_cb(struct bpf_map *map, __u32 *key, __u64 *val, void *data)
17 {
18 return 1;
19 }
20
21 SEC("fexit/bpf_testmod_return_ptr")
BPF_PROG(handle_fexit_ret_subprogs,int arg,struct file * ret)22 int BPF_PROG(handle_fexit_ret_subprogs, int arg, struct file *ret)
23 {
24 *(volatile long *)ret;
25 *(volatile int *)&ret->f_mode;
26 bpf_for_each_map_elem(&test_array, test_cb, NULL, 0);
27 triggered++;
28 return 0;
29 }
30
31 SEC("fexit/bpf_testmod_return_ptr")
BPF_PROG(handle_fexit_ret_subprogs2,int arg,struct file * ret)32 int BPF_PROG(handle_fexit_ret_subprogs2, int arg, struct file *ret)
33 {
34 *(volatile long *)ret;
35 *(volatile int *)&ret->f_mode;
36 bpf_for_each_map_elem(&test_array, test_cb, NULL, 0);
37 triggered++;
38 return 0;
39 }
40
41 SEC("fexit/bpf_testmod_return_ptr")
BPF_PROG(handle_fexit_ret_subprogs3,int arg,struct file * ret)42 int BPF_PROG(handle_fexit_ret_subprogs3, int arg, struct file *ret)
43 {
44 *(volatile long *)ret;
45 *(volatile int *)&ret->f_mode;
46 bpf_for_each_map_elem(&test_array, test_cb, NULL, 0);
47 triggered++;
48 return 0;
49 }
50
51 char _license[] SEC("license") = "GPL";
52