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 9 struct { 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 16 int count = 0; 17 18 static __noinline 19 int subprog_tail(void *ctx) 20 { 21 bpf_tail_call_static(ctx, &jmp_table, 0); 22 return 0; 23 } 24 25 SEC("fentry/dummy") 26 int 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 38 char _license[] SEC("license") = "GPL"; 39