Skip to contentSkip to conversation

skb_put: remove not needed check for skb linearity

PATCH In review Paulius Zaleckas 2 participants 2 messages Mar 30, 2010 – Mar 31, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 skb_put: remove not needed check for skb linearity

It is safe to call skb_put() on packets containing fragments.

Actually I have a case where I allocate packet header with some extra headroom and then I dynamically add data as frag_list. After adding frags I have to add more data to header and skb_put() just BUG's on me :)

And we will save couple instructions for CPU.

---

 include/linux/skbuff.h |    1 -
 net/core/skbuff.c      |    1 -
 2 files changed, 0 insertions(+), 2 deletions(-)
include/linux/skbuff.h +0 -1
index 124f90c..194e9fa 100644
@@ -1108,7 +1108,6 @@ extern unsigned char *skb_put(struct sk_buff *skb, unsigned int len);
 static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len)
 {
 	unsigned char *tmp = skb_tail_pointer(skb);
-	SKB_LINEAR_ASSERT(skb);
 	skb->tail += len;
 	skb->len  += len;
 	return tmp;
net/core/skbuff.c +0 -1
index 93c4e06..ea1ca61 100644
@@ -1011,7 +1011,6 @@ EXPORT_SYMBOL(skb_pad);
 unsigned char *skb_put(struct sk_buff *skb, unsigned int len)
 {
 	unsigned char *tmp = skb_tail_pointer(skb);
-	SKB_LINEAR_ASSERT(skb);
 	skb->tail += len;
 	skb->len  += len;
 	if (unlikely(skb->tail > skb->end))
maintainer
#1 lore raw

From: Paulius Zaleckas <[email protected]>
Date: Tue, 30 Mar 2010 16:01:31 +0300

Quoted 10 lines

It is safe to call skb_put() on packets containing fragments.

Actually I have a case where I allocate packet header with some extra headroom and then I dynamically add data as frag_list. After adding frags I have to add more data to header and skb_put() just BUG's on me :)

And we will save couple instructions for CPU.

No, you really cannot do this, that check is very much intentional and needs to be there. Otherwise we will allow violations of the semantics of the SKB data area.

Once you put even one byte of non-linear data into the skb, all data must be "put" to the end of that non-linear area, without exception.

You can't just stuff arbitrary things "in-between" the linear and the non-linear stuff.

You'll need to find a way to construct your SKBs properly such that the entirety of the linear area is constructed before you start adding non-linear elements.