18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci#include <linux/bpf.h>
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#include <bpf/bpf_helpers.h>
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_cistruct {
78c2ecf20Sopenharmony_ci	__uint(type, BPF_MAP_TYPE_PROG_ARRAY);
88c2ecf20Sopenharmony_ci	__uint(max_entries, 5);
98c2ecf20Sopenharmony_ci	__uint(key_size, sizeof(__u32));
108c2ecf20Sopenharmony_ci	__uint(value_size, sizeof(__u32));
118c2ecf20Sopenharmony_ci} jmp_table SEC(".maps");
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ciSEC("classifier/0")
148c2ecf20Sopenharmony_ciint bpf_func_0(struct __sk_buff *skb)
158c2ecf20Sopenharmony_ci{
168c2ecf20Sopenharmony_ci	bpf_tail_call_static(skb, &jmp_table, 1);
178c2ecf20Sopenharmony_ci	return 0;
188c2ecf20Sopenharmony_ci}
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ciSEC("classifier/1")
218c2ecf20Sopenharmony_ciint bpf_func_1(struct __sk_buff *skb)
228c2ecf20Sopenharmony_ci{
238c2ecf20Sopenharmony_ci	bpf_tail_call_static(skb, &jmp_table, 2);
248c2ecf20Sopenharmony_ci	return 1;
258c2ecf20Sopenharmony_ci}
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ciSEC("classifier/2")
288c2ecf20Sopenharmony_ciint bpf_func_2(struct __sk_buff *skb)
298c2ecf20Sopenharmony_ci{
308c2ecf20Sopenharmony_ci	return 2;
318c2ecf20Sopenharmony_ci}
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ciSEC("classifier/3")
348c2ecf20Sopenharmony_ciint bpf_func_3(struct __sk_buff *skb)
358c2ecf20Sopenharmony_ci{
368c2ecf20Sopenharmony_ci	bpf_tail_call_static(skb, &jmp_table, 4);
378c2ecf20Sopenharmony_ci	return 3;
388c2ecf20Sopenharmony_ci}
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ciSEC("classifier/4")
418c2ecf20Sopenharmony_ciint bpf_func_4(struct __sk_buff *skb)
428c2ecf20Sopenharmony_ci{
438c2ecf20Sopenharmony_ci	bpf_tail_call_static(skb, &jmp_table, 3);
448c2ecf20Sopenharmony_ci	return 4;
458c2ecf20Sopenharmony_ci}
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ciSEC("classifier")
488c2ecf20Sopenharmony_ciint entry(struct __sk_buff *skb)
498c2ecf20Sopenharmony_ci{
508c2ecf20Sopenharmony_ci	bpf_tail_call_static(skb, &jmp_table, 0);
518c2ecf20Sopenharmony_ci	/* Check multi-prog update. */
528c2ecf20Sopenharmony_ci	bpf_tail_call_static(skb, &jmp_table, 2);
538c2ecf20Sopenharmony_ci	/* Check tail call limit. */
548c2ecf20Sopenharmony_ci	bpf_tail_call_static(skb, &jmp_table, 3);
558c2ecf20Sopenharmony_ci	return 3;
568c2ecf20Sopenharmony_ci}
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_cichar __license[] SEC("license") = "GPL";
598c2ecf20Sopenharmony_ciint _version SEC("version") = 1;
60