diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2021-03-25 11:46:10 -0700 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2021-03-25 11:46:10 -0700 |
commit | 5acac83bf2e42f51ab9fd315d657798754bf0bb8 (patch) | |
tree | 564be60664226649f00798cc3afb72d72d0ed24d /tools/testing/selftests/bpf/progs/test_global_func13.c | |
parent | Input: cyttsp - verbose error on soft reset (diff) | |
parent | Linux 5.12-rc4 (diff) | |
download | linux-dev-5acac83bf2e42f51ab9fd315d657798754bf0bb8.tar.xz linux-dev-5acac83bf2e42f51ab9fd315d657798754bf0bb8.zip |
Merge tag 'v5.12-rc4' into next
Sync up with the mainline to bring in newest APIs.
Diffstat (limited to 'tools/testing/selftests/bpf/progs/test_global_func13.c')
-rw-r--r-- | tools/testing/selftests/bpf/progs/test_global_func13.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/test_global_func13.c b/tools/testing/selftests/bpf/progs/test_global_func13.c new file mode 100644 index 000000000000..ff8897c1ac22 --- /dev/null +++ b/tools/testing/selftests/bpf/progs/test_global_func13.c @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include <stddef.h> +#include <linux/bpf.h> +#include <bpf/bpf_helpers.h> + +struct S { + int x; +}; + +__noinline int foo(const struct S *s) +{ + if (s) + return bpf_get_prandom_u32() < s->x; + + return 0; +} + +SEC("cgroup_skb/ingress") +int test_cls(struct __sk_buff *skb) +{ + const struct S *s = (const struct S *)(0xbedabeda); + + return foo(s); +} |