sk_bufff结构是Linux网络模块中最重要的数据结构之一,用以描述已接收或待发送的数据报文信息,其成员可大致分为以下几类:
- 与sk_buff组织相关的成员变量。
- 数据存储相关的变量
- 通用成员变量。
- 标志性变量。
- 与特性相关的成员变量。
下面对sk_buff结构进行详细介绍。
struct sk_buff {
/* These two members must be first. */
struct sk_buff *next;
struct sk_buff *prev;
struct sock *sk;
ktime_t tstamp;
struct net_device *dev;
union {
struct dst_entry *dst;
struct rtable *rtable;
};
#ifdef CONFIG_XFRM
struct sec_path *sp;
#endif
/*
* This is the control buffer. It is free to use for every
* layer. Please put your private variables there. If you
* want to keep them across layers you have to do a skb_clone()
* first. This is owned by whoever has the skb queued ATM.
*/
char cb[48];
unsigned int len,
data_len;
__u16 mac_len,
hdr_len;
union {
__wsum csum;
struct {
__u16 csum_start;
__u16 csum_offset;
};
};
__u32 priority;
__u8 local_df:1,
cloned:1,
ip_summed:2,
nohdr:1,
nfctinfo:3;
__u8 pkt_type:3,
fclone:2,
ipvs_property:1,
peeked:1,
nf_trace:1;
__be16 protocol;
void (*destructor)(struct sk_buff *skb);
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
struct nf_conntrack *nfct;
struct sk_buff *nfct_reasm;
#endif
#ifdef CONFIG_BRIDGE_NETF

sk_buff是Linux网络模块的关键数据结构,用于描述数据报文信息。它包含组织相关、数据存储、通用成员和标志变量等,涉及网络设备、数据缓存、路由、协议处理等多个方面。sk_buff通过双向链表组织,使用spinlock_t保护并发操作,并通过cb字段存储各层协议的私有信息。

3587

被折叠的 条评论
为什么被折叠?



