net/tls/tls_device.c
Source file repositories/reference/linux-study-clean/net/tls/tls_device.c
File Facts
- System
- Linux kernel
- Corpus path
net/tls/tls_device.c- Extension
.c- Size
- 38004 bytes
- Lines
- 1443
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/aead.hlinux/highmem.hlinux/module.hlinux/netdevice.hnet/dst.hnet/inet_connection_sock.hnet/tcp.hnet/tls.hlinux/skbuff_ref.htls.htrace.h
Detected Declarations
function tls_device_free_ctxfunction tls_device_tx_del_taskfunction tls_device_queue_ctx_destructionfunction destroy_recordfunction delete_all_recordsfunction list_for_each_entry_safefunction tls_tcp_clean_ackedfunction list_for_each_entry_safefunction tls_device_sk_destructfunction tls_device_free_resources_txfunction tls_offload_tx_resync_requestfunction tls_device_resync_txfunction tls_append_fragfunction skb_frag_offfunction tls_push_recordfunction tls_device_record_closefunction coalescingfunction tls_create_new_recordfunction tls_do_allocationfunction tls_device_copy_datafunction tls_push_datafunction tls_device_sendmsgfunction tls_device_splice_eoffunction beforefunction tls_device_push_pending_recordfunction tls_device_write_spacefunction tls_device_resync_rxfunction tls_device_rx_resync_asyncfunction tls_device_rx_resync_new_recfunction tls_device_core_ctrl_rx_resyncfunction tls_device_reencryptfunction tls_device_decryptedfunction tls_device_attachfunction tls_set_device_offloadfunction tls_set_device_offload_rxfunction tls_device_offload_cleanup_rxfunction tls_device_downfunction list_for_each_entry_safefunction tls_dev_eventfunction tls_device_initfunction tls_device_cleanupexport tls_device_sk_destructexport tls_offload_tx_resync_requestexport tls_get_record
Annotated Snippet
skb_frag_off(frag) + skb_frag_size(frag) == pfrag->offset) {
skb_frag_size_add(frag, size);
} else {
++frag;
skb_frag_fill_page_desc(frag, pfrag->page, pfrag->offset,
size);
++record->num_frags;
get_page(pfrag->page);
}
pfrag->offset += size;
record->len += size;
}
static int tls_push_record(struct sock *sk,
struct tls_context *ctx,
struct tls_offload_context_tx *offload_ctx,
struct tls_record_info *record,
int flags)
{
struct tls_prot_info *prot = &ctx->prot_info;
struct tcp_sock *tp = tcp_sk(sk);
skb_frag_t *frag;
int i;
record->end_seq = tp->write_seq + record->len;
list_add_tail_rcu(&record->list, &offload_ctx->records_list);
offload_ctx->open_record = NULL;
if (test_bit(TLS_TX_SYNC_SCHED, &ctx->flags))
tls_device_resync_tx(sk, ctx, tp->write_seq);
tls_advance_record_sn(sk, prot, &ctx->tx);
for (i = 0; i < record->num_frags; i++) {
frag = &record->frags[i];
sg_unmark_end(&offload_ctx->sg_tx_data[i]);
sg_set_page(&offload_ctx->sg_tx_data[i], skb_frag_page(frag),
skb_frag_size(frag), skb_frag_off(frag));
sk_mem_charge(sk, skb_frag_size(frag));
get_page(skb_frag_page(frag));
}
sg_mark_end(&offload_ctx->sg_tx_data[record->num_frags - 1]);
/* all ready, send */
return tls_push_sg(sk, ctx, offload_ctx->sg_tx_data, 0, flags);
}
static void tls_device_record_close(struct sock *sk,
struct tls_context *ctx,
struct tls_record_info *record,
struct page_frag *pfrag,
unsigned char record_type)
{
struct tls_prot_info *prot = &ctx->prot_info;
struct page_frag dummy_tag_frag;
/* append tag
* device will fill in the tag, we just need to append a placeholder
* use socket memory to improve coalescing (re-using a single buffer
* increases frag count)
* if we can't allocate memory now use the dummy page
*/
if (unlikely(pfrag->size - pfrag->offset < prot->tag_size) &&
!skb_page_frag_refill(prot->tag_size, pfrag, sk->sk_allocation)) {
dummy_tag_frag.page = dummy_page;
dummy_tag_frag.offset = 0;
pfrag = &dummy_tag_frag;
}
tls_append_frag(record, pfrag, prot->tag_size);
/* fill prepend */
tls_fill_prepend(ctx, skb_frag_address(&record->frags[0]),
record->len - prot->overhead_size,
record_type);
}
static int tls_create_new_record(struct tls_offload_context_tx *offload_ctx,
struct page_frag *pfrag,
size_t prepend_size)
{
struct tls_record_info *record;
skb_frag_t *frag;
record = kmalloc_obj(*record);
if (!record)
return -ENOMEM;
frag = &record->frags[0];
skb_frag_fill_page_desc(frag, pfrag->page, pfrag->offset,
Annotation
- Immediate include surface: `crypto/aead.h`, `linux/highmem.h`, `linux/module.h`, `linux/netdevice.h`, `net/dst.h`, `net/inet_connection_sock.h`, `net/tcp.h`, `net/tls.h`.
- Detected declarations: `function tls_device_free_ctx`, `function tls_device_tx_del_task`, `function tls_device_queue_ctx_destruction`, `function destroy_record`, `function delete_all_records`, `function list_for_each_entry_safe`, `function tls_tcp_clean_acked`, `function list_for_each_entry_safe`, `function tls_device_sk_destruct`, `function tls_device_free_resources_tx`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration 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.