include/net/strparser.h

Source file repositories/reference/linux-study-clean/include/net/strparser.h

File Facts

System
Linux kernel
Corpus path
include/net/strparser.h
Extension
.h
Size
4347 bytes
Lines
171
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct strp_stats {
	unsigned long long msgs;
	unsigned long long bytes;
	unsigned int mem_fail;
	unsigned int need_more_hdr;
	unsigned int msg_too_big;
	unsigned int msg_timeouts;
	unsigned int bad_hdr_len;
};

struct strp_aggr_stats {
	unsigned long long msgs;
	unsigned long long bytes;
	unsigned int mem_fail;
	unsigned int need_more_hdr;
	unsigned int msg_too_big;
	unsigned int msg_timeouts;
	unsigned int bad_hdr_len;
	unsigned int aborts;
	unsigned int interrupted;
	unsigned int unrecov_intr;
};

struct strparser;

/* Callbacks are called with lock held for the attached socket */
struct strp_callbacks {
	int (*parse_msg)(struct strparser *strp, struct sk_buff *skb);
	void (*rcv_msg)(struct strparser *strp, struct sk_buff *skb);
	int (*read_sock)(struct strparser *strp, read_descriptor_t *desc,
			 sk_read_actor_t recv_actor);
	int (*read_sock_done)(struct strparser *strp, int err);
	void (*abort_parser)(struct strparser *strp, int err);
	void (*lock)(struct strparser *strp);
	void (*unlock)(struct strparser *strp);
};

struct strp_msg {
	int full_len;
	int offset;
};

struct _strp_msg {
	/* Internal cb structure. struct strp_msg must be first for passing
	 * to upper layer.
	 */
	struct strp_msg strp;
	int accum_len;
};

struct sk_skb_cb {
#define SK_SKB_CB_PRIV_LEN 20
	unsigned char data[SK_SKB_CB_PRIV_LEN];
	/* align strp on cache line boundary within skb->cb[] */
	unsigned char pad[4];
	struct _strp_msg strp;

	/* strp users' data follows */
	struct tls_msg {
		u8 control;
	} tls;
	/* temp_reg is a temporary register used for bpf_convert_data_end_access
	 * when dst_reg == src_reg.
	 */
	u64 temp_reg;
};

static inline struct strp_msg *strp_msg(struct sk_buff *skb)
{
	return (struct strp_msg *)((void *)skb->cb +
		offsetof(struct sk_skb_cb, strp));
}

/* Structure for an attached lower socket */
struct strparser {
	struct sock *sk;

	u32 stopped : 1;
	u32 paused : 1;
	u32 aborted : 1;
	u32 interrupted : 1;
	u32 unrecov_intr : 1;

	struct sk_buff **skb_nextp;
	struct sk_buff *skb_head;
	unsigned int need_bytes;
	struct delayed_work msg_timer_work;
	struct work_struct work;
	struct strp_stats stats;
	struct strp_callbacks cb;

Annotation

Implementation Notes