179d49ba0SDaniel Borkmann // SPDX-License-Identifier: GPL-2.0 279d49ba0SDaniel Borkmann #include <linux/bpf.h> 379d49ba0SDaniel Borkmann 43e689141SToke Høiland-Jørgensen #include <bpf/bpf_helpers.h> 579d49ba0SDaniel Borkmann 679d49ba0SDaniel Borkmann struct { 779d49ba0SDaniel Borkmann __uint(type, BPF_MAP_TYPE_PROG_ARRAY); 879d49ba0SDaniel Borkmann __uint(max_entries, 3); 979d49ba0SDaniel Borkmann __uint(key_size, sizeof(__u32)); 1079d49ba0SDaniel Borkmann __uint(value_size, sizeof(__u32)); 1179d49ba0SDaniel Borkmann } jmp_table SEC(".maps"); 1279d49ba0SDaniel Borkmann 13256eab48SAndrii Nakryiko int selector = 0; 1479d49ba0SDaniel Borkmann 1579d49ba0SDaniel Borkmann #define TAIL_FUNC(x) \ 16*c22bdd28SAndrii Nakryiko SEC("tc") \ 17*c22bdd28SAndrii Nakryiko int classifier_##x(struct __sk_buff *skb) \ 1879d49ba0SDaniel Borkmann { \ 1979d49ba0SDaniel Borkmann return x; \ 2079d49ba0SDaniel Borkmann } 2179d49ba0SDaniel Borkmann TAIL_FUNC(0) 2279d49ba0SDaniel Borkmann TAIL_FUNC(1) 2379d49ba0SDaniel Borkmann TAIL_FUNC(2) 2479d49ba0SDaniel Borkmann 25*c22bdd28SAndrii Nakryiko SEC("tc") entry(struct __sk_buff * skb)2679d49ba0SDaniel Borkmannint entry(struct __sk_buff *skb) 2779d49ba0SDaniel Borkmann { 2879d49ba0SDaniel Borkmann int idx = 0; 2979d49ba0SDaniel Borkmann 3079d49ba0SDaniel Borkmann if (selector == 1234) 3179d49ba0SDaniel Borkmann idx = 1; 3279d49ba0SDaniel Borkmann else if (selector == 5678) 3379d49ba0SDaniel Borkmann idx = 2; 3479d49ba0SDaniel Borkmann 3579d49ba0SDaniel Borkmann bpf_tail_call(skb, &jmp_table, idx); 3679d49ba0SDaniel Borkmann return 3; 3779d49ba0SDaniel Borkmann } 3879d49ba0SDaniel Borkmann 3979d49ba0SDaniel Borkmann char __license[] SEC("license") = "GPL"; 40