xref: /linux/tools/testing/selftests/bpf/progs/test_global_func8.c (revision ec8a42e7343234802b9054874fe01810880289ce)
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