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
7struct {
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
14unsigned int triggered;
15
16static __u64 test_cb(struct bpf_map *map, __u32 *key, __u64 *val, void *data)
17{
18 return 1;
19}
20
21SEC("fexit/bpf_testmod_return_ptr")
22int 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
31SEC("fexit/bpf_testmod_return_ptr")
32int 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
41SEC("fexit/bpf_testmod_return_ptr")
42int 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
51char _license[] SEC("license") = "GPL";
52

source code of linux/tools/testing/selftests/bpf/progs/test_subprogs_extable.c