build_skb
Prev | Socket Buffer Functions | Next

## Name

build_skb — build a network buffer

## Synopsis

`struct sk_buff * build_skb (` | void * data,
| unsigned int frag_size`)`;

## Arguments

`data`

  data buffer provided by caller

`frag_size`

  size of fragment, or 0 if head was kmalloced

## Description

Allocate a new sk_buff. Caller provides space holding head and skb_shared_info. `data` must have been allocated by `kmalloc` only if `frag_size` is 0, otherwise data should come from the page allocator. The return is the new skb buffer. On a failure the return is `NULL`, and `data` is not freed.

## Notes

Before IO, driver allocates only data buffer where NIC put incoming frame Driver should add room at head (NET_SKB_PAD) and MUST add room at tail (SKB_DATA_ALIGN(skb_shared_info)) After IO, driver calls `build_skb`, to allocate sk_buff and populate it before giving packet to stack. RX rings only contains data buffers, not full skbs.

Prev | Up | Next
__alloc_skb | Home | netdev_alloc_frag