tools/testing/selftests/net/tcp_ao/icmps-discard.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/tcp_ao/icmps-discard.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/tcp_ao/icmps-discard.c- Extension
.c- Size
- 12009 bytes
- Lines
- 449
- 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.hlinux/icmp.hlinux/icmpv6.hlinux/ipv6.hnetinet/in.hnetinet/ip.hsys/socket.haolib.h../../../../include/linux/compiler.h
Detected Declarations
function serve_interferedfunction checksum4_nofoldfunction checksum4_foldfunction set_ip4hdrfunction icmp_interfere4function set_ip6hdrfunction csum_foldfunction csum_addfunction checksum6_nofoldfunction icmp6_checksumfunction icmp6_interferefunction get_rcv_nxtfunction icmp_interferefunction send_interferedfunction main
Annotated Snippet
if (saddr4->sin_family == AF_INET) {
icmp_interfere4(ICMP_DEST_UNREACH, ICMP_PROT_UNREACH,
rcv_nxt, saddr4, daddr4);
icmp_interfere4(ICMP_DEST_UNREACH, ICMP_PORT_UNREACH,
rcv_nxt, saddr4, daddr4);
icmp_interfere4(ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
rcv_nxt, saddr4, daddr4);
icmps_sent += 3;
} else if (saddr4->sin_family == AF_INET6) {
icmp6_interfere(ICMPV6_DEST_UNREACH,
ICMPV6_ADM_PROHIBITED,
rcv_nxt, saddr6, daddr6);
icmp6_interfere(ICMPV6_DEST_UNREACH,
ICMPV6_PORT_UNREACH,
rcv_nxt, saddr6, daddr6);
icmps_sent += 2;
} else {
test_error("Not ip address family");
}
}
}
static void send_interfered(int sk)
{
struct sockaddr_in6 src, dst;
socklen_t addr_sz;
addr_sz = sizeof(src);
if (getsockname(sk, &src, &addr_sz))
test_error("getsockname()");
addr_sz = sizeof(dst);
if (getpeername(sk, &dst, &addr_sz))
test_error("getpeername()");
while (1) {
uint32_t rcv_nxt;
if (test_client_verify(sk, packet_size, packets_nr)) {
test_fail("client: connection is broken");
return;
}
packets_sent += packets_nr;
rcv_nxt = get_rcv_nxt(sk);
icmp_interfere(packets_nr, rcv_nxt, (void *)&src, (void *)&dst);
}
}
static void *client_fn(void *arg)
{
int sk = socket(test_family, SOCK_STREAM, IPPROTO_TCP);
if (sk < 0)
test_error("socket()");
if (test_add_key(sk, DEFAULT_TEST_PASSWORD, this_ip_dest, -1, 100, 100))
test_error("setsockopt(TCP_AO_ADD_KEY)");
synchronize_threads();
if (test_connect_socket(sk, this_ip_dest, test_server_port) <= 0)
test_error("failed to connect()");
synchronize_threads();
send_interfered(sk);
/* Not expecting client to quit */
test_fail("client disconnected");
return NULL;
}
int main(int argc, char *argv[])
{
test_init(4, server_fn, client_fn);
return 0;
}
Annotation
- Immediate include surface: `inttypes.h`, `linux/icmp.h`, `linux/icmpv6.h`, `linux/ipv6.h`, `netinet/in.h`, `netinet/ip.h`, `sys/socket.h`, `aolib.h`.
- Detected declarations: `function serve_interfered`, `function checksum4_nofold`, `function checksum4_fold`, `function set_ip4hdr`, `function icmp_interfere4`, `function set_ip6hdr`, `function csum_fold`, `function csum_add`, `function checksum6_nofold`, `function icmp6_checksum`.
- 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.