Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
skbuff.c File Reference
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/kmemcheck.h>
#include <linux/mm.h>
#include <linux/interrupt.h>
#include <linux/in.h>
#include <linux/inet.h>
#include <linux/slab.h>
#include <linux/netdevice.h>
#include <linux/string.h>
#include <linux/skbuff.h>
#include <linux/splice.h>
#include <linux/cache.h>
#include <linux/rtnetlink.h>
#include <linux/init.h>
#include <linux/scatterlist.h>
#include <linux/errqueue.h>
#include <linux/prefetch.h>
#include <net/protocol.h>
#include <net/dst.h>
#include <net/sock.h>
#include <net/checksum.h>
#include <net/xfrm.h>
#include <asm/uaccess.h>
#include <trace/events/skb.h>
#include <linux/highmem.h>

Go to the source code of this file.

Data Structures

struct  netdev_alloc_cache
 

Macros

#define pr_fmt(fmt)   KBUILD_MODNAME ": " fmt
 
#define kmalloc_reserve(size, gfp, node, pfmemalloc)   __kmalloc_reserve(size, gfp, node, _RET_IP_, pfmemalloc)
 
#define NETDEV_FRAG_PAGE_MAX_ORDER   get_order(32768)
 
#define NETDEV_FRAG_PAGE_MAX_SIZE   (PAGE_SIZE << NETDEV_FRAG_PAGE_MAX_ORDER)
 
#define NETDEV_PAGECNT_MAX_BIAS   NETDEV_FRAG_PAGE_MAX_SIZE
 
#define C(x)   n->x = skb->x
 
#define TS_SKB_CB(state)   ((struct skb_seq_state *) &((state)->cb))
 

Functions

void__kmalloc_reserve (size_t size, gfp_t flags, int node, unsigned long ip, bool *pfmemalloc)
 
struct sk_buff__alloc_skb (unsigned int size, gfp_t gfp_mask, int flags, int node)
 
 EXPORT_SYMBOL (__alloc_skb)
 
struct sk_buffbuild_skb (void *data, unsigned int frag_size)
 
 EXPORT_SYMBOL (build_skb)
 
voidnetdev_alloc_frag (unsigned int fragsz)
 
 EXPORT_SYMBOL (netdev_alloc_frag)
 
struct sk_buff__netdev_alloc_skb (struct net_device *dev, unsigned int length, gfp_t gfp_mask)
 
 EXPORT_SYMBOL (__netdev_alloc_skb)
 
void skb_add_rx_frag (struct sk_buff *skb, int i, struct page *page, int off, int size, unsigned int truesize)
 
 EXPORT_SYMBOL (skb_add_rx_frag)
 
void __kfree_skb (struct sk_buff *skb)
 
 EXPORT_SYMBOL (__kfree_skb)
 
void kfree_skb (struct sk_buff *skb)
 
 EXPORT_SYMBOL (kfree_skb)
 
void consume_skb (struct sk_buff *skb)
 
 EXPORT_SYMBOL (consume_skb)
 
struct sk_buffskb_morph (struct sk_buff *dst, struct sk_buff *src)
 
 EXPORT_SYMBOL_GPL (skb_morph)
 
int skb_copy_ubufs (struct sk_buff *skb, gfp_t gfp_mask)
 
 EXPORT_SYMBOL_GPL (skb_copy_ubufs)
 
struct sk_buffskb_clone (struct sk_buff *skb, gfp_t gfp_mask)
 
 EXPORT_SYMBOL (skb_clone)
 
struct sk_buffskb_copy (const struct sk_buff *skb, gfp_t gfp_mask)
 
 EXPORT_SYMBOL (skb_copy)
 
struct sk_buff__pskb_copy (struct sk_buff *skb, int headroom, gfp_t gfp_mask)
 
 EXPORT_SYMBOL (__pskb_copy)
 
int pskb_expand_head (struct sk_buff *skb, int nhead, int ntail, gfp_t gfp_mask)
 
 EXPORT_SYMBOL (pskb_expand_head)
 
struct sk_buffskb_realloc_headroom (struct sk_buff *skb, unsigned int headroom)
 
 EXPORT_SYMBOL (skb_realloc_headroom)
 
struct sk_buffskb_copy_expand (const struct sk_buff *skb, int newheadroom, int newtailroom, gfp_t gfp_mask)
 
 EXPORT_SYMBOL (skb_copy_expand)
 
int skb_pad (struct sk_buff *skb, int pad)
 
 EXPORT_SYMBOL (skb_pad)
 
unsigned charskb_put (struct sk_buff *skb, unsigned int len)
 
 EXPORT_SYMBOL (skb_put)
 
unsigned charskb_push (struct sk_buff *skb, unsigned int len)
 
 EXPORT_SYMBOL (skb_push)
 
unsigned charskb_pull (struct sk_buff *skb, unsigned int len)
 
 EXPORT_SYMBOL (skb_pull)
 
void skb_trim (struct sk_buff *skb, unsigned int len)
 
 EXPORT_SYMBOL (skb_trim)
 
int ___pskb_trim (struct sk_buff *skb, unsigned int len)
 
 EXPORT_SYMBOL (___pskb_trim)
 
unsigned char__pskb_pull_tail (struct sk_buff *skb, int delta)
 
 EXPORT_SYMBOL (__pskb_pull_tail)
 
int skb_copy_bits (const struct sk_buff *skb, int offset, void *to, int len)
 
 EXPORT_SYMBOL (skb_copy_bits)
 
int skb_splice_bits (struct sk_buff *skb, unsigned int offset, struct pipe_inode_info *pipe, unsigned int tlen, unsigned int flags)
 
int skb_store_bits (struct sk_buff *skb, int offset, const void *from, int len)
 
 EXPORT_SYMBOL (skb_store_bits)
 
__wsum skb_checksum (const struct sk_buff *skb, int offset, int len, __wsum csum)
 
 EXPORT_SYMBOL (skb_checksum)
 
__wsum skb_copy_and_csum_bits (const struct sk_buff *skb, int offset, u8 *to, int len, __wsum csum)
 
 EXPORT_SYMBOL (skb_copy_and_csum_bits)
 
void skb_copy_and_csum_dev (const struct sk_buff *skb, u8 *to)
 
 EXPORT_SYMBOL (skb_copy_and_csum_dev)
 
struct sk_buffskb_dequeue (struct sk_buff_head *list)
 
 EXPORT_SYMBOL (skb_dequeue)
 
struct sk_buffskb_dequeue_tail (struct sk_buff_head *list)
 
 EXPORT_SYMBOL (skb_dequeue_tail)
 
void skb_queue_purge (struct sk_buff_head *list)
 
 EXPORT_SYMBOL (skb_queue_purge)
 
void skb_queue_head (struct sk_buff_head *list, struct sk_buff *newsk)
 
 EXPORT_SYMBOL (skb_queue_head)
 
void skb_queue_tail (struct sk_buff_head *list, struct sk_buff *newsk)
 
 EXPORT_SYMBOL (skb_queue_tail)
 
void skb_unlink (struct sk_buff *skb, struct sk_buff_head *list)
 
 EXPORT_SYMBOL (skb_unlink)
 
void skb_append (struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head *list)
 
 EXPORT_SYMBOL (skb_append)
 
void skb_insert (struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head *list)
 
 EXPORT_SYMBOL (skb_insert)
 
void skb_split (struct sk_buff *skb, struct sk_buff *skb1, const u32 len)
 
 EXPORT_SYMBOL (skb_split)
 
int skb_shift (struct sk_buff *tgt, struct sk_buff *skb, int shiftlen)
 
void skb_prepare_seq_read (struct sk_buff *skb, unsigned int from, unsigned int to, struct skb_seq_state *st)
 
 EXPORT_SYMBOL (skb_prepare_seq_read)
 
unsigned int skb_seq_read (unsigned int consumed, const u8 **data, struct skb_seq_state *st)
 
 EXPORT_SYMBOL (skb_seq_read)
 
void skb_abort_seq_read (struct skb_seq_state *st)
 
 EXPORT_SYMBOL (skb_abort_seq_read)
 
unsigned int skb_find_text (struct sk_buff *skb, unsigned int from, unsigned int to, struct ts_config *config, struct ts_state *state)
 
 EXPORT_SYMBOL (skb_find_text)
 
int skb_append_datato_frags (struct sock *sk, struct sk_buff *skb, int(*getfrag)(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb), void *from, int length)
 
 EXPORT_SYMBOL (skb_append_datato_frags)
 
unsigned charskb_pull_rcsum (struct sk_buff *skb, unsigned int len)
 
 EXPORT_SYMBOL_GPL (skb_pull_rcsum)
 
struct sk_buffskb_segment (struct sk_buff *skb, netdev_features_t features)
 
 EXPORT_SYMBOL_GPL (skb_segment)
 
int skb_gro_receive (struct sk_buff **head, struct sk_buff *skb)
 
 EXPORT_SYMBOL_GPL (skb_gro_receive)
 
void __init skb_init (void)
 
int skb_to_sgvec (struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
 
 EXPORT_SYMBOL_GPL (skb_to_sgvec)
 
int skb_cow_data (struct sk_buff *skb, int tailbits, struct sk_buff **trailer)
 
 EXPORT_SYMBOL_GPL (skb_cow_data)
 
int sock_queue_err_skb (struct sock *sk, struct sk_buff *skb)
 
 EXPORT_SYMBOL (sock_queue_err_skb)
 
void skb_tstamp_tx (struct sk_buff *orig_skb, struct skb_shared_hwtstamps *hwtstamps)
 
 EXPORT_SYMBOL_GPL (skb_tstamp_tx)
 
void skb_complete_wifi_ack (struct sk_buff *skb, bool acked)
 
 EXPORT_SYMBOL_GPL (skb_complete_wifi_ack)
 
bool skb_partial_csum_set (struct sk_buff *skb, u16 start, u16 off)
 
 EXPORT_SYMBOL_GPL (skb_partial_csum_set)
 
void __skb_warn_lro_forwarding (const struct sk_buff *skb)
 
 EXPORT_SYMBOL (__skb_warn_lro_forwarding)
 
void kfree_skb_partial (struct sk_buff *skb, bool head_stolen)
 
 EXPORT_SYMBOL (kfree_skb_partial)
 
bool skb_try_coalesce (struct sk_buff *to, struct sk_buff *from, bool *fragstolen, int *delta_truesize)
 
 EXPORT_SYMBOL (skb_try_coalesce)
 

Variables

struct kmem_cache
*skbuff_head_cache 
__read_mostly
 

Macro Definition Documentation

#define C (   x)    n->x = skb->x
#define kmalloc_reserve (   size,
  gfp,
  node,
  pfmemalloc 
)    __kmalloc_reserve(size, gfp, node, _RET_IP_, pfmemalloc)

Definition at line 156 of file skbuff.c.

#define NETDEV_FRAG_PAGE_MAX_ORDER   get_order(32768)

Definition at line 351 of file skbuff.c.

#define NETDEV_FRAG_PAGE_MAX_SIZE   (PAGE_SIZE << NETDEV_FRAG_PAGE_MAX_ORDER)

Definition at line 352 of file skbuff.c.

#define NETDEV_PAGECNT_MAX_BIAS   NETDEV_FRAG_PAGE_MAX_SIZE

Definition at line 353 of file skbuff.c.

#define pr_fmt (   fmt)    KBUILD_MODNAME ": " fmt

Definition at line 39 of file skbuff.c.

#define TS_SKB_CB (   state)    ((struct skb_seq_state *) &((state)->cb))

Definition at line 2601 of file skbuff.c.

Function Documentation

int ___pskb_trim ( struct sk_buff skb,
unsigned int  len 
)

Definition at line 1298 of file skbuff.c.

struct sk_buff* __alloc_skb ( unsigned int  size,
gfp_t  gfp_mask,
int  flags,
int  node 
)
read

__alloc_skb - allocate a network buffer : size to allocate : allocation mask : If SKB_ALLOC_FCLONE is set, allocate from fclone cache instead of head cache and allocate a cloned (child) skb. If SKB_ALLOC_RX is set, __GFP_MEMALLOC will be used for allocations in case the data is required for writeback : numa node to allocate memory on

Allocate a new &sk_buff. The returned buffer has no headroom and a tail room of at least size bytes. The object has a reference count of one. The return is the buffer. On a failure the return is NULL.

Buffers may only be allocated from interrupts using a of GFP_ATOMIC.

Definition at line 208 of file skbuff.c.

void __kfree_skb ( struct sk_buff skb)

__kfree_skb - private function : buffer

Free an sk_buff. Release anything attached to the buffer. Clean the state. This is an internal helper function. Users should always call kfree_skb

Definition at line 610 of file skbuff.c.

void* __kmalloc_reserve ( size_t  size,
gfp_t  flags,
int  node,
unsigned long  ip,
bool pfmemalloc 
)

Definition at line 158 of file skbuff.c.

struct sk_buff* __netdev_alloc_skb ( struct net_device dev,
unsigned int  length,
gfp_t  gfp_mask 
)
read

__netdev_alloc_skb - allocate an skbuff for rx on a specific device : network device to receive on : length to allocate : get_free_pages mask, passed to alloc_skb

Allocate a new &sk_buff and assign it a usage count of one. The buffer has unspecified headroom built in. Users should allocate the headroom they think they need without accounting for the built in space. The built in space is used for optimisations.

NULL is returned if there is no free memory.

Definition at line 426 of file skbuff.c.

struct sk_buff* __pskb_copy ( struct sk_buff skb,
int  headroom,
gfp_t  gfp_mask 
)
read

__pskb_copy - create copy of an sk_buff with private head. : buffer to copy : headroom of new skb : allocation priority

Make a copy of both an &sk_buff and part of its data, located in header. Fragmented data remain shared. This is used when the caller wishes to modify only header of &sk_buff and needs private copy of the header to alter. Returns NULL on failure or the pointer to the buffer on success. The returned buffer has a reference count of 1.

Definition at line 942 of file skbuff.c.

unsigned char* __pskb_pull_tail ( struct sk_buff skb,
int  delta 
)

__pskb_pull_tail - advance tail of skb header : buffer to reallocate : number of bytes to advance tail

The function makes a sense only on a fragmented &sk_buff, it expands header moving its tail forward and copying necessary data from fragmented part.

&sk_buff MUST have reference count of 1.

Returns NULL (and &sk_buff does not change) if pull failed or value of new tail of skb in the case of success.

All the pointers pointing into skb header may change and must be reloaded after call to this function.

Definition at line 1406 of file skbuff.c.

void __skb_warn_lro_forwarding ( const struct sk_buff skb)

Definition at line 3373 of file skbuff.c.

struct sk_buff* build_skb ( void data,
unsigned int  frag_size 
)
read

build_skb - build a network buffer : data buffer provided by caller : size of fragment, or 0 if head was kmalloced

Allocate a new &sk_buff. Caller provides space holding head and skb_shared_info. must have been allocated by kmalloc() The return is the new skb buffer. On a failure the return is NULL, and 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.

Definition at line 308 of file skbuff.c.

void consume_skb ( struct sk_buff skb)

consume_skb - free an skbuff : buffer to free

Drop a ref to the buffer and free it if the usage count has hit zero Functions identically to kfree_skb, but kfree_skb assumes that the frame is being dropped after a failure and notes that

Definition at line 645 of file skbuff.c.

EXPORT_SYMBOL ( __alloc_skb  )
EXPORT_SYMBOL ( build_skb  )
EXPORT_SYMBOL ( netdev_alloc_frag  )
EXPORT_SYMBOL ( __netdev_alloc_skb  )
EXPORT_SYMBOL ( skb_add_rx_frag  )
EXPORT_SYMBOL ( __kfree_skb  )
EXPORT_SYMBOL ( kfree_skb  )
EXPORT_SYMBOL ( consume_skb  )
EXPORT_SYMBOL ( skb_clone  )
EXPORT_SYMBOL ( skb_copy  )
EXPORT_SYMBOL ( __pskb_copy  )
EXPORT_SYMBOL ( pskb_expand_head  )
EXPORT_SYMBOL ( skb_realloc_headroom  )
EXPORT_SYMBOL ( skb_copy_expand  )
EXPORT_SYMBOL ( skb_pad  )
EXPORT_SYMBOL ( skb_put  )
EXPORT_SYMBOL ( skb_push  )
EXPORT_SYMBOL ( skb_pull  )
EXPORT_SYMBOL ( skb_trim  )
EXPORT_SYMBOL ( ___pskb_trim  )
EXPORT_SYMBOL ( __pskb_pull_tail  )
EXPORT_SYMBOL ( skb_copy_bits  )
EXPORT_SYMBOL ( skb_store_bits  )
EXPORT_SYMBOL ( skb_checksum  )
EXPORT_SYMBOL ( skb_copy_and_csum_bits  )
EXPORT_SYMBOL ( skb_copy_and_csum_dev  )
EXPORT_SYMBOL ( skb_dequeue  )
EXPORT_SYMBOL ( skb_dequeue_tail  )
EXPORT_SYMBOL ( skb_queue_purge  )
EXPORT_SYMBOL ( skb_queue_head  )
EXPORT_SYMBOL ( skb_queue_tail  )
EXPORT_SYMBOL ( skb_unlink  )
EXPORT_SYMBOL ( skb_append  )
EXPORT_SYMBOL ( skb_insert  )
EXPORT_SYMBOL ( skb_split  )
EXPORT_SYMBOL ( skb_prepare_seq_read  )
EXPORT_SYMBOL ( skb_seq_read  )
EXPORT_SYMBOL ( skb_abort_seq_read  )
EXPORT_SYMBOL ( skb_find_text  )
EXPORT_SYMBOL ( skb_append_datato_frags  )
EXPORT_SYMBOL ( sock_queue_err_skb  )
EXPORT_SYMBOL ( __skb_warn_lro_forwarding  )
EXPORT_SYMBOL ( kfree_skb_partial  )
EXPORT_SYMBOL ( skb_try_coalesce  )
EXPORT_SYMBOL_GPL ( skb_morph  )
EXPORT_SYMBOL_GPL ( skb_copy_ubufs  )
EXPORT_SYMBOL_GPL ( skb_pull_rcsum  )
EXPORT_SYMBOL_GPL ( skb_segment  )
EXPORT_SYMBOL_GPL ( skb_gro_receive  )
EXPORT_SYMBOL_GPL ( skb_to_sgvec  )
EXPORT_SYMBOL_GPL ( skb_cow_data  )
EXPORT_SYMBOL_GPL ( skb_tstamp_tx  )
EXPORT_SYMBOL_GPL ( skb_complete_wifi_ack  )
EXPORT_SYMBOL_GPL ( skb_partial_csum_set  )
void kfree_skb ( struct sk_buff skb)

kfree_skb - free an sk_buff : buffer to free

Drop a reference to the buffer and free it if the usage count has hit zero.

Definition at line 624 of file skbuff.c.

void kfree_skb_partial ( struct sk_buff skb,
bool  head_stolen 
)

Definition at line 3380 of file skbuff.c.

void* netdev_alloc_frag ( unsigned int  fragsz)

netdev_alloc_frag - allocate a page fragment : fragment size

Allocates a frag from a page for receive buffer. Uses GFP_ATOMIC allocations.

Definition at line 407 of file skbuff.c.

int pskb_expand_head ( struct sk_buff skb,
int  nhead,
int  ntail,
gfp_t  gfp_mask 
)

pskb_expand_head - reallocate header of &sk_buff : buffer to reallocate : room to add at head : room to add at tail : allocation priority

Expands (or creates identical copy, if &nhead and &ntail are zero) header of skb. &sk_buff itself is not changed. &sk_buff MUST have reference count of 1. Returns zero in the case of success or error, if expansion failed. In the last case, &sk_buff is not changed.

All the pointers pointing into skb header may change and must be reloaded after call to this function.

Definition at line 1004 of file skbuff.c.

void skb_abort_seq_read ( struct skb_seq_state *  st)

skb_abort_seq_read - Abort a sequential read of skb data : state variable

Must be called if skb_seq_read() was not called until it returned 0.

Definition at line 2594 of file skbuff.c.

void skb_add_rx_frag ( struct sk_buff skb,
int  i,
struct page page,
int  off,
int  size,
unsigned int  truesize 
)

Definition at line 458 of file skbuff.c.

void skb_append ( struct sk_buff old,
struct sk_buff newsk,
struct sk_buff_head list 
)

skb_append - append a buffer : buffer to insert after : buffer to insert : list to use

Place a packet after a given packet in a list. The list locks are taken and this function is atomic with respect to other list locked calls. A buffer cannot be placed on two lists at the same time.

Definition at line 2225 of file skbuff.c.

int skb_append_datato_frags ( struct sock sk,
struct sk_buff skb,
int(*)(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb getfrag,
void from,
int  length 
)

skb_append_datato_frags - append the user data to a skb : sock structure : skb structure to be appened with user data. : call back function to be used for getting the user data : pointer to user message iov : length of the iov message

Description: This procedure append the user data in the fragment part of the skb if any page alloc fails user this procedure returns -ENOMEM

Definition at line 2655 of file skbuff.c.

__wsum skb_checksum ( const struct sk_buff skb,
int  offset,
int  len,
__wsum  csum 
)

Definition at line 1919 of file skbuff.c.

struct sk_buff* skb_clone ( struct sk_buff skb,
gfp_t  gfp_mask 
)
read

skb_clone - duplicate an sk_buff : buffer to clone : allocation priority

Duplicate an &sk_buff. The new one is not owned by a socket. Both copies share the same packet data but not structure. The new buffer has a reference count of 1. If the allocation fails the function returns NULL otherwise the new buffer is returned.

If this function is called from an interrupt gfp_mask() must be GFP_ATOMIC.

Definition at line 828 of file skbuff.c.

void skb_complete_wifi_ack ( struct sk_buff skb,
bool  acked 
)

Definition at line 3325 of file skbuff.c.

struct sk_buff* skb_copy ( const struct sk_buff skb,
gfp_t  gfp_mask 
)
read

skb_copy - create private copy of an sk_buff : buffer to copy : allocation priority

Make a copy of both an &sk_buff and its data. This is used when the caller wishes to modify the data and needs a private copy of the data to alter. Returns NULL on failure or the pointer to the buffer on success. The returned buffer has a reference count of 1.

As by-product this function converts non-linear &sk_buff to linear one, so that &sk_buff becomes completely private and caller is allowed to modify all the data of returned buffer. This means that this function is not recommended for use in circumstances when only header is going to be modified. Use pskb_copy() instead.

Definition at line 905 of file skbuff.c.

__wsum skb_copy_and_csum_bits ( const struct sk_buff skb,
int  offset,
u8 to,
int  len,
__wsum  csum 
)

Definition at line 1992 of file skbuff.c.

void skb_copy_and_csum_dev ( const struct sk_buff skb,
u8 to 
)

Definition at line 2069 of file skbuff.c.

int skb_copy_bits ( const struct sk_buff skb,
int  offset,
void to,
int  len 
)

skb_copy_bits - copy bits from skb to kernel buffer : source skb : offset in source : destination buffer : number of bytes to copy

Copy the specified number of bytes from the source skb to the destination buffer.

CAUTION ! : If its prototype is ever changed, check arch/{*}/net/{*}.S files, since it is called from BPF assembly code.

Definition at line 1538 of file skbuff.c.

struct sk_buff* skb_copy_expand ( const struct sk_buff skb,
int  newheadroom,
int  newtailroom,
gfp_t  gfp_mask 
)
read

skb_copy_expand - copy and expand sk_buff : buffer to copy : new free bytes at head : new free bytes at tail : allocation priority

Make a copy of both an &sk_buff and its data and while doing so allocate additional space.

This is used when the caller wishes to modify the data and needs a private copy of the data to alter as well as more space for new fields. Returns NULL on failure or the pointer to the buffer on success. The returned buffer has a reference count of 1.

You must pass GFP_ATOMIC as the allocation priority if this function is called from an interrupt.

Definition at line 1127 of file skbuff.c.

int skb_copy_ubufs ( struct sk_buff skb,
gfp_t  gfp_mask 
)

skb_copy_ubufs - copy userspace skb frags buffers to kernel : the skb to modify : allocation priority

This must be called on SKBTX_DEV_ZEROCOPY skb. It will copy all frags into kernel and drop the reference to userspace pages.

If this function is called from an interrupt gfp_mask() must be GFP_ATOMIC.

Returns 0 on success or a negative error code on failure to allocate kernel memory to copy to.

Definition at line 768 of file skbuff.c.

int skb_cow_data ( struct sk_buff skb,
int  tailbits,
struct sk_buff **  trailer 
)

skb_cow_data - Check that a socket buffer's data buffers are writable : The socket buffer to check. : Amount of trailing space to be added : Returned pointer to the skb where the space begins

Make sure that the data buffers attached to a socket buffer are writable. If they are not, private copies are made of the data buffers and the socket buffer is set to use these instead.

If is given, make sure that there is space to write bytes of data beyond current end of socket buffer. will be set to point to the skb in which this space begins.

The number of scatterlist elements required to completely map the COW'd and extended socket buffer will be returned.

Definition at line 3160 of file skbuff.c.

struct sk_buff* skb_dequeue ( struct sk_buff_head list)
read

skb_dequeue - remove from the head of the queue : list to dequeue from

Remove the head of the list. The list lock is taken so the function may be used safely with other locking list functions. The head item is returned or NULL if the list is empty.

Definition at line 2105 of file skbuff.c.

struct sk_buff* skb_dequeue_tail ( struct sk_buff_head list)
read

skb_dequeue_tail - remove from the tail of the queue : list to dequeue from

Remove the tail of the list. The list lock is taken so the function may be used safely with other locking list functions. The tail item is returned or NULL if the list is empty.

Definition at line 2125 of file skbuff.c.

unsigned int skb_find_text ( struct sk_buff skb,
unsigned int  from,
unsigned int  to,
struct ts_config config,
struct ts_state state 
)

skb_find_text - Find a text pattern in skb data : the buffer to look in : search offset : search limit : textsearch configuration : uninitialized textsearch state variable

Finds a pattern in the skb data according to the specified textsearch configuration. Use textsearch_next() to retrieve subsequent occurrences of the pattern. Returns the offset to the first occurrence or UINT_MAX if no match was found.

Definition at line 2628 of file skbuff.c.

int skb_gro_receive ( struct sk_buff **  head,
struct sk_buff skb 
)

Definition at line 2904 of file skbuff.c.

void __init skb_init ( void  )

Definition at line 3048 of file skbuff.c.

void skb_insert ( struct sk_buff old,
struct sk_buff newsk,
struct sk_buff_head list 
)

skb_insert - insert a buffer : buffer to insert before : buffer to insert : list to use

Place a packet before a given packet in a list. The list locks are taken and this function is atomic with respect to other list locked calls.

A buffer cannot be placed on two lists at the same time.

Definition at line 2247 of file skbuff.c.

struct sk_buff* skb_morph ( struct sk_buff dst,
struct sk_buff src 
)
read

skb_morph - morph one skb into another : the skb to receive the contents : the skb to supply the contents

This is identical to skb_clone except that the target skb is supplied by the user.

The target skb is returned upon exit.

Definition at line 746 of file skbuff.c.

int skb_pad ( struct sk_buff skb,
int  pad 
)

skb_pad - zero pad the tail of an skb : buffer to pad : space to pad

Ensure that a buffer is followed by a padding area that is zero filled. Used by network drivers which may DMA or transfer data beyond the buffer end onto the wire.

May return error in out of memory cases. The skb is freed on error.

Definition at line 1189 of file skbuff.c.

bool skb_partial_csum_set ( struct sk_buff skb,
u16  start,
u16  off 
)

skb_partial_csum_set - set up and verify partial csum values for packet : the skb to set : the number of bytes after skb->data to start checksumming. : the offset from start to place the checksum.

For untrusted partially-checksummed packets, we need to make sure the values for skb->csum_start and skb->csum_offset are valid so we don't oops.

This function checks and sets those values and skb->ip_summed: if this returns false you should drop the packet.

Definition at line 3358 of file skbuff.c.

void skb_prepare_seq_read ( struct sk_buff skb,
unsigned int  from,
unsigned int  to,
struct skb_seq_state *  st 
)

skb_prepare_seq_read - Prepare a sequential read of skb data : the buffer to read : lower offset of data to be read : upper offset of data to be read : state variable

Initializes the specified state variable. Must be called before invoking skb_seq_read() for the first time.

Definition at line 2489 of file skbuff.c.

unsigned char* skb_pull ( struct sk_buff skb,
unsigned int  len 
)

skb_pull - remove data from the start of a buffer : buffer to use : amount of data to remove

This function removes data from the start of a buffer, returning the memory to the headroom. A pointer to the next data in the buffer is returned. Once the data has been pulled future pushes will overwrite the old data.

Definition at line 1273 of file skbuff.c.

unsigned char* skb_pull_rcsum ( struct sk_buff skb,
unsigned int  len 
)

skb_pull_rcsum - pull skb and update receive checksum : buffer to update : length of data pulled

This function performs an skb_pull on the packet and updates the CHECKSUM_COMPLETE checksum. It should be used on receive path processing instead of skb_pull unless you know that the checksum difference is zero (e.g., a valid IP header) or you are setting ip_summed to CHECKSUM_NONE.

Definition at line 2724 of file skbuff.c.

unsigned char* skb_push ( struct sk_buff skb,
unsigned int  len 
)

skb_push - add data to the start of a buffer : buffer to use : amount of data to add

This function extends the used data area of the buffer at the buffer start. If this would exceed the total buffer headroom the kernel will panic. A pointer to the first byte of the extra data is returned.

Definition at line 1253 of file skbuff.c.

unsigned char* skb_put ( struct sk_buff skb,
unsigned int  len 
)

skb_put - add data to a buffer : buffer to use : amount of data to add

This function extends the used data area of the buffer. If this would exceed the total buffer size the kernel will panic. A pointer to the first byte of the extra data is returned.

Definition at line 1232 of file skbuff.c.

void skb_queue_head ( struct sk_buff_head list,
struct sk_buff newsk 
)

skb_queue_head - queue a buffer at the list head : list to use : buffer to queue

Queue a buffer at the start of the list. This function takes the list lock and can be used safely with other locking &sk_buff functions safely.

A buffer cannot be placed on two lists at the same time.

Definition at line 2164 of file skbuff.c.

void skb_queue_purge ( struct sk_buff_head list)

skb_queue_purge - empty a list : list to empty

Delete all buffers on an &sk_buff list. Each buffer is removed from the list and one reference dropped. This function takes the list lock and is atomic with respect to other list locking functions.

Definition at line 2145 of file skbuff.c.

void skb_queue_tail ( struct sk_buff_head list,
struct sk_buff newsk 
)

skb_queue_tail - queue a buffer at the list tail : list to use : buffer to queue

Queue a buffer at the tail of the list. This function takes the list lock and can be used safely with other locking &sk_buff functions safely.

A buffer cannot be placed on two lists at the same time.

Definition at line 2185 of file skbuff.c.

struct sk_buff* skb_realloc_headroom ( struct sk_buff skb,
unsigned int  headroom 
)
read

Definition at line 1090 of file skbuff.c.

struct sk_buff* skb_segment ( struct sk_buff skb,
netdev_features_t  features 
)
read

skb_segment - Perform protocol segmentation on skb. : buffer to segment : features for the output path (see dev->features)

This function performs segmentation on the given skb. It returns a pointer to the first in a list of new skbs for the segments. In case of error it returns ERR_PTR(err).

Definition at line 2743 of file skbuff.c.

unsigned int skb_seq_read ( unsigned int  consumed,
const u8 **  data,
struct skb_seq_state *  st 
)

skb_seq_read - Sequentially read skb data : number of bytes consumed by the caller so far : destination pointer for data to be returned : state variable

Reads a block of skb data at &consumed relative to the lower offset specified to skb_prepare_seq_read(). Assigns the head of the data block to &data and returns the length of the block or 0 if the end of the skb data or the upper offset has been reached.

The caller is not required to consume all of the data returned, i.e. &consumed is typically set to the number of bytes already consumed and the next call to skb_seq_read() will return the remaining part of the block.

Note 1: The size of each block of data returned can be arbitrary, this limitation is the cost for zerocopy seqeuental reads of potentially non linear data.

Note 2: Fragment lists within fragments are not implemented at the moment, state->root_skb could be replaced with a stack for this purpose.

Definition at line 2525 of file skbuff.c.

int skb_shift ( struct sk_buff tgt,
struct sk_buff skb,
int  shiftlen 
)

skb_shift - Shifts paged data partially from skb to another : buffer into which tail data gets added : buffer from which the paged data comes from : shift up to this many bytes

Attempts to shift up to shiftlen worth of bytes, which may be less than the length of the skb, from skb to tgt. Returns number bytes shifted. It's up to caller to free skb if everything was shifted.

If runs out of frags, the whole operation is aborted.

Skb cannot include anything else but paged data while tgt is allowed to have non-paged data as well.

TODO: full sized shift could be optimized but that would need specialized skb free'er to handle frags without up-to-date nr_frags.

Definition at line 2363 of file skbuff.c.

int skb_splice_bits ( struct sk_buff skb,
unsigned int  offset,
struct pipe_inode_info pipe,
unsigned int  tlen,
unsigned int  flags 
)

Definition at line 1777 of file skbuff.c.

void skb_split ( struct sk_buff skb,
struct sk_buff skb1,
const u32  len 
)

skb_split - Split fragmented skb to two parts at length len. : the buffer to split : the buffer to receive the second part : new length for skb

Definition at line 2325 of file skbuff.c.

int skb_store_bits ( struct sk_buff skb,
int  offset,
const void from,
int  len 
)

skb_store_bits - store bits from kernel buffer to skb : destination buffer : offset in destination : source buffer : number of bytes to copy

Copy the specified number of bytes from the source buffer to the destination skb. This function handles all the messy bits of traversing fragment lists and such.

Definition at line 1845 of file skbuff.c.

int skb_to_sgvec ( struct sk_buff skb,
struct scatterlist sg,
int  offset,
int  len 
)

Definition at line 3133 of file skbuff.c.

void skb_trim ( struct sk_buff skb,
unsigned int  len 
)

skb_trim - remove end from a buffer : buffer to alter : new length

Cut the length of a buffer down by removing data from the tail. If the buffer is already under the length specified it is not modified. The skb must be linear.

Definition at line 1288 of file skbuff.c.

bool skb_try_coalesce ( struct sk_buff to,
struct sk_buff from,
bool fragstolen,
int delta_truesize 
)

skb_try_coalesce - try to merge skb to prior one : prior buffer : buffer to add : pointer to boolean : how much more was allocated than was requested

Definition at line 3398 of file skbuff.c.

void skb_tstamp_tx ( struct sk_buff orig_skb,
struct skb_shared_hwtstamps hwtstamps 
)

Definition at line 3286 of file skbuff.c.

void skb_unlink ( struct sk_buff skb,
struct sk_buff_head list 
)

skb_unlink - remove a buffer from a list : buffer to remove : list to use

Remove a packet from a list. The list locks are taken and this function is atomic with respect to other list locked calls

You must know what list the SKB is on.

Definition at line 2205 of file skbuff.c.

int sock_queue_err_skb ( struct sock sk,
struct sk_buff skb 
)

Definition at line 3263 of file skbuff.c.

Variable Documentation

struct kmem_cache* skbuff_fclone_cache __read_mostly

Definition at line 74 of file skbuff.c.