Commit 33c1abbe authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

[NET]: Use pskb_expand_head() instead of skb_copy() in skb_checksum_help().

Here is the patch that you wanted to shoot holes at :)

The idea is simple.  None of the callers of skb_checksum are passing it
skb's which are shared.  They may be cloned however.  But the application
checksum is always in the skb header so there is no need to linearise it.

Supposing all these assumptions are correct, then we can avoid the overhead
of skb_copy() and get away with pskb_expand_head().

If the assumption is wrong, we will find out because
pskb_expand_head() will BUG() if skb_shared() is true.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@redhat.com>
parent aab66c40
......@@ -1144,16 +1144,10 @@ int skb_checksum_help(struct sk_buff **pskb, int inward)
goto out;
}
if (skb_shared(*pskb) || skb_cloned(*pskb)) {
struct sk_buff *newskb = skb_copy(*pskb, GFP_ATOMIC);
if (!newskb) {
ret = -ENOMEM;
if (skb_cloned(*pskb)) {
ret = pskb_expand_head(*pskb, 0, 0, GFP_ATOMIC);
if (ret)
goto out;
}
if ((*pskb)->sk)
skb_set_owner_w(newskb, (*pskb)->sk);
kfree_skb(*pskb);
*pskb = newskb;
}
if (offset > (int)(*pskb)->len)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment