Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 #include <stddef.h>
0003 #include <linux/bpf.h>
0004 #include <bpf/bpf_helpers.h>
0005 
0006 struct S {
0007     int x;
0008 };
0009 
0010 __noinline int foo(const struct S *s)
0011 {
0012     if (s)
0013         return bpf_get_prandom_u32() < s->x;
0014 
0015     return 0;
0016 }
0017 
0018 SEC("cgroup_skb/ingress")
0019 int test_cls(struct __sk_buff *skb)
0020 {
0021     const struct S *s = (const struct S *)(0xbedabeda);
0022 
0023     return foo(s);
0024 }