net/core/skmsg.c
Source file repositories/reference/linux-study-clean/net/core/skmsg.c
File Facts
- System
- Linux kernel
- Corpus path
net/core/skmsg.c- Extension
.c- Size
- 31076 bytes
- Lines
- 1278
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/skmsg.hlinux/skbuff.hlinux/scatterlist.hnet/sock.hnet/tcp.htrace/events/sock.h
Detected Declarations
function sk_msg_try_coalesce_okfunction sk_msg_allocfunction sk_msg_clonefunction sk_msg_return_zerofunction sk_msg_returnfunction sk_msg_free_elemfunction __sk_msg_freefunction sk_msg_free_nochargefunction sk_msg_freefunction __sk_msg_free_partialfunction sk_msg_free_partialfunction sk_msg_free_partial_nochargefunction sk_msg_trimfunction sk_msg_iter_distfunction sk_msg_zerocopy_from_iterfunction sk_msg_memcopy_from_iterfunction __sk_msg_recvmsgfunction sk_msg_recvmsgfunction sk_msg_is_readablefunction sk_psock_skb_ingress_enqueuefunction sk_psock_skb_ingressfunction sk_psock_skb_ingress_selffunction sk_psock_handle_skbfunction sk_psock_skb_statefunction sk_psock_backlogfunction __sk_psock_purge_ingress_msgfunction list_for_each_entry_safefunction __sk_psock_zap_ingressfunction sk_psock_link_destroyfunction list_for_each_entry_safefunction sk_psock_stopfunction sk_psock_destroyfunction sk_psock_dropfunction sk_psock_map_verdfunction sk_psock_msg_verdictfunction sk_psock_skb_redirectfunction sk_psock_verdict_applyfunction sk_psock_write_spacefunction sk_psock_strp_readfunction sk_psock_strp_read_donefunction sk_psock_strp_parsefunction sk_psock_strp_data_readyfunction sk_psock_init_strpfunction sk_psock_start_strpfunction sk_psock_stop_strpfunction sk_psock_done_strpfunction sk_psock_done_strpfunction sk_psock_verdict_data_ready
Annotated Snippet
const struct proto_ops *ops = NULL;
struct sk_psock *psock;
struct socket *sock;
int copied;
trace_sk_data_ready(sk);
rcu_read_lock();
sock = READ_ONCE(sk->sk_socket);
if (likely(sock))
ops = READ_ONCE(sock->ops);
rcu_read_unlock();
if (!ops || !ops->read_skb)
return;
copied = ops->read_skb(sk, sk_psock_verdict_recv);
if (copied >= 0) {
rcu_read_lock();
psock = sk_psock(sk);
if (psock)
sk_psock_data_ready(sk, psock);
rcu_read_unlock();
}
}
void sk_psock_start_verdict(struct sock *sk, struct sk_psock *psock)
{
if (psock->saved_data_ready)
return;
psock->saved_data_ready = sk->sk_data_ready;
WRITE_ONCE(sk->sk_data_ready, sk_psock_verdict_data_ready);
WRITE_ONCE(sk->sk_write_space, sk_psock_write_space);
}
void sk_psock_stop_verdict(struct sock *sk, struct sk_psock *psock)
{
psock_set_prog(&psock->progs.stream_verdict, NULL);
psock_set_prog(&psock->progs.skb_verdict, NULL);
if (!psock->saved_data_ready)
return;
WRITE_ONCE(sk->sk_data_ready, psock->saved_data_ready);
psock->saved_data_ready = NULL;
}
Annotation
- Immediate include surface: `linux/skmsg.h`, `linux/skbuff.h`, `linux/scatterlist.h`, `net/sock.h`, `net/tcp.h`, `trace/events/sock.h`.
- Detected declarations: `function sk_msg_try_coalesce_ok`, `function sk_msg_alloc`, `function sk_msg_clone`, `function sk_msg_return_zero`, `function sk_msg_return`, `function sk_msg_free_elem`, `function __sk_msg_free`, `function sk_msg_free_nocharge`, `function sk_msg_free`, `function __sk_msg_free_partial`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern 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.