diff options
author | Jiri Pirko | 2014-11-19 14:05:01 +0100 |
---|---|---|
committer | David S. Miller | 2014-11-21 14:20:17 -0500 |
commit | e21951212f03b8d805795d8f71206853b2ab344d (patch) | |
tree | 2ecd2d59b8ca78f40e8a695ba5599e60dc652a48 /net/core | |
parent | 15255a43e6c917813800702e100267046e240cc0 (diff) |
net: move make_writable helper into common code
note that skb_make_writable already exists in net/netfilter/core.c
but does something slightly different.
Suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/skbuff.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 700189604f3d..d11bbe0da355 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -4151,6 +4151,18 @@ err_free: } EXPORT_SYMBOL(skb_vlan_untag); +int skb_ensure_writable(struct sk_buff *skb, int write_len) +{ + if (!pskb_may_pull(skb, write_len)) + return -ENOMEM; + + if (!skb_cloned(skb) || skb_clone_writable(skb, write_len)) + return 0; + + return pskb_expand_head(skb, 0, 0, GFP_ATOMIC); +} +EXPORT_SYMBOL(skb_ensure_writable); + /** * alloc_skb_with_frags - allocate skb with page frags * |