User Tools

Site Tools


mywiki:linux:skb

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
mywiki:linux:skb [2021/10/07 10:49] – [skb_put()] shaoguohmywiki:linux:skb [2022/04/02 17:29] (current) – external edit 127.0.0.1
Line 42: Line 42:
 ====== skb_headroom(), skb_tailroom() ====== ====== skb_headroom(), skb_tailroom() ======
 Prototype / Description:  Prototype / Description: 
-| int skb_headroom(const struct sk_buff *skb); |  bytes at buffer head |+| int skb_headroom(const struct sk_buff *skb); | bytes at buffer head |
 | int skb_tailroom(const struct sk_buff *skb); | bytes at buffer  | | int skb_tailroom(const struct sk_buff *skb); | bytes at buffer  |
 {{:mywiki:linux:skb.png?direct|}} {{:mywiki:linux:skb.png?direct|}}
 +
 +
 +
 ====== skb_reserve() ====== ====== skb_reserve() ======
 Prototype / Description:  Prototype / Description: 
-| void skb_reserve(struct sk_buff *skb, unsigned int len); | adjust headroom |+| void skb_reserve(struct sk_buff *skb, unsigned int len); | adjust headroom \\ skb->data += len; \\ skb->tail += len; |
 {{:mywiki:linux:skb_reserve.png?direct|}} {{:mywiki:linux:skb_reserve.png?direct|}}
 +| linear/non-paged skb API | non-linear/paged skb API via skb_shared |
 +| skb_push | NA |
 +| skb_pull | **p**skb_pull: p means **paged** |
 +| skb_put | pskb_put |
 +| skb_trim | pskb_trim |
 +
 ====== skb_push() ====== ====== skb_push() ======
 Prototype / Description: Prototype / Description:
-| unsigned char *skb_push(struct sk_buff *skb, unsigned int len); | add data to the start of a buffer |+| unsigned char *skb_push(struct sk_buff *skb, unsigned int len); | add data to the start of a buffer \\ skb->data -= len; \\ skb->len  += len; |
 {{:mywiki:linux:skb_push.png?direct|}} {{:mywiki:linux:skb_push.png?direct|}}
 ====== skb_pull() ====== ====== skb_pull() ======
 Prototype / Description:  Prototype / Description: 
-| unsigned char *skb_pull(struct sk_buff *skb, unsigned int len); | remove data from the start of a buffer |+| unsigned char *skb_pull(struct sk_buff *skb, unsigned int len); | remove data from the start of a buffer \\ skb->len -= len; \\ skb->data += len;|
 {{:mywiki:linux:skb_pull.png?direct|}} {{:mywiki:linux:skb_pull.png?direct|}}
 ====== skb_put() ====== ====== skb_put() ======
Line 61: Line 70:
 | unsigned char *skb_put(struct sk_buff *skb, unsigned int len); | add data to a buffer \\ skb->tail += len; \\ skb->len  += len; | | unsigned char *skb_put(struct sk_buff *skb, unsigned int len); | add data to a buffer \\ skb->tail += len; \\ skb->len  += len; |
 {{:mywiki:linux:skb_put.png?direct|}} {{:mywiki:linux:skb_put.png?direct|}}
 +
 +
 ====== skb_trim() ====== ====== skb_trim() ======
 Prototype / Description:  Prototype / Description: 
-| void skb_trim(struct sk_buff *skb, unsigned int len); | remove end from a buffer |+| void skb_trim(struct sk_buff *skb, unsigned int len); | remove end from a buffer \\ skb->len -= len; \\ skb->tail = skb->data + offset |
 {{:mywiki:linux:skb_trim.png?direct|}} {{:mywiki:linux:skb_trim.png?direct|}}
  
Line 109: Line 120:
 } </file> } </file>
  
 +
 +
 +====== other skb APIs ======
 +  * skb_orphan():  使SKB不属于任何传输控制块。
 +     * skb->destructor(skb);
 +     * skb->destructor = NULL;
 +     * skb->sk = NULL;
 +  * skb_cow(): 确保SKB存在指定的headroom空间。如果不足,会重新分配。
 +     * skb_cow - copy header of skb when it is required, iek, if the skb passed lacks sufficient headroom or its data part is shared, data is reallocated. If reallocation fails, an error is returned and original skb is not changed.
 +  * skb_condense(): try to get rid of fragments/frag_list if possible. Can be used to save memory before skb is added to a busy queue. If packet has bytes in frags and enough tail room in skb->head, pull all of them, so that we can free the frags right now and adjust truesize.
mywiki/linux/skb.1633574954.txt.gz · Last modified: (external edit)