Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 224785
b: refs/heads/master
c: ca44ac3
h: refs/heads/master
i:
  224783: ac3e211
v: v3
  • Loading branch information
Changli Gao authored and David S. Miller committed Dec 3, 2010
1 parent 4624180 commit e6c3e4e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 289700dbc40c78741f17e2304ed4ac0db3c3afd3
refs/heads/master: ca44ac386181ba710a9ab6db900d6c1e5451b366
34 changes: 23 additions & 11 deletions trunk/net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,28 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,

size = SKB_DATA_ALIGN(size);

/* Check if we can avoid taking references on fragments if we own
* the last reference on skb->head. (see skb_release_data())
*/
if (!skb->cloned)
fastpath = true;
else {
int delta = skb->nohdr ? (1 << SKB_DATAREF_SHIFT) + 1 : 1;

fastpath = atomic_read(&skb_shinfo(skb)->dataref) == delta;
}

if (fastpath &&
size + sizeof(struct skb_shared_info) <= ksize(skb->head)) {
memmove(skb->head + size, skb_shinfo(skb),
offsetof(struct skb_shared_info,
frags[skb_shinfo(skb)->nr_frags]));
memmove(skb->head + nhead, skb->head,
skb_tail_pointer(skb) - skb->head);
off = nhead;
goto adjust_others;
}

data = kmalloc(size + sizeof(struct skb_shared_info), gfp_mask);
if (!data)
goto nodata;
Expand All @@ -791,17 +813,6 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
skb_shinfo(skb),
offsetof(struct skb_shared_info, frags[skb_shinfo(skb)->nr_frags]));

/* Check if we can avoid taking references on fragments if we own
* the last reference on skb->head. (see skb_release_data())
*/
if (!skb->cloned)
fastpath = true;
else {
int delta = skb->nohdr ? (1 << SKB_DATAREF_SHIFT) + 1 : 1;

fastpath = atomic_read(&skb_shinfo(skb)->dataref) == delta;
}

if (fastpath) {
kfree(skb->head);
} else {
Expand All @@ -816,6 +827,7 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
off = (data + nhead) - skb->head;

skb->head = data;
adjust_others:
skb->data += off;
#ifdef NET_SKBUFF_DATA_USES_OFFSET
skb->end = size;
Expand Down

0 comments on commit e6c3e4e

Please sign in to comment.