net/tls/tls_sw.c
Source file repositories/reference/linux-study-clean/net/tls/tls_sw.c
File Facts
- System
- Linux kernel
- Corpus path
net/tls/tls_sw.c- Extension
.c- Size
- 67287 bytes
- Lines
- 2626
- 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
linux/bug.hlinux/sched/signal.hlinux/module.hlinux/kernel.hlinux/splice.hcrypto/aead.hnet/strparser.hnet/tls.htrace/events/sock.htls.h
Detected Declarations
struct tls_decrypt_argstruct tls_decrypt_ctxfunction tls_err_abortfunction __skb_nsgfunction skb_nsgfunction tls_padding_lengthfunction tls_decrypt_donefunction for_each_sgfunction tls_decrypt_async_waitfunction tls_do_decryptionfunction tls_trim_both_msgsfunction tls_alloc_encrypted_msgfunction tls_clone_plaintext_msgfunction tls_free_recfunction tls_free_open_recfunction tls_tx_recordsfunction tls_encrypt_donefunction tls_encrypt_async_waitfunction tls_do_encryptionfunction tls_encrypt_donefunction tls_push_recordfunction bpf_exec_tx_verdictfunction tls_sw_push_pending_recordfunction tls_sw_sendmsg_splicefunction tls_sw_sendmsg_lockedfunction tls_sw_sendmsgfunction tls_sw_splice_eoffunction sock_errorfunction tcp_donefunction tls_setup_from_iterfunction tls_alloc_clrtxt_skbfunction tls_decrypt_swfunction tls_decrypt_swfunction tls_decrypt_devicefunction tls_check_pending_rekeyfunction tls_rx_one_recordfunction decrypt_skbfunction tls_record_content_typefunction tls_rx_reader_releasefunction process_rx_listfunction tls_read_flush_backlogfunction tls_rx_reader_acquirefunction tls_rx_reader_lockfunction tls_rx_reader_releasefunction tls_rx_reader_unlockfunction tls_sw_recvmsgfunction tls_sw_splice_readfunction tls_sw_read_sock
Annotated Snippet
struct tls_decrypt_arg {
struct_group(inargs,
bool zc;
bool async;
bool async_done;
u8 tail;
);
struct sk_buff *skb;
};
struct tls_decrypt_ctx {
struct sock *sk;
u8 iv[TLS_MAX_IV_SIZE];
u8 aad[TLS_MAX_AAD_SIZE];
u8 tail;
bool free_sgout;
struct scatterlist sg[];
};
noinline void tls_err_abort(struct sock *sk, int err)
{
WARN_ON_ONCE(err >= 0);
/* sk->sk_err should contain a positive error code. */
WRITE_ONCE(sk->sk_err, -err);
/* Paired with smp_rmb() in tcp_poll() */
smp_wmb();
sk_error_report(sk);
}
static int __skb_nsg(struct sk_buff *skb, int offset, int len,
unsigned int recursion_level)
{
int start = skb_headlen(skb);
int i, chunk = start - offset;
struct sk_buff *frag_iter;
int elt = 0;
if (unlikely(recursion_level >= 24))
return -EMSGSIZE;
if (chunk > 0) {
if (chunk > len)
chunk = len;
elt++;
len -= chunk;
if (len == 0)
return elt;
offset += chunk;
}
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
int end;
WARN_ON(start > offset + len);
end = start + skb_frag_size(&skb_shinfo(skb)->frags[i]);
chunk = end - offset;
if (chunk > 0) {
if (chunk > len)
chunk = len;
elt++;
len -= chunk;
if (len == 0)
return elt;
offset += chunk;
}
start = end;
}
if (unlikely(skb_has_frag_list(skb))) {
skb_walk_frags(skb, frag_iter) {
int end, ret;
WARN_ON(start > offset + len);
end = start + frag_iter->len;
chunk = end - offset;
if (chunk > 0) {
if (chunk > len)
chunk = len;
ret = __skb_nsg(frag_iter, offset - start, chunk,
recursion_level + 1);
if (unlikely(ret < 0))
return ret;
elt += ret;
len -= chunk;
if (len == 0)
return elt;
offset += chunk;
Annotation
- Immediate include surface: `linux/bug.h`, `linux/sched/signal.h`, `linux/module.h`, `linux/kernel.h`, `linux/splice.h`, `crypto/aead.h`, `net/strparser.h`, `net/tls.h`.
- Detected declarations: `struct tls_decrypt_arg`, `struct tls_decrypt_ctx`, `function tls_err_abort`, `function __skb_nsg`, `function skb_nsg`, `function tls_padding_length`, `function tls_decrypt_done`, `function for_each_sg`, `function tls_decrypt_async_wait`, `function tls_do_decryption`.
- 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.