[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160422232750.GB1594@localhost.localdomain>
Date: Fri, 22 Apr 2016 20:27:50 -0300
From: marcelo.leitner@...il.com
To: Sowmini Varadhan <sowmini.varadhan@...cle.com>
Cc: netdev@...r.kernel.org, rds-devel@....oracle.com,
santosh.shilimkar@...cle.com, davem@...emloft.net,
eric.dumazet@...il.com
Subject: Re: [PATCH net-next 1/2] skbuff: Add pskb_extract() helper function
On Wed, Apr 20, 2016 at 03:17:41AM -0700, Sowmini Varadhan wrote:
...
> +/* Extract to_copy bytes starting at off from skb, and return this in
> + * a new skb
> + */
> +struct sk_buff *pskb_extract(struct sk_buff *skb, int off,
> + int to_copy, gfp_t gfp)
> +{
> + struct sk_buff *clone = skb_clone(skb, gfp);
> +
> + if (!clone)
> + return NULL;
> +
> + if (pskb_carve(clone, off, gfp) < 0) {
> + pr_warn("pskb_carve failed\n");
You most likely don't want these pr_warn
> + kfree_skb(clone);
> + return NULL;
> + }
> +
> + if (pskb_trim(clone, to_copy)) {
> + pr_warn("pskb_trim failed\n");
> + kfree_skb(clone);
> + return NULL;
> + }
> + return clone;
Then these two blocks can be just:
if (pskb_carve(clone, off, gfp) < 0 ||
pskb_trim(clone, to_copy)) {
kfree_skb(clone);
clone = NULL;
}
return clone;
Marcelo
> +}
> +EXPORT_SYMBOL(pskb_extract);
> --
> 1.7.1
>
Powered by blists - more mailing lists