Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 214323
b: refs/heads/master
c: 1fd6304
h: refs/heads/master
i:
  214321: 982de45
  214319: 2e5d5d2
v: v3
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Sep 7, 2010
1 parent ff7a288 commit d3d403b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 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: 9d348af47656a65a697ff55a53daf294ea4d5662
refs/heads/master: 1fd63041c49c5c6ed1fe58b7bccc2de462d51e2b
25 changes: 20 additions & 5 deletions trunk/net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
u8 *data;
int size = nhead + (skb_end_pointer(skb) - skb->head) + ntail;
long off;
bool fastpath;

BUG_ON(nhead < 0);

Expand All @@ -800,14 +801,28 @@ 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]));

for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
get_page(skb_shinfo(skb)->frags[i].page);
/* 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;

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

skb_release_data(skb);
if (fastpath) {
kfree(skb->head);
} else {
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
get_page(skb_shinfo(skb)->frags[i].page);

if (skb_has_frag_list(skb))
skb_clone_fraglist(skb);

skb_release_data(skb);
}
off = (data + nhead) - skb->head;

skb->head = data;
Expand Down

0 comments on commit d3d403b

Please sign in to comment.