The SK_BUFF structure is probably the most important data structure in Linux Network Code, which represents the packet header information that is received or sent. It is defined in and contains a number of member variables for use by subsystems in the network code.
This structure is used by different network layers (Mac or other two-layer link protocol, three-layer IP, four-layer TCP or UDP, etc.), and the member variables change as the structure passes from one layer to another. L4 adds a L4 header to the L3 before it is passed to the L2, and a L3 header is added to the L3 before it is delivered. Adding headers is more efficient than copying data between different layers.
Since adding data to the head of the buffer means modifying pointers to buffers, this is a complex operation, so the kernel provides a function skb_reserve.
Each layer in the protocol stack before passing the buffer, the first thing is to call Skb_reserve in the buffer head to the protocol header to reserve a certain amount of space.
The Skb_reserve is also used by the device driver to align the packets received to the packet header. If the buffer is passed to the upper layer protocol, the old protocol layer header information is useless. For example, L2 's head is only useful when the network driver deals with L2 protocols, and L3 does not care about its information. However, the kernel does not remove the L2 head from the buffer, but instead points the payload pointer to the L3 's head, which saves CPU time.