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