xref: /linux/tools/testing/selftests/bpf/progs/test_global_func8.c (revision ae22a94997b8a03dcb3c922857c203246711f9d4)
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 #include "bpf_misc.h"
7 
8 __noinline int foo(struct __sk_buff *skb)
9 {
10 	return bpf_get_prandom_u32();
11 }
12 
13 SEC("cgroup_skb/ingress")
14 __success
15 int global_func8(struct __sk_buff *skb)
16 {
17 	if (!foo(skb))
18 		return 0;
19 
20 	return 1;
21 }
22