Skip to content

Commit

Permalink
net: relax expensive skb_unclone() in iptunnel_handle_offloads()
Browse files Browse the repository at this point in the history
Locally generated TCP GSO packets having to go through a GRE/SIT/IPIP
tunnel have to go through an expensive skb_unclone()

Reallocating skb->head is a lot of work.

Test should really check if a 'real clone' of the packet was done.

TCP does not care if the original gso_type is changed while the packet
travels in the stack.

This adds skb_header_unclone() which is a variant of skb_clone()
using skb_header_cloned() check instead of skb_cloned().

This variant can probably be used from other points.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed May 3, 2016
1 parent c0ef079 commit 9580bf2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions include/linux/skbuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,16 @@ static inline int skb_header_cloned(const struct sk_buff *skb)
return dataref != 1;
}

static inline int skb_header_unclone(struct sk_buff *skb, gfp_t pri)
{
might_sleep_if(gfpflags_allow_blocking(pri));

if (skb_header_cloned(skb))
return pskb_expand_head(skb, 0, 0, pri);

return 0;
}

/**
* skb_header_release - release reference to header
* @skb: buffer to operate on
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/ip_tunnel_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ int iptunnel_handle_offloads(struct sk_buff *skb,
}

if (skb_is_gso(skb)) {
err = skb_unclone(skb, GFP_ATOMIC);
err = skb_header_unclone(skb, GFP_ATOMIC);
if (unlikely(err))
return err;
skb_shinfo(skb)->gso_type |= gso_type_mask;
Expand Down

0 comments on commit 9580bf2

Please sign in to comment.