tools/testing/selftests/bpf/prog_tests/btf_map_in_map.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/btf_map_in_map.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/btf_map_in_map.c- Extension
.c- Size
- 4458 bytes
- Lines
- 141
- 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
test_progs.htest_btf_map_in_map.skel.h
Detected Declarations
function bpf_map_idfunction test_lookup_updatefunction test_diff_sizefunction test_btf_map_in_map
Annotated Snippet
if (CHECK_FAIL(err)) {
printf("failed to update hash_of_maps on iter #%d\n", i);
goto cleanup;
}
err = bpf_map_update_elem(outer_arr_fd, &key, &val, 0);
if (CHECK_FAIL(err)) {
printf("failed to update array_of_maps on iter #%d\n", i);
goto cleanup;
}
val = i % 2 ? map4_fd : map5_fd;
err = bpf_map_update_elem(outer_arr_dyn_fd, &key, &val, 0);
if (CHECK_FAIL(err)) {
printf("failed to update array_of_maps (dyn) on iter #%d\n", i);
goto cleanup;
}
}
map1_id = bpf_map_id(skel->maps.inner_map1);
map2_id = bpf_map_id(skel->maps.inner_map2);
CHECK(map1_id == 0, "map1_id", "failed to get ID 1\n");
CHECK(map2_id == 0, "map2_id", "failed to get ID 2\n");
cleanup:
test_btf_map_in_map__destroy(skel);
}
static void test_diff_size(void)
{
struct test_btf_map_in_map *skel;
int err, inner_map_fd, zero = 0;
skel = test_btf_map_in_map__open_and_load();
if (CHECK(!skel, "skel_open", "failed to open&load skeleton\n"))
return;
inner_map_fd = bpf_map__fd(skel->maps.sockarr_sz2);
err = bpf_map_update_elem(bpf_map__fd(skel->maps.outer_sockarr), &zero,
&inner_map_fd, 0);
CHECK(err, "outer_sockarr inner map size check",
"cannot use a different size inner_map\n");
inner_map_fd = bpf_map__fd(skel->maps.inner_map_sz2);
err = bpf_map_update_elem(bpf_map__fd(skel->maps.outer_arr), &zero,
&inner_map_fd, 0);
CHECK(!err, "outer_arr inner map size check",
"incorrectly updated with a different size inner_map\n");
test_btf_map_in_map__destroy(skel);
}
void test_btf_map_in_map(void)
{
if (test__start_subtest("lookup_update"))
test_lookup_update();
if (test__start_subtest("diff_size"))
test_diff_size();
}
Annotation
- Immediate include surface: `test_progs.h`, `test_btf_map_in_map.skel.h`.
- Detected declarations: `function bpf_map_id`, `function test_lookup_update`, `function test_diff_size`, `function test_btf_map_in_map`.
- 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.