xref: /linux/tools/testing/selftests/bpf/progs/test_global_func11.c (revision 164666fa66669d437bdcc8d5f1744a2aee73be41)
1 // SPDX-License-Identifier: GPL-2.0-only
2 #include <stddef.h>
3 #include <linux/bpf.h>
4 #include <bpf/bpf_helpers.h>
5 
6 struct S {
7 	int x;
8 };
9 
10 __noinline int foo(const struct S *s)
11 {
12 	return s ? bpf_get_prandom_u32() < s->x : 0;
13 }
14 
15 SEC("cgroup_skb/ingress")
16 int test_cls(struct __sk_buff *skb)
17 {
18 	return foo((const void *)skb);
19 }
20