include/linux/skmsg.h
Source file repositories/reference/linux-study-clean/include/linux/skmsg.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/skmsg.h- Extension
.h- Size
- 16160 bytes
- Lines
- 639
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- 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/bitops.hlinux/bpf.hlinux/filter.hlinux/scatterlist.hlinux/skbuff.hnet/sock.hnet/tcp.hnet/strparser.h
Detected Declarations
struct sk_msg_sgstruct sk_msgstruct sk_psock_progsstruct sk_psock_linkstruct sk_psock_work_statestruct sk_psockenum __sk_actionenum sk_psock_state_bitsfunction sk_msg_check_to_freefunction sk_msg_apply_bytesfunction sk_msg_iter_distfunction sk_msg_initfunction sk_msg_xferfunction sk_msg_xfer_fullfunction sk_msg_fullfunction sk_msg_elem_usedfunction sk_msg_elem_cpyfunction sk_msg_to_ingressfunction sk_msg_compute_data_pointersfunction sk_msg_page_addfunction sk_msg_sg_copyfunction sk_msg_sg_copy_assignfunction sk_msg_sg_copy_setfunction sk_msg_sg_copy_clearfunction sk_psock_set_statefunction sk_psock_clear_statefunction sk_psock_test_statefunction sock_dropfunction sk_psock_get_msg_len_nolockfunction sk_psock_msg_len_add_lockedfunction sk_psock_msg_len_addfunction sk_psock_queue_msgfunction sk_psock_queue_emptyfunction kfree_sk_msgfunction sk_psock_report_errorfunction sk_psock_init_strpfunction sk_psock_start_strpfunction separatelyfunction sk_psock_cork_freefunction sk_psock_restore_protofunction sk_psock_putfunction sk_psock_data_readyfunction psock_set_progfunction psock_replace_progfunction psock_progs_dropfunction sk_psock_msg_inqfunction sk_msg_first_lenfunction skb_bpf_strparser
Annotated Snippet
struct sk_msg_sg {
u32 start;
u32 curr;
u32 end;
u32 size;
u32 copybreak;
DECLARE_BITMAP(copy, MAX_MSG_FRAGS + 2);
/* The extra two elements:
* 1) used for chaining the front and sections when the list becomes
* partitioned (e.g. end < start). The crypto APIs require the
* chaining;
* 2) to chain tailer SG entries after the message.
*/
struct scatterlist data[MAX_MSG_FRAGS + 2];
};
/* UAPI in filter.c depends on struct sk_msg_sg being first element. */
struct sk_msg {
struct sk_msg_sg sg;
void *data;
void *data_end;
u32 apply_bytes;
u32 cork_bytes;
u32 flags;
struct sk_buff *skb;
struct sock *sk_redir;
struct sock *sk;
struct list_head list;
};
struct sk_psock_progs {
struct bpf_prog *msg_parser;
struct bpf_prog *stream_parser;
struct bpf_prog *stream_verdict;
struct bpf_prog *skb_verdict;
struct bpf_link *msg_parser_link;
struct bpf_link *stream_parser_link;
struct bpf_link *stream_verdict_link;
struct bpf_link *skb_verdict_link;
};
enum sk_psock_state_bits {
SK_PSOCK_TX_ENABLED,
SK_PSOCK_RX_STRP_ENABLED,
};
struct sk_psock_link {
struct list_head list;
struct bpf_map *map;
void *link_raw;
};
struct sk_psock_work_state {
u32 len;
u32 off;
};
struct sk_psock {
struct sock *sk;
struct sock *sk_redir;
u32 apply_bytes;
u32 cork_bytes;
u32 eval;
bool redir_ingress; /* undefined if sk_redir is null */
struct sk_msg *cork;
struct sk_psock_progs progs;
#if IS_ENABLED(CONFIG_BPF_STREAM_PARSER)
struct strparser strp;
u32 copied_seq;
u32 ingress_bytes;
#endif
struct sk_buff_head ingress_skb;
struct list_head ingress_msg;
spinlock_t ingress_lock;
/** @msg_tot_len: Total bytes queued in ingress_msg list. */
u32 msg_tot_len;
unsigned long state;
struct list_head link;
spinlock_t link_lock;
refcount_t refcnt;
void (*saved_unhash)(struct sock *sk);
void (*saved_destroy)(struct sock *sk);
void (*saved_close)(struct sock *sk, long timeout);
void (*saved_write_space)(struct sock *sk);
void (*saved_data_ready)(struct sock *sk);
/* psock_update_sk_prot may be called with restore=false many times
* so the handler must be safe for this case. It will be called
* exactly once with restore=true when the psock is being destroyed
* and psock refcnt is zero, but before an RCU grace period.
*/
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/bpf.h`, `linux/filter.h`, `linux/scatterlist.h`, `linux/skbuff.h`, `net/sock.h`, `net/tcp.h`, `net/strparser.h`.
- Detected declarations: `struct sk_msg_sg`, `struct sk_msg`, `struct sk_psock_progs`, `struct sk_psock_link`, `struct sk_psock_work_state`, `struct sk_psock`, `enum __sk_action`, `enum sk_psock_state_bits`, `function sk_msg_check_to_free`, `function sk_msg_apply_bytes`.
- Atlas domain: Core OS / Core Kernel Interface.
- 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.