net/ipv4/tcp_ao.c
Source file repositories/reference/linux-study-clean/net/ipv4/tcp_ao.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv4/tcp_ao.c- Extension
.c- Size
- 66649 bytes
- Lines
- 2420
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
crypto/aes-cbc-macs.hcrypto/sha1.hcrypto/sha2.hcrypto/utils.hlinux/inetdevice.hlinux/tcp.hnet/tcp.hnet/ipv6.hnet/icmp.htrace/events/tcp.h
Detected Declarations
struct tcp_ao_mac_ctxstruct kdf_input_blockfunction tcp_ao_mac_initfunction tcp_ao_mac_updatefunction tcp_ao_mac_finalfunction tcp_ao_calc_traffic_keyfunction tcp_ao_ignore_icmpfunction statesfunction hlist_for_each_entry_rcufunction ipv4_prefix_cmpfunction __tcp_ao_key_cmpfunction tcp_ao_key_cmpfunction hlist_for_each_entry_rcufunction tcp_ao_link_mktfunction tcp_ao_key_free_rcufunction tcp_ao_info_freefunction hlist_for_each_entry_safefunction tcp_ao_sk_omem_freefunction tcp_ao_destroy_sockfunction tcp_ao_time_waitfunction hlist_for_each_entry_safefunction tcp_v4_ao_calc_keyfunction tcp_v4_ao_calc_key_skfunction tcp_ao_calc_key_skfunction tcp_v4_ao_calc_key_rskfunction tcp_v4_ao_calc_key_skbfunction tcp_ao_calc_key_skbfunction tcp_v4_ao_hash_pseudoheaderfunction tcp_ao_hash_pseudoheaderfunction tcp_ao_compute_snefunction tcp_ao_hash_snefunction tcp_ao_hash_headerfunction tcp_ao_hash_hdrfunction tcp_ao_hash_skb_datafunction skb_frag_foreach_pagefunction tcp_ao_hash_skbfunction tcp_v4_ao_hash_skbfunction tcp_v4_ao_synack_hashfunction tcp_ao_prepare_resetfunction tcp_ao_transmit_skbfunction tcp_ao_syncookiefunction tcp_ao_verify_hashfunction tcp_inbound_ao_hashfunction tcp_ao_cache_traffic_keysfunction tcp_ao_connect_initfunction hlist_for_each_entry_safefunction tcp_ao_establishedfunction tcp_ao_finish_connect
Annotated Snippet
struct tcp_ao_mac_ctx {
enum tcp_ao_algo_id algo;
union {
struct hmac_sha1_ctx hmac_sha1;
struct hmac_sha256_ctx hmac_sha256;
struct {
struct aes_cmac_key key;
struct aes_cmac_ctx ctx;
} aes_cmac;
};
};
static const struct tcp_ao_algo *tcp_ao_find_algo(const char *name)
{
for (size_t i = 0; i < ARRAY_SIZE(tcp_ao_algos); i++) {
const struct tcp_ao_algo *algo = &tcp_ao_algos[i];
if (!algo->name)
continue;
if (WARN_ON_ONCE(algo->digest_size > TCP_AO_MAX_MAC_LEN ||
algo->digest_size >
TCP_AO_MAX_TRAFFIC_KEY_LEN))
continue;
if (strcmp(name, algo->name) == 0)
return algo;
}
return NULL;
}
static void tcp_ao_mac_init(struct tcp_ao_mac_ctx *mac_ctx,
enum tcp_ao_algo_id algo, const u8 *traffic_key)
{
mac_ctx->algo = algo;
switch (mac_ctx->algo) {
case TCP_AO_ALGO_HMAC_SHA1:
hmac_sha1_init_usingrawkey(&mac_ctx->hmac_sha1, traffic_key,
SHA1_DIGEST_SIZE);
return;
case TCP_AO_ALGO_HMAC_SHA256:
hmac_sha256_init_usingrawkey(&mac_ctx->hmac_sha256, traffic_key,
SHA256_DIGEST_SIZE);
return;
case TCP_AO_ALGO_AES_128_CMAC:
aes_cmac_preparekey(&mac_ctx->aes_cmac.key, traffic_key,
AES_KEYSIZE_128);
aes_cmac_init(&mac_ctx->aes_cmac.ctx, &mac_ctx->aes_cmac.key);
return;
default:
WARN_ON_ONCE(1); /* algo was validated earlier. */
}
}
void tcp_ao_mac_update(struct tcp_ao_mac_ctx *mac_ctx, const void *data,
size_t data_len)
{
switch (mac_ctx->algo) {
case TCP_AO_ALGO_HMAC_SHA1:
hmac_sha1_update(&mac_ctx->hmac_sha1, data, data_len);
return;
case TCP_AO_ALGO_HMAC_SHA256:
hmac_sha256_update(&mac_ctx->hmac_sha256, data, data_len);
return;
case TCP_AO_ALGO_AES_128_CMAC:
aes_cmac_update(&mac_ctx->aes_cmac.ctx, data, data_len);
return;
default:
WARN_ON_ONCE(1); /* algo was validated earlier. */
}
}
static void tcp_ao_mac_final(struct tcp_ao_mac_ctx *mac_ctx, u8 *out)
{
switch (mac_ctx->algo) {
case TCP_AO_ALGO_HMAC_SHA1:
hmac_sha1_final(&mac_ctx->hmac_sha1, out);
return;
case TCP_AO_ALGO_HMAC_SHA256:
hmac_sha256_final(&mac_ctx->hmac_sha256, out);
return;
case TCP_AO_ALGO_AES_128_CMAC:
aes_cmac_final(&mac_ctx->aes_cmac.ctx, out);
return;
default:
WARN_ON_ONCE(1); /* algo was validated earlier. */
}
}
void tcp_ao_calc_traffic_key(const struct tcp_ao_key *mkt, u8 *traffic_key,
const void *input, unsigned int input_len)
{
Annotation
- Immediate include surface: `crypto/aes-cbc-macs.h`, `crypto/sha1.h`, `crypto/sha2.h`, `crypto/utils.h`, `linux/inetdevice.h`, `linux/tcp.h`, `net/tcp.h`, `net/ipv6.h`.
- Detected declarations: `struct tcp_ao_mac_ctx`, `struct kdf_input_block`, `function tcp_ao_mac_init`, `function tcp_ao_mac_update`, `function tcp_ao_mac_final`, `function tcp_ao_calc_traffic_key`, `function tcp_ao_ignore_icmp`, `function states`, `function hlist_for_each_entry_rcu`, `function ipv4_prefix_cmp`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.