tools/testing/selftests/bpf/network_helpers.h
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/network_helpers.h
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/network_helpers.h- Extension
.h- Size
- 8425 bytes
- Lines
- 297
- 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.hsys/socket.hsys/types.hlinux/types.hlinux/if_ether.hlinux/if_packet.hlinux/if_tun.hlinux/ip.hlinux/ipv6.hlinux/ethtool.hlinux/sockios.hlinux/err.hnetinet/tcp.hnetinet/udp.hbpf/bpf_endian.hnet/if.hstdio.h
Detected Declarations
struct network_helper_optsstruct ipv4_packetstruct ipv6_packetstruct nstokenstruct tmonitor_ctxfunction csum_foldfunction csum_partialfunction build_ip_csumfunction csum_tcpudp_magicfunction csum_ipv6_magicfunction build_udp_v4_csumfunction build_udp_v6_csumfunction traffic_monitor_stop
Annotated Snippet
struct network_helper_opts {
int timeout_ms;
int proto;
/* +ve: Passed to listen() as-is.
* 0: Default when the test does not set
* a particular value during the struct init.
* It is changed to 1 before passing to listen().
* Most tests only have one on-going connection.
* -ve: It is changed to 0 before passing to listen().
* It is useful to force syncookie without
* changing the "tcp_syncookies" sysctl from 1 to 2.
*/
int backlog;
int (*post_socket_cb)(int fd, void *opts);
void *cb_opts;
};
/* ipv4 test vector */
struct ipv4_packet {
struct ethhdr eth;
struct iphdr iph;
struct tcphdr tcp;
} __packed;
extern struct ipv4_packet pkt_v4;
/* ipv6 test vector */
struct ipv6_packet {
struct ethhdr eth;
struct ipv6hdr iph;
struct tcphdr tcp;
} __packed;
extern struct ipv6_packet pkt_v6;
int settimeo(int fd, int timeout_ms);
int start_server_str(int family, int type, const char *addr_str, __u16 port,
const struct network_helper_opts *opts);
int start_server(int family, int type, const char *addr, __u16 port,
int timeout_ms);
int *start_reuseport_server(int family, int type, const char *addr_str,
__u16 port, int timeout_ms,
unsigned int nr_listens);
int start_server_addr(int type, const struct sockaddr_storage *addr, socklen_t len,
const struct network_helper_opts *opts);
void free_fds(int *fds, unsigned int nr_close_fds);
int client_socket(int family, int type,
const struct network_helper_opts *opts);
int connect_to_addr(int type, const struct sockaddr_storage *addr, socklen_t len,
const struct network_helper_opts *opts);
int connect_to_addr_str(int family, int type, const char *addr_str, __u16 port,
const struct network_helper_opts *opts);
int connect_to_fd(int server_fd, int timeout_ms);
int connect_to_fd_opts(int server_fd, const struct network_helper_opts *opts);
int connect_fd_to_fd(int client_fd, int server_fd, int timeout_ms);
int fastopen_connect(int server_fd, const char *data, unsigned int data_len,
int timeout_ms);
int make_sockaddr(int family, const char *addr_str, __u16 port,
struct sockaddr_storage *addr, socklen_t *len);
char *ping_command(int family);
int get_socket_local_port(int sock_fd);
int get_hw_ring_size(char *ifname, struct ethtool_ringparam *ring_param);
int set_hw_ring_size(char *ifname, struct ethtool_ringparam *ring_param);
int open_tuntap(const char *dev_name, bool need_mac);
struct nstoken;
/**
* open_netns() - Switch to specified network namespace by name.
*
* Returns token with which to restore the original namespace
* using close_netns().
*/
struct nstoken *open_netns(const char *name);
void close_netns(struct nstoken *token);
int send_recv_data(int lfd, int fd, uint32_t total_bytes);
int make_netns(const char *name);
int remove_netns(const char *name);
/**
* append_tid() - Append thread ID to the given string.
*
* @str: string to extend
* @sz: string's size
*
* 8 characters are used to append the thread ID (7 digits + '\0')
*
* Returns -1 on errors, 0 otherwise
*/
int append_tid(char *str, size_t sz);
static __u16 csum_fold(__u32 csum)
Annotation
- Immediate include surface: `arpa/inet.h`, `sys/socket.h`, `sys/types.h`, `linux/types.h`, `linux/if_ether.h`, `linux/if_packet.h`, `linux/if_tun.h`, `linux/ip.h`.
- Detected declarations: `struct network_helper_opts`, `struct ipv4_packet`, `struct ipv6_packet`, `struct nstoken`, `struct tmonitor_ctx`, `function csum_fold`, `function csum_partial`, `function build_ip_csum`, `function csum_tcpudp_magic`, `function csum_ipv6_magic`.
- 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.