0001
0002 #include <linux/bpf.h>
0003
0004 #include <bpf/bpf_helpers.h>
0005
0006 struct {
0007 __uint(type, BPF_MAP_TYPE_PROG_ARRAY);
0008 __uint(max_entries, 3);
0009 __uint(key_size, sizeof(__u32));
0010 __uint(value_size, sizeof(__u32));
0011 } jmp_table SEC(".maps");
0012
0013 int selector = 0;
0014
0015 #define TAIL_FUNC(x) \
0016 SEC("tc") \
0017 int classifier_##x(struct __sk_buff *skb) \
0018 { \
0019 return x; \
0020 }
0021 TAIL_FUNC(0)
0022 TAIL_FUNC(1)
0023 TAIL_FUNC(2)
0024
0025 SEC("tc")
0026 int entry(struct __sk_buff *skb)
0027 {
0028 bpf_tail_call(skb, &jmp_table, selector);
0029 return 3;
0030 }
0031
0032 char __license[] SEC("license") = "GPL";