mirror of
https://github.com/torvalds/linux.git
synced 2024-12-03 09:31:26 +00:00
net: core: use helper skb_ensure_writable in more places
Use helper skb_ensure_writable in two more places to simplify the code. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
3289086210
commit
8211fbfaf2
@ -3165,12 +3165,9 @@ int skb_checksum_help(struct sk_buff *skb)
|
|||||||
offset += skb->csum_offset;
|
offset += skb->csum_offset;
|
||||||
BUG_ON(offset + sizeof(__sum16) > skb_headlen(skb));
|
BUG_ON(offset + sizeof(__sum16) > skb_headlen(skb));
|
||||||
|
|
||||||
if (skb_cloned(skb) &&
|
ret = skb_ensure_writable(skb, offset + sizeof(__sum16));
|
||||||
!skb_clone_writable(skb, offset + sizeof(__sum16))) {
|
if (ret)
|
||||||
ret = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
|
goto out;
|
||||||
if (ret)
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
*(__sum16 *)(skb->data + offset) = csum_fold(csum) ?: CSUM_MANGLED_0;
|
*(__sum16 *)(skb->data + offset) = csum_fold(csum) ?: CSUM_MANGLED_0;
|
||||||
out_set_summed:
|
out_set_summed:
|
||||||
@ -3205,12 +3202,11 @@ int skb_crc32c_csum_help(struct sk_buff *skb)
|
|||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (skb_cloned(skb) &&
|
|
||||||
!skb_clone_writable(skb, offset + sizeof(__le32))) {
|
ret = skb_ensure_writable(skb, offset + sizeof(__le32));
|
||||||
ret = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
|
if (ret)
|
||||||
if (ret)
|
goto out;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
crc32c_csum = cpu_to_le32(~__skb_checksum(skb, start,
|
crc32c_csum = cpu_to_le32(~__skb_checksum(skb, start,
|
||||||
skb->len - start, ~(__u32)0,
|
skb->len - start, ~(__u32)0,
|
||||||
crc32c_csum_stub));
|
crc32c_csum_stub));
|
||||||
|
Loading…
Reference in New Issue
Block a user