xref: /linux/tools/testing/selftests/bpf/progs/test_global_func8.c (revision 02680c23d7b3febe45ea3d4f9818c2b2dc89020a)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /* Copyright (c) 2020 Facebook */
3 #include <stddef.h>
4 #include <linux/bpf.h>
5 #include <bpf/bpf_helpers.h>
6 
7 __noinline int foo(struct __sk_buff *skb)
8 {
9 	return bpf_get_prandom_u32();
10 }
11 
12 SEC("cgroup_skb/ingress")
13 int test_cls(struct __sk_buff *skb)
14 {
15 	if (!foo(skb))
16 		return 0;
17 
18 	return 1;
19 }
20