tools/testing/selftests/net/tcp_ao/lib/sock.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/tcp_ao/lib/sock.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/tcp_ao/lib/sock.c- Extension
.c- Size
- 18209 bytes
- Lines
- 731
- 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
alloca.hfcntl.hinttypes.hstring.h../../../../../include/linux/kernel.h../../../../../include/linux/stringify.haolib.h
Detected Declarations
function __test_listen_socketfunction __test_wait_fdfunction test_wait_fdfunction __skpair_poll_should_stopfunction __test_skpair_pollfunction __test_connect_socketfunction test_skpair_wait_pollfunction _test_skpair_connect_pollfunction __test_set_md5function test_prepare_key_sockaddrfunction test_get_ao_keys_nrfunction test_get_one_aofunction test_get_ao_infofunction test_set_ao_infofunction test_cmp_getsockopt_setsockoptfunction setsockoptfunction test_cmp_getsockopt_setsockopt_aofunction test_get_tcp_countersfunction test_cmp_countersfunction test_assert_counters_skfunction test_assert_counters_keyfunction test_tcp_counters_freefunction _test_server_runfunction test_server_runfunction test_skpair_serverfunction test_client_loopfunction test_client_verifyfunction test_skpair_client
Annotated Snippet
if (errno != EINPROGRESS) {
err = -errno;
goto out;
}
if (async)
return sk;
err = test_wait_fd(sk, TEST_TIMEOUT_SEC, 1);
if (err)
goto out;
}
return sk;
out:
close(sk);
return err;
}
int test_skpair_wait_poll(int sk, bool write,
test_cnt cond, volatile int *err)
{
struct tcp_counters c;
int ret;
*err = 0;
if (test_get_tcp_counters(sk, &c))
test_error("test_get_tcp_counters()");
synchronize_threads(); /* 1: init skpair & read nscounters */
ret = __test_skpair_poll(sk, write, TEST_TIMEOUT_SEC, &c, cond, err);
test_tcp_counters_free(&c);
return ret;
}
int _test_skpair_connect_poll(int sk, const char *device,
void *addr, size_t addr_sz,
test_cnt condition, volatile int *err)
{
struct tcp_counters c;
int ret;
*err = 0;
if (test_get_tcp_counters(sk, &c))
test_error("test_get_tcp_counters()");
synchronize_threads(); /* 1: init skpair & read nscounters */
ret = __test_connect_socket(sk, device, addr, addr_sz, true);
if (ret < 0) {
test_tcp_counters_free(&c);
return (*err = ret);
}
ret = __test_skpair_poll(sk, 1, TEST_TIMEOUT_SEC, &c, condition, err);
if (ret < 0)
close(sk);
test_tcp_counters_free(&c);
return ret;
}
int __test_set_md5(int sk, void *addr, size_t addr_sz, uint8_t prefix,
int vrf, const char *password)
{
size_t pwd_len = strlen(password);
struct tcp_md5sig md5sig = {};
md5sig.tcpm_keylen = pwd_len;
memcpy(md5sig.tcpm_key, password, pwd_len);
md5sig.tcpm_flags = TCP_MD5SIG_FLAG_PREFIX;
md5sig.tcpm_prefixlen = prefix;
if (vrf >= 0) {
md5sig.tcpm_flags |= TCP_MD5SIG_FLAG_IFINDEX;
md5sig.tcpm_ifindex = (uint8_t)vrf;
}
memcpy(&md5sig.tcpm_addr, addr, addr_sz);
errno = 0;
return setsockopt(sk, IPPROTO_TCP, TCP_MD5SIG_EXT,
&md5sig, sizeof(md5sig));
}
int test_prepare_key_sockaddr(struct tcp_ao_add *ao, const char *alg,
void *addr, size_t addr_sz, bool set_current, bool set_rnext,
uint8_t prefix, uint8_t vrf, uint8_t sndid, uint8_t rcvid,
uint8_t maclen, uint8_t keyflags,
uint8_t keylen, const char *key)
{
memset(ao, 0, sizeof(struct tcp_ao_add));
ao->set_current = !!set_current;
ao->set_rnext = !!set_rnext;
ao->prefix = prefix;
ao->sndid = sndid;
Annotation
- Immediate include surface: `alloca.h`, `fcntl.h`, `inttypes.h`, `string.h`, `../../../../../include/linux/kernel.h`, `../../../../../include/linux/stringify.h`, `aolib.h`.
- Detected declarations: `function __test_listen_socket`, `function __test_wait_fd`, `function test_wait_fd`, `function __skpair_poll_should_stop`, `function __test_skpair_poll`, `function __test_connect_socket`, `function test_skpair_wait_poll`, `function _test_skpair_connect_poll`, `function __test_set_md5`, `function test_prepare_key_sockaddr`.
- 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.