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     return bpf_get_prandom_u32() < s->x;
0013 }
0014 
0015 SEC("cgroup_skb/ingress")
0016 int test_cls(struct __sk_buff *skb)
0017 {
0018     const struct S s = {.x = skb->len };
0019 
0020     return foo(&s);
0021 }