diff options
| author | Johannes Berg <[email protected]> | 2024-10-09 08:59:14 +0200 | 
|---|---|---|
| committer | Johannes Berg <[email protected]> | 2024-10-09 08:59:22 +0200 | 
| commit | a0efa2f362a69e47b9d8b48f770ef3a0249a7911 (patch) | |
| tree | 384d2c79a9b613213ef7591583d820d18c7be9c3 /tools/testing/selftests/bpf/prog_tests/pro_epilogue.c | |
| parent | db03488897a70367aeafe82d07a78943d2a6068e (diff) | |
| parent | 36efaca9cb28a893cad98f0448c39a8b698859e2 (diff) | |
Merge net-next/main to resolve conflicts
The wireless-next tree was based on something older, and there
are now conflicts between -rc2 and work here. Merge net-next,
which has enough of -rc2 for the conflicts to happen, resolving
them in the process.
Signed-off-by: Johannes Berg <[email protected]>
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/pro_epilogue.c')
| -rw-r--r-- | tools/testing/selftests/bpf/prog_tests/pro_epilogue.c | 60 | 
1 files changed, 60 insertions, 0 deletions
| diff --git a/tools/testing/selftests/bpf/prog_tests/pro_epilogue.c b/tools/testing/selftests/bpf/prog_tests/pro_epilogue.c new file mode 100644 index 000000000000..509883e6823a --- /dev/null +++ b/tools/testing/selftests/bpf/prog_tests/pro_epilogue.c @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */ + +#include <test_progs.h> +#include "pro_epilogue.skel.h" +#include "epilogue_tailcall.skel.h" +#include "pro_epilogue_goto_start.skel.h" +#include "epilogue_exit.skel.h" + +struct st_ops_args { +	__u64 a; +}; + +static void test_tailcall(void) +{ +	LIBBPF_OPTS(bpf_test_run_opts, topts); +	struct epilogue_tailcall *skel; +	struct st_ops_args args; +	int err, prog_fd; + +	skel = epilogue_tailcall__open_and_load(); +	if (!ASSERT_OK_PTR(skel, "epilogue_tailcall__open_and_load")) +		return; + +	topts.ctx_in = &args; +	topts.ctx_size_in = sizeof(args); + +	skel->links.epilogue_tailcall = +		bpf_map__attach_struct_ops(skel->maps.epilogue_tailcall); +	if (!ASSERT_OK_PTR(skel->links.epilogue_tailcall, "attach_struct_ops")) +		goto done; + +	/* Both test_epilogue_tailcall and test_epilogue_subprog are +	 * patched with epilogue. When syscall_epilogue_tailcall() +	 * is run, test_epilogue_tailcall() is triggered. +	 * It executes a tail call and control is transferred to +	 * test_epilogue_subprog(). Only test_epilogue_subprog() +	 * does args->a += 1, thus final args.a value of 10001 +	 * guarantees that only the epilogue of the +	 * test_epilogue_subprog is executed. +	 */ +	memset(&args, 0, sizeof(args)); +	prog_fd = bpf_program__fd(skel->progs.syscall_epilogue_tailcall); +	err = bpf_prog_test_run_opts(prog_fd, &topts); +	ASSERT_OK(err, "bpf_prog_test_run_opts"); +	ASSERT_EQ(args.a, 10001, "args.a"); +	ASSERT_EQ(topts.retval, 10001 * 2, "topts.retval"); + +done: +	epilogue_tailcall__destroy(skel); +} + +void test_pro_epilogue(void) +{ +	RUN_TESTS(pro_epilogue); +	RUN_TESTS(pro_epilogue_goto_start); +	RUN_TESTS(epilogue_exit); +	if (test__start_subtest("tailcall")) +		test_tailcall(); +} |