tools/testing/selftests/net/udpgso_bench_rx.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/udpgso_bench_rx.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/udpgso_bench_rx.c- Extension
.c- Size
- 8831 bytes
- Lines
- 410
- 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.hlimits.hlinux/errqueue.hlinux/if_packet.hlinux/socket.hlinux/sockios.hnet/ethernet.hnet/if.hnetinet/ip.hnetinet/ip6.hnetinet/tcp.hnetinet/udp.hpoll.hsched.hstdbool.hstdio.hstdint.hstdlib.hstring.hsys/ioctl.hsys/socket.hsys/stat.hsys/time.hsys/types.hsys/wait.hunistd.h
Detected Declarations
function sigint_handlerfunction setup_sockaddrfunction gettimeofday_msfunction do_pollfunction do_socketfunction do_flush_tcpfunction sanitized_charfunction do_verify_udpfunction recv_msgfunction do_flush_udpfunction usagefunction parse_optsfunction do_recvfunction main
Annotated Snippet
if (ret == 0) {
if (!timeout_ms)
continue;
timeout_ms -= 10;
if (timeout_ms <= 0) {
interrupted = true;
break;
}
/* no events and more time to wait, do poll again */
continue;
}
if (pfd.revents != POLLIN)
error(1, errno, "poll: 0x%x expected 0x%x\n",
pfd.revents, POLLIN);
} while (!ret);
}
static int do_socket(bool do_tcp)
{
int fd, val;
fd = socket(cfg_family, cfg_tcp ? SOCK_STREAM : SOCK_DGRAM, 0);
if (fd == -1)
error(1, errno, "socket");
val = 1 << 21;
if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, sizeof(val)))
error(1, errno, "setsockopt rcvbuf");
val = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val)))
error(1, errno, "setsockopt reuseport");
if (bind(fd, (void *)&cfg_bind_addr, cfg_alen))
error(1, errno, "bind");
if (do_tcp) {
int accept_fd = fd;
if (listen(accept_fd, 1))
error(1, errno, "listen");
do_poll(accept_fd, cfg_connect_timeout_ms);
if (interrupted)
exit(0);
fd = accept(accept_fd, NULL, NULL);
if (fd == -1)
error(1, errno, "accept");
if (close(accept_fd))
error(1, errno, "close accept fd");
}
return fd;
}
/* Flush all outstanding bytes for the tcp receive queue */
static void do_flush_tcp(int fd)
{
int ret;
while (true) {
/* MSG_TRUNC flushes up to len bytes */
ret = recv(fd, NULL, 1 << 21, MSG_TRUNC | MSG_DONTWAIT);
if (ret == -1 && errno == EAGAIN)
return;
if (ret == -1)
error(1, errno, "flush");
if (ret == 0) {
/* client detached */
exit(0);
}
packets++;
bytes += ret;
}
}
static char sanitized_char(char val)
{
return (val >= 'a' && val <= 'z') ? val : '.';
}
static void do_verify_udp(const char *data, int len)
{
char cur = data[0];
int i;
Annotation
- Immediate include surface: `arpa/inet.h`, `error.h`, `errno.h`, `limits.h`, `linux/errqueue.h`, `linux/if_packet.h`, `linux/socket.h`, `linux/sockios.h`.
- Detected declarations: `function sigint_handler`, `function setup_sockaddr`, `function gettimeofday_ms`, `function do_poll`, `function do_socket`, `function do_flush_tcp`, `function sanitized_char`, `function do_verify_udp`, `function recv_msg`, `function do_flush_udp`.
- 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.