tools/testing/selftests/bpf/prog_tests/mptcp.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/mptcp.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/mptcp.c- Extension
.c- Size
- 14465 bytes
- Lines
- 588
- 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
linux/const.hnetinet/in.htest_progs.hunistd.herrno.hcgroup_helpers.hnetwork_helpers.hmptcp_sock.skel.hmptcpify.skel.hmptcp_subflow.skel.hmptcp_sockmap.skel.h
Detected Declarations
struct __mptcp_infostruct mptcp_storagefunction start_mptcp_serverfunction verify_tskfunction get_msk_ca_namefunction verify_mskfunction run_testfunction test_basefunction send_bytefunction verify_mptcpifyfunction run_mptcpifyfunction test_mptcpifyfunction endpoint_initfunction wait_for_new_subflowsfunction run_subflowfunction test_subflowfunction test_sockmap_with_mptcp_fallbackfunction test_sockmap_reject_mptcpfunction test_mptcp_sockmapfunction test_mptcp
Annotated Snippet
struct __mptcp_info {
__u8 mptcpi_subflows;
__u8 mptcpi_add_addr_signal;
__u8 mptcpi_add_addr_accepted;
__u8 mptcpi_subflows_max;
__u8 mptcpi_add_addr_signal_max;
__u8 mptcpi_add_addr_accepted_max;
__u32 mptcpi_flags;
__u32 mptcpi_token;
__u64 mptcpi_write_seq;
__u64 mptcpi_snd_una;
__u64 mptcpi_rcv_nxt;
__u8 mptcpi_local_addr_used;
__u8 mptcpi_local_addr_max;
__u8 mptcpi_csum_enabled;
__u32 mptcpi_retransmits;
__u64 mptcpi_bytes_retrans;
__u64 mptcpi_bytes_sent;
__u64 mptcpi_bytes_received;
__u64 mptcpi_bytes_acked;
};
struct mptcp_storage {
__u32 invoked;
__u32 is_mptcp;
struct sock *sk;
__u32 token;
struct sock *first;
char ca_name[TCP_CA_NAME_MAX];
};
static int start_mptcp_server(int family, const char *addr_str, __u16 port,
int timeout_ms)
{
struct network_helper_opts opts = {
.timeout_ms = timeout_ms,
.proto = IPPROTO_MPTCP,
};
return start_server_str(family, SOCK_STREAM, addr_str, port, &opts);
}
static int verify_tsk(int map_fd, int client_fd)
{
int err, cfd = client_fd;
struct mptcp_storage val;
err = bpf_map_lookup_elem(map_fd, &cfd, &val);
if (!ASSERT_OK(err, "bpf_map_lookup_elem"))
return err;
if (!ASSERT_EQ(val.invoked, 1, "unexpected invoked count"))
err++;
if (!ASSERT_EQ(val.is_mptcp, 0, "unexpected is_mptcp"))
err++;
return err;
}
static void get_msk_ca_name(char ca_name[])
{
size_t len;
int fd;
fd = open("/proc/sys/net/ipv4/tcp_congestion_control", O_RDONLY);
if (!ASSERT_GE(fd, 0, "failed to open tcp_congestion_control"))
return;
len = read(fd, ca_name, TCP_CA_NAME_MAX);
if (!ASSERT_GT(len, 0, "failed to read ca_name"))
goto err;
if (len > 0 && ca_name[len - 1] == '\n')
ca_name[len - 1] = '\0';
err:
close(fd);
}
static int verify_msk(int map_fd, int client_fd, __u32 token)
{
char ca_name[TCP_CA_NAME_MAX];
int err, cfd = client_fd;
struct mptcp_storage val;
if (!ASSERT_GT(token, 0, "invalid token"))
return -1;
get_msk_ca_name(ca_name);
Annotation
- Immediate include surface: `linux/const.h`, `netinet/in.h`, `test_progs.h`, `unistd.h`, `errno.h`, `cgroup_helpers.h`, `network_helpers.h`, `mptcp_sock.skel.h`.
- Detected declarations: `struct __mptcp_info`, `struct mptcp_storage`, `function start_mptcp_server`, `function verify_tsk`, `function get_msk_ca_name`, `function verify_msk`, `function run_test`, `function test_base`, `function send_byte`, `function verify_mptcpify`.
- 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.