tools/testing/selftests/net/tcp_ao/rst.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/tcp_ao/rst.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/tcp_ao/rst.c- Extension
.c- Size
- 13923 bytes
- Lines
- 460
- 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
inttypes.h../../../../include/linux/kernel.haolib.h
Detected Declarations
function netstats_checkfunction tcp_send_active_resetfunction test_server_active_rstfunction test_server_passive_rstfunction test_wait_fdsfunction test_client_active_rstfunction test_client_passive_rstfunction main
Annotated Snippet
if (FD_ISSET(sk[i], &fds)) {
if (is_writable)
is_writable[i] = true;
FD_CLR(sk[i], &left);
wait_for--;
continue;
}
if (FD_ISSET(sk[i], &efds)) {
FD_CLR(sk[i], &left);
wait_for--;
}
}
} while (wait_for > 0);
return 0;
}
static void test_client_active_rst(unsigned int port)
{
int i, sk[3], err;
bool is_writable[ARRAY_SIZE(sk)] = {false};
unsigned int last = ARRAY_SIZE(sk) - 1;
for (i = 0; i < ARRAY_SIZE(sk); i++) {
sk[i] = socket(test_family, SOCK_STREAM, IPPROTO_TCP);
if (sk[i] < 0)
test_error("socket()");
if (test_add_key(sk[i], DEFAULT_TEST_PASSWORD,
this_ip_dest, -1, 100, 100))
test_error("setsockopt(TCP_AO_ADD_KEY)");
}
synchronize_threads(); /* 1: MKT added */
for (i = 0; i < last; i++) {
err = _test_connect_socket(sk[i], this_ip_dest, port, i != 0);
if (err < 0)
test_error("failed to connect()");
}
synchronize_threads(); /* 2: two connections: one accept()ed, another queued */
err = test_wait_fds(sk, last, is_writable, last, TEST_TIMEOUT_SEC);
if (err < 0)
test_error("test_wait_fds(): %d", err);
/* async connect() with third sk to get into request_sock_queue */
err = _test_connect_socket(sk[last], this_ip_dest, port, 1);
if (err < 0)
test_error("failed to connect()");
synchronize_threads(); /* 3: close listen socket */
if (test_client_verify(sk[0], packet_sz, quota / packet_sz))
test_fail("Failed to send data on connected socket");
else
test_ok("Verified established tcp connection");
synchronize_threads(); /* 4: finishing up */
synchronize_threads(); /* 5: closed active sk */
/*
* Wait for 2 connections: one accepted, another in the accept queue,
* the one in request_sock_queue won't get fully established, so
* doesn't receive an active RST, see inet_csk_listen_stop().
*/
err = test_wait_fds(sk, last, NULL, last, TEST_TIMEOUT_SEC);
if (err < 0)
test_error("select(): %d", err);
for (i = 0; i < ARRAY_SIZE(sk); i++) {
socklen_t slen = sizeof(err);
if (getsockopt(sk[i], SOL_SOCKET, SO_ERROR, &err, &slen))
test_error("getsockopt()");
if (is_writable[i] && err != ECONNRESET) {
test_fail("sk[%d] = %d, err = %d, connection wasn't reset",
i, sk[i], err);
} else {
test_ok("sk[%d] = %d%s", i, sk[i],
is_writable[i] ? ", connection was reset" : "");
}
}
synchronize_threads(); /* 6: counters checks */
}
static void test_client_passive_rst(unsigned int port)
{
struct tcp_counters cnt1, cnt2;
struct tcp_ao_repair ao_img;
struct tcp_sock_state img;
sockaddr_af saddr;
int sk, err;
Annotation
- Immediate include surface: `inttypes.h`, `../../../../include/linux/kernel.h`, `aolib.h`.
- Detected declarations: `function netstats_check`, `function tcp_send_active_reset`, `function test_server_active_rst`, `function test_server_passive_rst`, `function test_wait_fds`, `function test_client_active_rst`, `function test_client_passive_rst`, `function main`.
- 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.