sk_buff结构详解 struct sk_buff可能是linux网络代码中最重要的数据结构,它表示接收或发送数据包的包头信息,并包含很多成员变量供网络代码中的各子系统使用。这个结构被网络的不同层(MAC或者其他二层链路协议,三层的IP,四层的TCP或UDP等)使用,并且其中的成员变量在结构从一层向另一层传递时改变。L4向L3传递前...
因此,sk_buff结构里面的一些成员变量只有在内核选择支持某些功能时才有效,比如防火墙(netfilter)或者qos: *1 unsigned long nfmark __u32 nfcache __u32 nfctinfo struct nf_conntracknfct *unsigned int nfdebug struct nf_bridge_infonf_bridge 这些变量被netfilter使用(防火墙代码),内核编译选项是"Device Drivers...
{ unsigned int napi_id; unsigned int sender_cpu; }; #endif #ifdef CONFIG_NETWORK_SECMARK __u32 secmark;//安全标记,该操作由iptables secmask目标设置 #endif union { __u32 mark;//通过此标识来标识SKB,在iptables使用MARK目标和mangle表来设置mark字段 __u32 reserved_tailroom; }; union { __...
unsignedintsender_cpu; };#endif#ifdef CONFIG_NETWORK_SECMARK __u32 secmark;#endifunion { __u32 mark; __u32 reserved_tailroom; };/*封装的协议*/union { __be16 inner_protocol; __u8 inner_ipproto; };/*封装的传输层头部相对于head的偏移*/__u16 inner_transport_header;/*封装的网络层头部...
(netfilter)或者qos: __u32 nfctinfo ... #ifdef CONFIG_NETFILTER struct nf_conntrack *nfct; #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) struct sk_buff *nfct_reasm; #endif #ifdef CONFIG_BRIDGE_NETFILTER struct nf_bridge_info nf_bridge;#endif__u32 nfmark;#...
__u8 offload_fwd_mark:1; #endif #ifdef CONFIG_NET_CLS_ACT __u8 tc_skip_classify:1;// do not classify packet. set by IFB device __u8 tc_at_ingress:1;// used within tc_classify to distinguish in/egress __u8 tc_redirected:1;// packet was redirected by a tc action __u8 tc_fro...
* @mark: Generic packet mark * @vlan_proto: vlan encapsulation protocol * @vlan_tci: vlan tag control information * @inner_protocol: Protocol (encapsulation) * @inner_transport_header: Inner transport layer header (encapsulation) * @inner_network_header: Network layer header (encapsulation) ...
1、使用struct ethhdr结构体来表示以太网帧的头部。这个struct ethhdr结构体位于#include<linux/if_ether.h>之中。 #define ETH_ALEN 6 //定义了以太网接口的MAC地址的长度为6个字节 #define ETH_HLAN 14 //定义了以太网帧的头长度为14个字节 #define ETH_ZLEN 60 //定义了以太网帧的最小长度为 ETH_Z...
(netfilter)或者qos: __u32 nfctinfo ... #ifdef CONFIG_NETFILTER struct nf_conntrack *nfct; #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) struct sk_buff *nfct_reasm; #endif #ifdef CONFIG_BRIDGE_NETFILTER struct nf_bridge_info nf_bridge;#endif__u32 nfmark;#...
1 unsigned long nfmark __u32 nfcache __u32 nfctinfo struct nf_conntrack *nfct unsigned int nfdebug struct nf_bridge_info *nf_bridge 这些变量被netfilter使用(防火墙代码),内核编译选项是"Device Drivers->Networking support-> Networking options-> Network packet filtering"和两个子选项"Network packet...