1 // SPDX-License-Identifier: GPL-2.0
3 #include <bpf/bpf_helpers.h>
6 __uint(type, BPF_MAP_TYPE_ARRAY);
7 __uint(max_entries, 1);
8 __uint(key_size, sizeof(__u32));
9 __uint(value_size, sizeof(__u32));
10 } nop_table SEC(".maps");
13 __uint(type, BPF_MAP_TYPE_PROG_ARRAY);
14 __uint(max_entries, 3);
15 __uint(key_size, sizeof(__u32));
16 __uint(value_size, sizeof(__u32));
17 } jmp_table SEC(".maps");
22 static __always_inline int subprog_noise(void)
26 bpf_map_lookup_elem(&nop_table, &key);
31 int subprog_tail_2(struct __sk_buff *skb)
35 bpf_tail_call_static(skb, &jmp_table, 2);
40 int subprog_tail_1(struct __sk_buff *skb)
42 bpf_tail_call_static(skb, &jmp_table, 1);
47 int subprog_tail(struct __sk_buff *skb)
49 bpf_tail_call_static(skb, &jmp_table, 0);
54 int classifier_1(struct __sk_buff *skb)
56 return subprog_tail_2(skb);
60 int classifier_2(struct __sk_buff *skb)
63 return subprog_tail_2(skb);
67 int classifier_0(struct __sk_buff *skb)
69 return subprog_tail_1(skb);
73 int entry(struct __sk_buff *skb)
75 return subprog_tail(skb);
78 char __license[] SEC("license") = "GPL";