tools/testing/selftests/bpf/prog_tests/dynptr.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/dynptr.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/dynptr.c- Extension
.c- Size
- 5112 bytes
- Lines
- 197
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
test_progs.hnetwork_helpers.hdynptr_fail.skel.hdynptr_success.skel.h
Detected Declarations
enum test_setup_typefunction verify_successfunction test_dynptr
Annotated Snippet
if (!ASSERT_OK_PTR(link, "bpf_program__attach")) {
bpf_object__close(obj);
goto cleanup;
}
err = bpf_prog_test_run_opts(aux_prog_fd, &topts);
bpf_link__destroy(link);
bpf_object__close(obj);
if (!ASSERT_OK(err, "test_run"))
goto cleanup;
break;
}
case SETUP_XDP_PROG:
{
char data[90000];
int err, prog_fd;
LIBBPF_OPTS(bpf_test_run_opts, opts,
.data_in = &data,
.repeat = 1,
);
if (getpagesize() == PAGE_SIZE_64K)
opts.data_size_in = sizeof(data);
else
opts.data_size_in = 5000;
prog_fd = bpf_program__fd(prog);
err = bpf_prog_test_run_opts(prog_fd, &opts);
if (!ASSERT_OK(err, "test_run"))
goto cleanup;
break;
}
}
ASSERT_EQ(skel->bss->err, 0, "err");
cleanup:
dynptr_success__destroy(skel);
}
void test_dynptr(void)
{
int i;
for (i = 0; i < ARRAY_SIZE(success_tests); i++) {
if (!test__start_subtest(success_tests[i].prog_name))
continue;
verify_success(success_tests[i].prog_name, success_tests[i].type);
}
RUN_TESTS(dynptr_fail);
}
Annotation
- Immediate include surface: `test_progs.h`, `network_helpers.h`, `dynptr_fail.skel.h`, `dynptr_success.skel.h`.
- Detected declarations: `enum test_setup_type`, `function verify_success`, `function test_dynptr`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.