tools/testing/selftests/bpf/progs/test_skc_to_unix_sock.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/test_skc_to_unix_sock.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/test_skc_to_unix_sock.c- Extension
.c- Size
- 840 bytes
- Lines
- 41
- 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
vmlinux.hbpf/bpf_helpers.hbpf/bpf_tracing.hbpf_tracing_net.h
Detected Declarations
function BPF_PROG
Annotated Snippet
#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
#include "bpf_tracing_net.h"
const volatile pid_t my_pid = 0;
char path[256] = {};
SEC("fentry/unix_listen")
int BPF_PROG(unix_listen, struct socket *sock, int backlog)
{
pid_t pid = bpf_get_current_pid_tgid() >> 32;
struct unix_sock *unix_sk;
int i, len;
if (pid != my_pid)
return 0;
unix_sk = (struct unix_sock *)bpf_skc_to_unix_sock(sock->sk);
if (!unix_sk)
return 0;
if (unix_sk->addr->name->sun_path[0])
return 0;
len = unix_sk->addr->len - sizeof(short);
path[0] = '@';
for (i = 1; i < len; i++) {
if (i >= (int)sizeof(struct sockaddr_un))
break;
path[i] = unix_sk->addr->name->sun_path[i];
}
return 0;
}
char _license[] SEC("license") = "GPL";
Annotation
- Immediate include surface: `vmlinux.h`, `bpf/bpf_helpers.h`, `bpf/bpf_tracing.h`, `bpf_tracing_net.h`.
- Detected declarations: `function BPF_PROG`.
- 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.