tools/testing/selftests/net/tcp_ao/setsockopt-closed.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/tcp_ao/setsockopt-closed.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/tcp_ao/setsockopt-closed.c- Extension
.c- Size
- 30421 bytes
- Lines
- 1012
- 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 make_listenfunction test_vefify_ao_infofunction __setsockopt_checkedfunction setsockopt_checkedfunction prepare_defsfunction test_extendfunction extend_testsfunction test_optmem_limitfunction test_einval_add_keyfunction test_einval_del_keyfunction test_einval_ao_infofunction getsockopt_checkedfunction test_einval_get_keysfunction einval_testsfunction duplicate_testsfunction fetch_all_keysfunction prepare_test_keysfunction compare_mktsfunction filter_keys_checkedfunction filter_testsfunction main
Annotated Snippet
if (optname == TCP_AO_ADD_KEY) {
test_verify_socket_key(sk, optval);
} else if (optname == TCP_AO_INFO && !get) {
test_vefify_ao_info(sk, optval, tst2);
} else if (optname == TCP_AO_GET_KEYS) {
if (*len != sizeof(struct tcp_ao_getsockopt))
test_fail("%s%s: get keys returned wrong tcp_ao_getsockopt size",
tst, tst2);
}
}
close(sk);
}
static void setsockopt_checked(int sk, int optname, void *optval,
int err, const char *tst)
{
const char *cmd = NULL;
socklen_t len;
switch (optname) {
case TCP_AO_ADD_KEY:
cmd = "key add: ";
len = sizeof(struct tcp_ao_add);
break;
case TCP_AO_DEL_KEY:
cmd = "key del: ";
len = sizeof(struct tcp_ao_del);
break;
case TCP_AO_INFO:
cmd = "AO info set: ";
len = sizeof(struct tcp_ao_info_opt);
break;
default:
break;
}
__setsockopt_checked(sk, optname, false, optval, &len, err, cmd, tst);
}
static int prepare_defs(int cmd, void *optval)
{
int sk = socket(test_family, SOCK_STREAM, IPPROTO_TCP);
if (sk < 0)
test_error("socket()");
switch (cmd) {
case TCP_AO_ADD_KEY: {
struct tcp_ao_add *add = optval;
if (test_prepare_def_key(add, DEFAULT_TEST_PASSWORD, 0, this_ip_dest,
-1, 0, 100, 100))
test_error("prepare default tcp_ao_add");
break;
}
case TCP_AO_DEL_KEY: {
struct tcp_ao_del *del = optval;
if (test_add_key(sk, DEFAULT_TEST_PASSWORD, this_ip_dest,
DEFAULT_TEST_PREFIX, 100, 100))
test_error("add default key");
memset(del, 0, sizeof(struct tcp_ao_del));
del->sndid = 100;
del->rcvid = 100;
del->prefix = DEFAULT_TEST_PREFIX;
tcp_addr_to_sockaddr_in(&del->addr, &this_ip_dest, 0);
break;
}
case TCP_AO_INFO: {
struct tcp_ao_info_opt *info = optval;
if (test_add_key(sk, DEFAULT_TEST_PASSWORD, this_ip_dest,
DEFAULT_TEST_PREFIX, 100, 100))
test_error("add default key");
memset(info, 0, sizeof(struct tcp_ao_info_opt));
break;
}
case TCP_AO_GET_KEYS: {
struct tcp_ao_getsockopt *get = optval;
if (test_add_key(sk, DEFAULT_TEST_PASSWORD, this_ip_dest,
DEFAULT_TEST_PREFIX, 100, 100))
test_error("add default key");
memset(get, 0, sizeof(struct tcp_ao_getsockopt));
get->nkeys = 1;
get->get_all = 1;
break;
}
default:
test_error("unknown cmd");
Annotation
- Immediate include surface: `inttypes.h`, `../../../../include/linux/kernel.h`, `aolib.h`.
- Detected declarations: `function make_listen`, `function test_vefify_ao_info`, `function __setsockopt_checked`, `function setsockopt_checked`, `function prepare_defs`, `function test_extend`, `function extend_tests`, `function test_optmem_limit`, `function test_einval_add_key`, `function test_einval_del_key`.
- 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.