From: "Michał Mirosław" <mirqus@gmail.com>
To: Pravin B Shelar <pshelar@nicira.com>
Cc: netdev@vger.kernel.org, jesse@nicira.com, eric.dumazet@gmail.com
Subject: Re: [PATCH 1/2] net: Add skb_unclone() helper function.
Date: Fri, 25 Jan 2013 02:21:06 +0100 [thread overview]
Message-ID: <CAHXqBF+uHoGRXP3HdiL2Zm9RUhT-+7RsrRhAYZyEg-FjzH2-eQ@mail.gmail.com> (raw)
In-Reply-To: <1359065787-1763-1-git-send-email-pshelar@nicira.com>
2013/1/24 Pravin B Shelar <pshelar@nicira.com>:
[...]
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -798,6 +798,19 @@ static inline int skb_cloned(const struct sk_buff *skb)
> }
>
> /**
> + * skb_unclone - creates separate copy if skb is cloned.
> + */
> +static inline bool skb_unclone(struct sk_buff *skb, gfp_t pri)
> +{
> + might_sleep_if(pri & __GFP_WAIT);
> +
> + if (skb_cloned(skb))
> + return pskb_expand_head(skb, 0, 0, pri);
> +
> + return 0;
> +}
This should return int. pskb_expand_head() returns 0 or -ENOMEM.
[...]
> diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c
> index ddee0a0..c1f00ef 100644
> --- a/net/ipv4/xfrm4_mode_tunnel.c
> +++ b/net/ipv4/xfrm4_mode_tunnel.c
> @@ -142,8 +142,7 @@ static int xfrm4_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
> for_each_input_rcu(rcv_notify_handlers, handler)
> handler->handler(skb);
>
> - if (skb_cloned(skb) &&
> - (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC)))
> + if (skb_unclone(skb, GFP_ATOMIC))
> goto out;
And here return -ENOMEM is replaced with return -EINVAL because of this.
Best Regards,
Michał Mirosław
next prev parent reply other threads:[~2013-01-25 1:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-24 22:16 [PATCH 1/2] net: Add skb_unclone() helper function Pravin B Shelar
2013-01-25 1:13 ` Eric Dumazet
2013-01-25 1:21 ` Michał Mirosław [this message]
2013-01-25 1:36 ` Pravin Shelar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAHXqBF+uHoGRXP3HdiL2Zm9RUhT-+7RsrRhAYZyEg-FjzH2-eQ@mail.gmail.com \
--to=mirqus@gmail.com \
--cc=eric.dumazet@gmail.com \
--cc=jesse@nicira.com \
--cc=netdev@vger.kernel.org \
--cc=pshelar@nicira.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).