The allocation of a socket buffer is a bit tricky, since it needs at least three different functions:
- First of all, the whole memory allocation should be done using the netdev_alloc_skb() function
- Increase and align header room with the skb_reserve() function
- Extend the used data area of the buffer (which will contain the packet) using the skb_put() function.
Let's have a look at the following diagram:
- We allocate a buffer large enough to contain a packet along with the Ethernet header by means of the netdev_alloc_skb() function:
struct sk_buff *netdev_alloc_skb(struct net_device ...