tools/testing/selftests/net/sk_connect_zero_addr.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/sk_connect_zero_addr.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/sk_connect_zero_addr.c- Extension
.c- Size
- 1168 bytes
- Lines
- 63
- 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
arpa/inet.herror.herrno.hunistd.h
Detected Declarations
function main
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include <arpa/inet.h>
#include <error.h>
#include <errno.h>
#include <unistd.h>
int main(void)
{
int fd1, fd2, one = 1;
struct sockaddr_in6 bind_addr = {
.sin6_family = AF_INET6,
.sin6_port = htons(20000),
.sin6_flowinfo = htonl(0),
.sin6_addr = {},
.sin6_scope_id = 0,
};
inet_pton(AF_INET6, "::", &bind_addr.sin6_addr);
fd1 = socket(AF_INET6, SOCK_STREAM, IPPROTO_IP);
if (fd1 < 0) {
error(1, errno, "socket fd1");
return -1;
}
if (setsockopt(fd1, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one))) {
error(1, errno, "setsockopt(SO_REUSEADDR) fd1");
goto out_err1;
}
if (bind(fd1, (struct sockaddr *)&bind_addr, sizeof(bind_addr))) {
error(1, errno, "bind fd1");
goto out_err1;
}
if (listen(fd1, 0)) {
error(1, errno, "listen");
goto out_err1;
}
fd2 = socket(AF_INET6, SOCK_STREAM, IPPROTO_IP);
if (fd2 < 0) {
error(1, errno, "socket fd2");
goto out_err1;
}
if (connect(fd2, (struct sockaddr *)&bind_addr, sizeof(bind_addr))) {
error(1, errno, "bind fd2");
goto out_err2;
}
close(fd2);
close(fd1);
return 0;
out_err2:
close(fd2);
out_err1:
close(fd1);
return -1;
}
Annotation
- Immediate include surface: `arpa/inet.h`, `error.h`, `errno.h`, `unistd.h`.
- Detected declarations: `function main`.
- 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.