sk_buff structure analysis sk_buff is the second important structure we encountered, often abbreviated as skb in the kernel. In linux 2.6.21 it is defined as: struct sk_buff {//points to the next skbstruct sk_buff *next ;//Previous skbstruct sk_buff *prev; struct sk_buf0f_head *list; //corresponding sock. This is also an important structure. In the transport layer, we will analyze the struct sock *sk; //receive or send the timestamp struct timeval stamp; //receive or send the corresponding net_devicestruct net_device * dev; //receive net_devicestruct net_device *input_dev;//The real net_device corresponding to the data packet. The virtual device can discuss the struct net_device *real_dev;//ip layer related information in the subsequent bridge mode analysis. union {struct tcphdr *th;struct udphdr *uh;struct icmphdr * icmph; struct igmphdr * igmph; struct iphdr * ipiph; struct ipv6hdr * ipv6h; unsigned char * raw;} h; information protocol layer union //{struct iphdr * iph; struct ipv6hdr * ipv6h; struct arphdr * arph ;unsigned char *raw;} nh;//link layer related information union {unsigned char *raw;} mac; //in the routing subsystem to analyze this structure struct dst_entry * dst; struct sec_path * sp; /** 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 [40];. //data length of each layer unsigned int len, data_len, mac_len, csum; unsigned char local_df, cloned, pkt_type, ip_summed; __ u32 priority; unsigned short protocol, security; void (* destructor) (struct sk_buff * skb); # ifdef CONFIG_NETFILTERunsigned long nfmark; __ u32 nfcache; __ u32 nfctinfo; struct nf_conntrack * nfct; #ifdef CONFIG_NETFILTER_DEBUGunsigned int nf_debug; # endif # ifdef CONFIG_BRIDGE_NETFILTERstruct nf_bridge_info * nf_bridge; # endif # endif /* CONFIG_NETFILTER * /# if defined (CONFIG_HIPPI) union {__u32 ifield;} private; # endif # ifdef CONFIG_NET_SCHED__u32 tc_index; /* traffic control index * /# ifdef CONFIG_NET_CLS_ACT__u32 tc_verd; /* traffic control verdict * /__ u32 tc_classid; /* traffic control classid * /# endif # endif /* These elements must be at the end, see alloc_skb () for details * /unsigned int truesize;. //reference count atomic_t users; //start of storage Address unsigned char *head, //network data starting address * data, //store network data End address * tail, the end address of the memory space //* end;} corresponding to the NIC driver on our analysis. The received data is stored in the area between data and tail. Skb usually has several commonly used functions. The analysis is as follows: struct sk_buff *alloc_skb(unsigned int size, int gfp_mask) allocates the storage space to sixe's skb, and the memory allocation level is gfp_mask. Note the meaning of the storage space here. That is, skb->data to skb->tail area struct sk_buff *skb_clone(struct sk_buff *skb, int priority) cloned skb points to the same structure, and will increase the skb reference count struct sk_buff *skb_copy(const Struct sk_buff *skb, int priority) Copy a brand new skbvoid kfree_skb(struct sk_buff *skb) When the skb reference count is 1, release the skbunsigned char *skb_put(struct sk_buff *skb, unsigned int len) to make skb storage Space expansion len. Even if the tail pointer moves down unsigned char *skb_push(struct sk_buff *skb, unsigned int len) push, the data is pushed out, so that the data pointer is under the layer. Void skb_reserve(struct sk_buff *skb, unsigned int len) This operation causes the data pointer to move down with the tail pointer at the same time, that is, the space before the storage area is expanded. skb_headroom(const struct sk_buff *skb) The amount of space available before returning data is int skb_tailroom( Const struct sk_buff *skb) Returns the amount of space available in the cache
Windows CE is an embedded operating system developed by Microsoft that can be used in a variety of e
How do I use a USB-based storage device in a Linux environment? This
1 Start vSphere Client2 Start Virtual Machine [Right-click on VM, select Power —>Open] and
RedHat Linux provides firewall protection for increased system security. A firewall exists between y
Vsftpd 500 OOPS: cannot change directory
The reason why the driver of the single-chip microcomputer should be set to low level is
Step by step to teach the Linux system to maintain the four great tricks
CentOS Apache configuration details
Relationship and difference between CPU usage and machine load under Linux
Neighbor subsystem of linux protocol stack (garbage collection seven)
How to connect a Linux computer to the Internet with a cdma 1x phone
How does Windows 8 open a command prompt?
Win7 system mouse flicker cursor thickness how to adjust
The fastest shutdown method for Win8 system
Laptop win7 system shutdown when the pop-up To return to windows solution
Convert cad text into word step teaching
Under the operating system, WinXP is easy to change "Apple"
CF August 8th online activity time extension and activity rewards receiving announcement
Quickly improve the speed of anti-virus software
How to make the win8 photo application display computer pictures?