Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 #include <linux/bpf.h>
0003 #include <bpf/bpf_helpers.h>
0004 
0005 #define __unused __attribute__((unused))
0006 
0007 struct {
0008     __uint(type, BPF_MAP_TYPE_PROG_ARRAY);
0009     __uint(max_entries, 1);
0010     __uint(key_size, sizeof(__u32));
0011     __uint(value_size, sizeof(__u32));
0012 } jmp_table SEC(".maps");
0013 
0014 int done = 0;
0015 
0016 SEC("tc")
0017 int classifier_0(struct __sk_buff *skb __unused)
0018 {
0019     done = 1;
0020     return 0;
0021 }
0022 
0023 static __noinline
0024 int subprog_tail(struct __sk_buff *skb)
0025 {
0026     /* Don't propagate the constant to the caller */
0027     volatile int ret = 1;
0028 
0029     bpf_tail_call_static(skb, &jmp_table, 0);
0030     return ret;
0031 }
0032 
0033 SEC("tc")
0034 int entry(struct __sk_buff *skb)
0035 {
0036     /* Have data on stack which size is not a multiple of 8 */
0037     volatile char arr[1] = {};
0038 
0039     return subprog_tail(skb);
0040 }
0041 
0042 char __license[] SEC("license") = "GPL";