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