Skip to content

Commit

Permalink
net: makes skb_splice_bits() aware of skb->head_frag
Browse files Browse the repository at this point in the history
__skb_splice_bits() can check if skb to be spliced has its skb->head
mapped to a page fragment, instead of a kmalloc() area.

If so we can avoid a copy of the skb head and get a reference on
underlying page.

Signed-off-by: Eric Dumazet <[email protected]>
Cc: Ilpo Järvinen <[email protected]>
Cc: Herbert Xu <[email protected]>
Cc: Maciej Żenczykowski <[email protected]>
Cc: Neal Cardwell <[email protected]>
Cc: Tom Herbert <[email protected]>
Cc: Jeff Kirsher <[email protected]>
Cc: Ben Hutchings <[email protected]>
Cc: Matt Carlson <[email protected]>
Cc: Michael Chan <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Eric Dumazet authored and davem330 committed May 1, 2012
1 parent 329033f commit 1d0c0b3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1699,14 +1699,18 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info *pipe,
struct splice_pipe_desc *spd, struct sock *sk)
{
int seg;
bool head_is_linear = !skb->head_frag;

/*
* map the linear part
/* map the linear part :
* If skb->head_frag is set, this 'linear' part is backed
* by a fragment, and we can avoid a copy.
*/
if (__splice_segment(virt_to_page(skb->data),
(unsigned long) skb->data & (PAGE_SIZE - 1),
skb_headlen(skb),
offset, len, skb, spd, true, sk, pipe))
offset, len, skb, spd,
head_is_linear,
sk, pipe))
return true;

/*
Expand Down

0 comments on commit 1d0c0b3

Please sign in to comment.