xref: /linux/tools/testing/selftests/bpf/progs/test_global_func15.c (revision b83deaa741558babf4b8d51d34f6637ccfff1b26)
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 __noinline int foo(unsigned int *v)
7 {
8 	if (v)
9 		*v = bpf_get_prandom_u32();
10 
11 	return 0;
12 }
13 
14 SEC("cgroup_skb/ingress")
15 int test_cls(struct __sk_buff *skb)
16 {
17 	unsigned int v = 1;
18 
19 	foo(&v);
20 
21 	return v;
22 }
23