WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / bpf / progs / tailcall_bpf2bpf2.c
blob7b1c041838240ebcb893f9d03fa11db92b0e8343
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/bpf.h>
3 #include <bpf/bpf_helpers.h>
4 #include "bpf_legacy.h"
6 struct {
7 __uint(type, BPF_MAP_TYPE_PROG_ARRAY);
8 __uint(max_entries, 1);
9 __uint(key_size, sizeof(__u32));
10 __uint(value_size, sizeof(__u32));
11 } jmp_table SEC(".maps");
13 static __noinline
14 int subprog_tail(struct __sk_buff *skb)
16 if (load_byte(skb, 0))
17 bpf_tail_call_static(skb, &jmp_table, 1);
18 else
19 bpf_tail_call_static(skb, &jmp_table, 0);
20 return 1;
23 static volatile int count;
25 SEC("classifier/0")
26 int bpf_func_0(struct __sk_buff *skb)
28 count++;
29 return subprog_tail(skb);
32 SEC("classifier")
33 int entry(struct __sk_buff *skb)
35 bpf_tail_call_static(skb, &jmp_table, 0);
37 return 0;
40 char __license[] SEC("license") = "GPL";
41 int _version SEC("version") = 1;