Return-path: Received: from webmail.solarflare.com ([12.187.104.25]:8513 "EHLO webmail.solarflare.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758569Ab3FMQxT (ORCPT ); Thu, 13 Jun 2013 12:53:19 -0400 Message-ID: <1371142391.2246.4.camel@bwh-desktop.uk.level5networks.com> (sfid-20130613_185340_098056_5F570C58) Subject: Re: [PATCH 3/3] skbuff: Added new helper function skb_cow_clone_head. From: Ben Hutchings To: Dave Wiltshire CC: , , , , , , , , , , , , , , , , , , , , Date: Thu, 13 Jun 2013 17:53:11 +0100 In-Reply-To: <1371040811-8319-2-git-send-email-david.wiltshire@gmx.com> References: <1371030906-2396-1-git-send-email-david.wiltshire@gmx.com> <1371040811-8319-1-git-send-email-david.wiltshire@gmx.com> <1371040811-8319-2-git-send-email-david.wiltshire@gmx.com> Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org List-ID: On Wed, 2013-06-12 at 22:40 +1000, Dave Wiltshire wrote: > In a few different drivers there is a check of (skb_cloned && > !skb_clone_writable) before then using pskb_expand_head to copy the skb > if that is required. There are already some skb_cow_* functions for > other conditions, so added this one and changed the call sites. > > Signed-off-by: Dave Wiltshire > --- > include/linux/skbuff.h | 14 ++++++++++++++ > net/core/dev.c | 8 ++------ > net/openvswitch/actions.c | 22 +++++++--------------- > net/sched/act_csum.c | 8 ++------ > net/sched/act_nat.c | 18 +++++------------- > 5 files changed, 30 insertions(+), 40 deletions(-) > > diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h > index a7393ad..7d18541 100644 > --- a/include/linux/skbuff.h > +++ b/include/linux/skbuff.h > @@ -2154,6 +2154,20 @@ static inline int skb_cow_head(struct sk_buff *skb, unsigned int headroom) > } > > /** > + * skb_cow_clone_head This is a missing a short description after the name. Ben. > + * @skb: buffer to cow > + * @len: length up to which to write > + * > + * This function is identical to skb_cow and sb_cow_head except that we > + * replace the skb_cloned check by skb_cloned && !skb_clone_writable. > + * > + */ > +static inline int skb_cow_clone_head(struct sk_buff *skb, unsigned int len) > +{ > + return __skb_cow(skb, 0, skb_cloned(skb) && !skb_clone_writable(skb, len)); > +} [...] -- Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.