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/* Copyright Leon Hwang */
3
4#include "vmlinux.h"
5#include <bpf/bpf_helpers.h>
6#include <bpf/bpf_tracing.h>
7#include "bpf_test_utils.h"
8
9struct {
10 __uint(type, BPF_MAP_TYPE_PROG_ARRAY);
11 __uint(max_entries, 1);
12 __uint(key_size, sizeof(__u32));
13 __uint(value_size, sizeof(__u32));
14} jmp_table SEC(".maps");
15
16int count = 0;
17
18static __noinline
19int subprog_tail(void *ctx)
20{
21 bpf_tail_call_static(ctx, &jmp_table, 0);
22 return 0;
23}
24
25SEC("fentry/dummy")
26int BPF_PROG(fentry, struct sk_buff *skb)
27{
28 clobber_regs_stack();
29
30 count++;
31 subprog_tail(ctx);
32 subprog_tail(ctx);
33
34 return 0;
35}
36
37
38char _license[] SEC("license") = "GPL";