tools/testing/selftests/net/mptcp/mptcp_connect.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/mptcp/mptcp_connect.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/mptcp/mptcp_connect.c- Extension
.c- Size
- 35000 bytes
- Lines
- 1633
- 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
errno.hlimits.hfcntl.hstring.hstdarg.hstdbool.hstdint.hstdio.hstdlib.hstrings.hsignal.hunistd.htime.hsys/ioctl.hsys/poll.hsys/random.hsys/sendfile.hsys/stat.hsys/socket.hsys/types.hsys/mman.harpa/inet.hnetdb.hnetinet/in.hlinux/tcp.hlinux/time_types.hlinux/sockios.hlinux/compiler.h
Detected Declarations
struct cfg_cmsg_typesstruct cfg_sockopt_typesstruct tcp_inq_statestruct wstateenum cfg_modeenum cfg_peekfunction die_usagefunction xerrorfunction handle_signalfunction xgetnameinfofunction xgetaddrinfofunction set_rcvbuffunction set_sndbuffunction set_markfunction set_transparentfunction set_mptfofunction do_ulp_sofunction sock_test_tcpulpfunction sock_listen_mptcpfunction sock_connect_mptcpfunction do_rnd_writefunction do_writefunction process_cmsgfunction do_recvmsg_cmsgfunction do_rnd_readfunction set_nonblockfunction shut_wrfunction copyfd_io_pollfunction do_recvfilefunction spool_buffunction do_mmapfunction get_infd_sizefunction do_sendfilefunction copyfd_io_mmapfunction copyfd_io_sendfilefunction do_splicefunction copyfd_io_splicefunction copyfd_iofunction check_sockaddrfunction check_getpeernamefunction check_getpeername_connectfunction maybe_closefunction main_loop_sfunction init_rngfunction xsetsockoptfunction apply_cmsg_typesfunction parse_cmsg_typesfunction parse_setsock_options
Annotated Snippet
static int do_mmap(int infd, int outfd, unsigned int size,
struct wstate *winfo)
{
char *inbuf = mmap(NULL, size, PROT_READ, MAP_SHARED, infd, 0);
ssize_t ret = 0, off = winfo->total_len;
size_t rem;
if (inbuf == MAP_FAILED) {
perror("mmap");
return 1;
}
ret = spool_buf(outfd, winfo);
if (ret < 0)
return ret;
rem = size - winfo->total_len;
while (rem > 0) {
ret = write(outfd, inbuf + off, rem);
if (ret < 0) {
perror("write");
break;
}
off += ret;
rem -= ret;
}
munmap(inbuf, size);
return rem;
}
static int get_infd_size(int fd)
{
struct stat sb;
ssize_t count;
int err;
err = fstat(fd, &sb);
if (err < 0) {
perror("fstat");
return -1;
}
if ((sb.st_mode & S_IFMT) != S_IFREG) {
fprintf(stderr, "%s: stdin is not a regular file\n", __func__);
return -2;
}
count = sb.st_size;
if (count > INT_MAX) {
fprintf(stderr, "File too large: %zu\n", count);
return -3;
}
return (int)count;
}
static int do_sendfile(int infd, int outfd, unsigned int count,
struct wstate *winfo)
{
int ret = spool_buf(outfd, winfo);
if (ret < 0)
return ret;
count -= winfo->total_len;
while (count > 0) {
ssize_t r;
r = sendfile(outfd, infd, NULL, count);
if (r < 0) {
perror("sendfile");
return 3;
}
count -= r;
}
return 0;
}
static int copyfd_io_mmap(int infd, int peerfd, int outfd,
unsigned int size, bool *in_closed_after_out,
struct wstate *winfo)
{
int err;
Annotation
- Immediate include surface: `errno.h`, `limits.h`, `fcntl.h`, `string.h`, `stdarg.h`, `stdbool.h`, `stdint.h`, `stdio.h`.
- Detected declarations: `struct cfg_cmsg_types`, `struct cfg_sockopt_types`, `struct tcp_inq_state`, `struct wstate`, `enum cfg_mode`, `enum cfg_peek`, `function die_usage`, `function xerror`, `function handle_signal`, `function xgetnameinfo`.
- 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.