tools/testing/selftests/net/nettest.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/nettest.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/nettest.c- Extension
.c- Size
- 47224 bytes
- Lines
- 2255
- 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
features.hsys/types.hsys/ioctl.hsys/socket.hsys/wait.hlinux/tcp.hlinux/udp.harpa/inet.hnet/if.hnetinet/in.hnetinet/ip.hnetdb.hfcntl.hlibgen.hlimits.hsched.hstdarg.hstdio.hstdlib.hstring.hunistd.htime.herrno.hgetopt.hlinux/xfrm.hlinux/ipsec.hlinux/pfkeyv2.h
Detected Declarations
struct sock_argsenum addr_typefunction log_msgfunction log_errorfunction log_err_errnofunction log_addressfunction switch_nsfunction tcp_md5sigfunction tcp_md5_remotefunction get_ifidxfunction bind_to_devicefunction get_bind_to_devicefunction check_devicefunction set_pktinfo_v4function set_recvpktinfo_v6function set_recverr_v4function set_recverr_v6function set_unicast_iffunction set_multicast_iffunction set_membershipfunction set_freebindfunction set_broadcastfunction set_reuseportfunction set_reuseaddrfunction set_dsfieldfunction set_dontroutefunction str_to_uintfunction resolve_devicesfunction expected_addr_matchfunction show_sockstatfunction convert_addrfunction validate_addressesfunction get_index_from_cmsgfunction send_msg_no_cmsgfunction send_msg_cmsgfunction send_msgfunction socket_read_dgramfunction socket_read_streamfunction socket_readfunction stdin_to_socketfunction set_recv_attrfunction msg_loopfunction msock_initfunction msock_serverfunction msock_clientfunction bind_socketfunction config_xfrm_policyfunction lsock_init
Annotated Snippet
struct sock_args {
/* local address */
const char *local_addr_str;
const char *client_local_addr_str;
union {
struct in_addr in;
struct in6_addr in6;
} local_addr;
/* remote address */
const char *remote_addr_str;
union {
struct in_addr in;
struct in6_addr in6;
} remote_addr;
int scope_id; /* remote scope; v6 send only */
struct in_addr grp; /* multicast group */
unsigned int has_local_ip:1,
has_remote_ip:1,
has_grp:1,
has_expected_laddr:1,
has_expected_raddr:1,
bind_test_only:1,
client_dontroute:1,
server_dontroute:1;
unsigned short port;
int type; /* DGRAM, STREAM, RAW */
int protocol;
int version; /* AF_INET/AF_INET6 */
int use_setsockopt;
int use_freebind;
int use_cmsg;
uint8_t dsfield;
const char *dev;
const char *server_dev;
int ifindex;
const char *clientns;
const char *serverns;
const char *password;
const char *client_pw;
/* prefix for MD5 password */
const char *md5_prefix_str;
union {
struct sockaddr_in v4;
struct sockaddr_in6 v6;
} md5_prefix;
unsigned int prefix_len;
/* 0: default, -1: force off, +1: force on */
int bind_key_ifindex;
/* expected addresses and device index for connection */
const char *expected_dev;
const char *expected_server_dev;
int expected_ifindex;
/* local address */
const char *expected_laddr_str;
union {
struct in_addr in;
struct in6_addr in6;
} expected_laddr;
/* remote address */
const char *expected_raddr_str;
union {
struct in_addr in;
struct in6_addr in6;
} expected_raddr;
/* ESP in UDP encap test */
int use_xfrm;
/* use send() and connect() instead of sendto */
int datagram_connect;
};
static int server_mode;
static unsigned int prog_timeout = 5;
static unsigned int interactive;
static int iter = 1;
static char *msg = "Hello world!";
static int msglen;
static int quiet;
Annotation
- Immediate include surface: `features.h`, `sys/types.h`, `sys/ioctl.h`, `sys/socket.h`, `sys/wait.h`, `linux/tcp.h`, `linux/udp.h`, `arpa/inet.h`.
- Detected declarations: `struct sock_args`, `enum addr_type`, `function log_msg`, `function log_error`, `function log_err_errno`, `function log_address`, `function switch_ns`, `function tcp_md5sig`, `function tcp_md5_remote`, `function get_ifidx`.
- 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.