Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
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, 1);
0009     __uint(key_size, sizeof(__u32));
0010     __uint(value_size, sizeof(__u32));
0011 } jmp_table SEC(".maps");
0012 
0013 int count, which;
0014 
0015 SEC("tc")
0016 int classifier_0(struct __sk_buff *skb)
0017 {
0018     count++;
0019     if (__builtin_constant_p(which))
0020         __bpf_unreachable();
0021     bpf_tail_call(skb, &jmp_table, which);
0022     return 1;
0023 }
0024 
0025 SEC("tc")
0026 int entry(struct __sk_buff *skb)
0027 {
0028     if (__builtin_constant_p(which))
0029         __bpf_unreachable();
0030     bpf_tail_call(skb, &jmp_table, which);
0031     return 0;
0032 }
0033 
0034 char __license[] SEC("license") = "GPL";