net/tls/tls_strp.c
Source file repositories/reference/linux-study-clean/net/tls/tls_strp.c
File Facts
- System
- Linux kernel
- Corpus path
net/tls/tls_strp.c- Extension
.c- Size
- 15201 bytes
- Lines
- 659
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/skbuff.hlinux/skbuff_ref.hlinux/workqueue.hnet/strparser.hnet/tcp.hnet/sock.hnet/tls.htls.h
Detected Declarations
function tls_strp_abort_strpfunction tls_strp_anchor_freefunction tls_strp_skb_copyfunction itselffunction tls_strp_msg_holdfunction tls_strp_flush_anchor_copyfunction tls_strp_copyin_fragfunction tls_strp_copyin_skbfunction tls_strp_copyinfunction tls_strp_read_copyinfunction tls_strp_read_copyfunction tls_strp_check_queue_okfunction tls_strp_load_anchor_with_queuefunction tls_strp_msg_loadfunction tls_strp_read_sockfunction tls_rx_msg_maybe_announcefunction tls_strp_data_readyfunction tls_strp_workfunction tls_strp_data_readyfunction tls_strp_stopfunction tls_strp_initfunction tls_strp_donefunction __tls_strp_donefunction tls_strp_dev_initfunction tls_strp_dev_exit
Annotated Snippet
while (len > 0) {
if (iter->len <= offset) {
offset -= iter->len;
goto next;
}
chunk = iter->len - offset;
offset = 0;
clone = skb_clone(iter, strp->sk->sk_allocation);
if (!clone)
return -ENOMEM;
__skb_queue_tail(dst, clone);
len -= chunk;
next:
iter = iter->next;
}
}
return 0;
}
static void tls_strp_flush_anchor_copy(struct tls_strparser *strp)
{
struct skb_shared_info *shinfo = skb_shinfo(strp->anchor);
int i;
DEBUG_NET_WARN_ON_ONCE(atomic_read(&shinfo->dataref) != 1);
for (i = 0; i < shinfo->nr_frags; i++)
__skb_frag_unref(&shinfo->frags[i], false);
shinfo->nr_frags = 0;
if (strp->copy_mode) {
kfree_skb_list(shinfo->frag_list);
shinfo->frag_list = NULL;
}
strp->copy_mode = 0;
strp->mixed_decrypted = 0;
}
static int tls_strp_copyin_frag(struct tls_strparser *strp, struct sk_buff *skb,
struct sk_buff *in_skb, unsigned int offset,
size_t in_len)
{
unsigned int nfrag = skb->len / PAGE_SIZE;
size_t len, chunk;
skb_frag_t *frag;
int sz;
if (unlikely(nfrag >= skb_shinfo(skb)->nr_frags)) {
DEBUG_NET_WARN_ON_ONCE(1);
return -EMSGSIZE;
}
frag = &skb_shinfo(skb)->frags[nfrag];
len = in_len;
/* First make sure we got the header */
if (!strp->stm.full_len) {
/* Assume one page is more than enough for headers */
chunk = min_t(size_t, len, PAGE_SIZE - skb_frag_size(frag));
WARN_ON_ONCE(skb_copy_bits(in_skb, offset,
skb_frag_address(frag) +
skb_frag_size(frag),
chunk));
skb->len += chunk;
skb->data_len += chunk;
skb_frag_size_add(frag, chunk);
sz = tls_rx_msg_size(strp, skb);
if (sz < 0)
return sz;
/* We may have over-read, sz == 0 is guaranteed under-read */
if (unlikely(sz && sz < skb->len)) {
int over = skb->len - sz;
WARN_ON_ONCE(over > chunk);
skb->len -= over;
skb->data_len -= over;
skb_frag_size_add(frag, -over);
chunk -= over;
}
frag++;
len -= chunk;
offset += chunk;
Annotation
- Immediate include surface: `linux/skbuff.h`, `linux/skbuff_ref.h`, `linux/workqueue.h`, `net/strparser.h`, `net/tcp.h`, `net/sock.h`, `net/tls.h`, `tls.h`.
- Detected declarations: `function tls_strp_abort_strp`, `function tls_strp_anchor_free`, `function tls_strp_skb_copy`, `function itself`, `function tls_strp_msg_hold`, `function tls_strp_flush_anchor_copy`, `function tls_strp_copyin_frag`, `function tls_strp_copyin_skb`, `function tls_strp_copyin`, `function tls_strp_read_copyin`.
- 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.