diff options
author | Toke Høiland-Jørgensen <toke@redhat.com> | 2022-06-06 09:52:52 +0200 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2022-06-07 10:41:20 -0700 |
commit | 2cf7b7ffdae519b284f1406012b52e2282fa36bf (patch) | |
tree | d1a8f9aa36309f7678a94e58b53bf9987e457091 /tools/testing/selftests/bpf/progs/freplace_global_func.c | |
parent | bpf: Fix calling global functions from BPF_PROG_TYPE_EXT programs (diff) | |
download | linux-dev-2cf7b7ffdae519b284f1406012b52e2282fa36bf.tar.xz linux-dev-2cf7b7ffdae519b284f1406012b52e2282fa36bf.zip |
selftests/bpf: Add selftest for calling global functions from freplace
Add a selftest that calls a global function with a context object parameter
from an freplace function to check that the program context type is
correctly converted to the freplace target when fetching the context type
from the kernel BTF.
v2:
- Trim includes
- Get rid of global function
- Use __noinline
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/r/20220606075253.28422-2-toke@redhat.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to '')
-rw-r--r-- | tools/testing/selftests/bpf/progs/freplace_global_func.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/freplace_global_func.c b/tools/testing/selftests/bpf/progs/freplace_global_func.c new file mode 100644 index 000000000000..96cb61a6ce87 --- /dev/null +++ b/tools/testing/selftests/bpf/progs/freplace_global_func.c @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <linux/bpf.h> +#include <bpf/bpf_helpers.h> + +__noinline +int test_ctx_global_func(struct __sk_buff *skb) +{ + volatile int retval = 1; + return retval; +} + +SEC("freplace/test_pkt_access") +int new_test_pkt_access(struct __sk_buff *skb) +{ + return test_ctx_global_func(skb); +} + +char _license[] SEC("license") = "GPL"; |