tools/testing/selftests/net/mptcp/mptcp_inq.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/mptcp/mptcp_inq.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/mptcp/mptcp_inq.c- Extension
.c- Size
- 11570 bytes
- Lines
- 615
- 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 IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
assert.herrno.hfcntl.hlimits.hstring.hstdarg.hstdbool.hstdint.hinttypes.hstdio.hstdlib.hstrings.hunistd.htime.hsys/ioctl.hsys/random.hsys/socket.hsys/types.hsys/wait.hnetdb.hnetinet/in.hlinux/tcp.hlinux/sockios.hlinux/compiler.h
Detected Declarations
function die_perrorfunction die_usagefunction xerrorfunction xgetaddrinfofunction sock_listen_mptcpfunction sock_connect_mptcpfunction protostr_to_numfunction parse_optsfunction wait_for_ackfunction connect_one_serverfunction get_tcp_inqfunction process_one_clientfunction xacceptfunction serverfunction clientfunction init_rngfunction xforkfunction rcheckfunction main
Annotated Snippet
if (err == EAI_SOCKTYPE) {
hints->ai_protocol = IPPROTO_TCP;
goto again;
}
errstr = getxinfo_strerr(err);
fprintf(stderr, "Fatal: getaddrinfo(%s:%s): %s\n",
node ? node : "", service ? service : "", errstr);
exit(1);
}
}
static int sock_listen_mptcp(const char * const listenaddr,
const char * const port)
{
int sock = -1;
struct addrinfo hints = {
.ai_protocol = IPPROTO_MPTCP,
.ai_socktype = SOCK_STREAM,
.ai_flags = AI_PASSIVE | AI_NUMERICHOST
};
hints.ai_family = pf;
struct addrinfo *a, *addr;
int one = 1;
xgetaddrinfo(listenaddr, port, &hints, &addr);
hints.ai_family = pf;
for (a = addr; a; a = a->ai_next) {
sock = socket(a->ai_family, a->ai_socktype, proto_rx);
if (sock < 0)
continue;
if (-1 == setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &one,
sizeof(one)))
perror("setsockopt");
if (bind(sock, a->ai_addr, a->ai_addrlen) == 0)
break; /* success */
perror("bind");
close(sock);
sock = -1;
}
freeaddrinfo(addr);
if (sock < 0)
xerror("could not create listen socket");
if (listen(sock, 20))
die_perror("listen");
return sock;
}
static int sock_connect_mptcp(const char * const remoteaddr,
const char * const port, int proto)
{
struct addrinfo hints = {
.ai_protocol = IPPROTO_MPTCP,
.ai_socktype = SOCK_STREAM,
};
struct addrinfo *a, *addr;
int sock = -1;
hints.ai_family = pf;
xgetaddrinfo(remoteaddr, port, &hints, &addr);
for (a = addr; a; a = a->ai_next) {
sock = socket(a->ai_family, a->ai_socktype, proto);
if (sock < 0)
continue;
if (connect(sock, a->ai_addr, a->ai_addrlen) == 0)
break; /* success */
die_perror("connect");
}
if (sock < 0)
xerror("could not create connect socket");
freeaddrinfo(addr);
return sock;
}
Annotation
- Immediate include surface: `assert.h`, `errno.h`, `fcntl.h`, `limits.h`, `string.h`, `stdarg.h`, `stdbool.h`, `stdint.h`.
- Detected declarations: `function die_perror`, `function die_usage`, `function xerror`, `function xgetaddrinfo`, `function sock_listen_mptcp`, `function sock_connect_mptcp`, `function protostr_to_num`, `function parse_opts`, `function wait_for_ack`, `function connect_one_server`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.