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.

Dependency Surface

Detected Declarations

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

Implementation Notes