tools/testing/selftests/bpf/prog_tests/skc_to_unix_sock.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/skc_to_unix_sock.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/skc_to_unix_sock.c- Extension
.c- Size
- 1349 bytes
- Lines
- 55
- 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.hsys/un.htest_skc_to_unix_sock.skel.h
Detected Declarations
function test_skc_to_unix_sock
Annotated Snippet
#include <test_progs.h>
#include <sys/un.h>
#include "test_skc_to_unix_sock.skel.h"
static const char *sock_path = "@skc_to_unix_sock";
void test_skc_to_unix_sock(void)
{
struct test_skc_to_unix_sock *skel;
struct sockaddr_un sockaddr;
int err, sockfd = 0;
skel = test_skc_to_unix_sock__open();
if (!ASSERT_OK_PTR(skel, "could not open BPF object"))
return;
skel->rodata->my_pid = getpid();
err = test_skc_to_unix_sock__load(skel);
if (!ASSERT_OK(err, "could not load BPF object"))
goto cleanup;
err = test_skc_to_unix_sock__attach(skel);
if (!ASSERT_OK(err, "could not attach BPF object"))
goto cleanup;
/* trigger unix_listen */
sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
if (!ASSERT_GT(sockfd, 0, "socket failed"))
goto cleanup;
memset(&sockaddr, 0, sizeof(sockaddr));
sockaddr.sun_family = AF_UNIX;
strscpy(sockaddr.sun_path, sock_path);
sockaddr.sun_path[0] = '\0';
err = bind(sockfd, (struct sockaddr *)&sockaddr, sizeof(sockaddr));
if (!ASSERT_OK(err, "bind failed"))
goto cleanup;
err = listen(sockfd, 1);
if (!ASSERT_OK(err, "listen failed"))
goto cleanup;
ASSERT_EQ(strcmp(skel->bss->path, sock_path), 0, "bpf_skc_to_unix_sock failed");
cleanup:
if (sockfd)
close(sockfd);
test_skc_to_unix_sock__destroy(skel);
}
Annotation
- Immediate include surface: `test_progs.h`, `sys/un.h`, `test_skc_to_unix_sock.skel.h`.
- Detected declarations: `function test_skc_to_unix_sock`.
- 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.