tools/testing/selftests/bpf/prog_tests/tailcalls.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/tailcalls.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/tailcalls.c- Extension
.c- Size
- 55912 bytes
- Lines
- 1971
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
unistd.htest_progs.hnetwork_helpers.htailcall_poke.skel.htailcall_bpf2bpf_hierarchy2.skel.htailcall_bpf2bpf_hierarchy3.skel.htailcall_freplace.skel.htc_bpf2bpf.skel.htailcall_fail.skel.htailcall_cgrp_storage_owner.skel.htailcall_cgrp_storage_no_storage.skel.htailcall_cgrp_storage.skel.htailcall_sleepable.skel.htailcall_bpf2bpf4.skel.htailcall_bpf2bpf6.skel.h
Detected Declarations
function test_tailcall_1function test_tailcall_2function test_tailcall_countfunction test_tailcall_3function test_tailcall_6function test_tailcall_4function test_tailcall_5function test_tailcall_bpf2bpf_1function test_tailcall_bpf2bpf_2function test_tailcall_bpf2bpf_3function test_tailcall_bpf2bpf_4function test_tailcall_bpf2bpf_6function test_tailcall_bpf2bpf_fentryfunction test_tailcall_bpf2bpf_fexitfunction test_tailcall_bpf2bpf_fentry_fexitfunction test_tailcall_bpf2bpf_fentry_entryfunction test_tailcall_pokefunction test_tailcall_hierarchy_countfunction test_tailcall_bpf2bpf_hierarchy_1function test_tailcall_bpf2bpf_hierarchy_fentryfunction test_tailcall_bpf2bpf_hierarchy_fexitfunction test_tailcall_bpf2bpf_hierarchy_fentry_fexitfunction test_tailcall_bpf2bpf_hierarchy_fentry_entryfunction test_tailcall_bpf2bpf_hierarchy_2function test_tailcall_bpf2bpf_hierarchy_3function test_tailcall_freplacefunction test_tailcall_bpf2bpf_freplacefunction test_tailcall_failurefunction test_tailcall_cgrp_storagefunction test_tailcall_cgrp_storage_diff_storagefunction test_tailcall_cgrp_storage_no_storagefunction test_tailcall_cgrp_storage_no_storage_leaffunction test_tailcall_cgrp_storage_no_storage_bridgefunction uprobe_sleepable_triggerfunction test_tailcall_sleepablefunction test_tailcalls
Annotated Snippet
if (!ASSERT_OK(err, "bpf_map__pin")) {
tailcall_poke__destroy(test);
break;
}
bpf_program__set_autoload(test->progs.test, true);
bpf_program__set_autoload(test->progs.call1, false);
bpf_program__set_autoload(test->progs.call2, false);
err = tailcall_poke__load(test);
tailcall_poke__destroy(test);
if (!ASSERT_OK(err, "tailcall_poke__load"))
break;
}
poke_thread_exit = 1;
ASSERT_OK(pthread_join(thread, NULL), "pthread_join");
out:
bpf_map__unpin(call->maps.jmp_table, JMP_TABLE);
tailcall_poke__destroy(call);
}
static void test_tailcall_hierarchy_count(const char *which, bool test_fentry,
bool test_fexit,
bool test_fentry_entry)
{
int err, map_fd, prog_fd, main_data_fd, fentry_data_fd = 0, fexit_data_fd = 0, i, val;
struct bpf_object *obj = NULL, *fentry_obj = NULL, *fexit_obj = NULL;
struct bpf_link *fentry_link = NULL, *fexit_link = NULL;
struct bpf_program *prog, *fentry_prog;
struct bpf_map *prog_array, *data_map;
int fentry_prog_fd;
char buff[128] = {};
LIBBPF_OPTS(bpf_test_run_opts, topts,
.data_in = buff,
.data_size_in = sizeof(buff),
.repeat = 1,
);
err = bpf_prog_test_load(which, BPF_PROG_TYPE_SCHED_CLS, &obj,
&prog_fd);
if (!ASSERT_OK(err, "load obj"))
return;
prog = bpf_object__find_program_by_name(obj, "entry");
if (!ASSERT_OK_PTR(prog, "find entry prog"))
goto out;
prog_fd = bpf_program__fd(prog);
if (!ASSERT_GE(prog_fd, 0, "prog_fd"))
goto out;
if (test_fentry_entry) {
fentry_obj = bpf_object__open_file("tailcall_bpf2bpf_hierarchy_fentry.bpf.o",
NULL);
if (!ASSERT_OK_PTR(fentry_obj, "open fentry_obj file"))
goto out;
fentry_prog = bpf_object__find_program_by_name(fentry_obj,
"fentry");
if (!ASSERT_OK_PTR(prog, "find fentry prog"))
goto out;
err = bpf_program__set_attach_target(fentry_prog, prog_fd,
"entry");
if (!ASSERT_OK(err, "set_attach_target entry"))
goto out;
err = bpf_object__load(fentry_obj);
if (!ASSERT_OK(err, "load fentry_obj"))
goto out;
fentry_link = bpf_program__attach_trace(fentry_prog);
if (!ASSERT_OK_PTR(fentry_link, "attach_trace"))
goto out;
fentry_prog_fd = bpf_program__fd(fentry_prog);
if (!ASSERT_GE(fentry_prog_fd, 0, "fentry_prog_fd"))
goto out;
prog_array = bpf_object__find_map_by_name(fentry_obj, "jmp_table");
if (!ASSERT_OK_PTR(prog_array, "find jmp_table"))
goto out;
map_fd = bpf_map__fd(prog_array);
if (!ASSERT_GE(map_fd, 0, "map_fd"))
goto out;
Annotation
- Immediate include surface: `unistd.h`, `test_progs.h`, `network_helpers.h`, `tailcall_poke.skel.h`, `tailcall_bpf2bpf_hierarchy2.skel.h`, `tailcall_bpf2bpf_hierarchy3.skel.h`, `tailcall_freplace.skel.h`, `tc_bpf2bpf.skel.h`.
- Detected declarations: `function test_tailcall_1`, `function test_tailcall_2`, `function test_tailcall_count`, `function test_tailcall_3`, `function test_tailcall_6`, `function test_tailcall_4`, `function test_tailcall_5`, `function test_tailcall_bpf2bpf_1`, `function test_tailcall_bpf2bpf_2`, `function test_tailcall_bpf2bpf_3`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.