Patchwork [net-next,1/4] net: Add skb_headers_offset_update helper function.

login
register
mail settings
Submitter Pravin B Shelar
Date March 7, 2013, 11:21 p.m.
Message ID <1362698500-2411-1-git-send-email-pshelar@nicira.com>
Download mbox | patch
Permalink /patch/225996/
State Accepted
Delegated to: David Miller
Headers show

Comments

Pravin B Shelar - March 7, 2013, 11:21 p.m.
This function will be used in next VXLAN_GSO patch. This patch does
not change any functionality.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
---
 net/core/skbuff.c |   34 ++++++++++++++--------------------
 1 files changed, 14 insertions(+), 20 deletions(-)
stephen hemminger - March 8, 2013, 5:40 a.m.
On Thu,  7 Mar 2013 15:21:40 -0800
Pravin B Shelar <pshelar@nicira.com> wrote:

> +static void skb_headers_offset_update(struct sk_buff *skb, int off)
> +{
> +	/* {transport,network,mac}_header and tail are relative to skb->head */
> +	skb->transport_header += off;
> +	skb->network_header   += off;
> +	if (skb_mac_header_was_set(skb))
> +		skb->mac_header += off;
> +	skb->inner_transport_header += off;
> +	skb->inner_network_header += off;
> +}
> +

Won't this cause an unused function warning if NET_SKBUFF_DATA_USES_OFFSET is defined?
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pravin B Shelar - March 8, 2013, 7:23 a.m.
On Thu, Mar 7, 2013 at 9:40 PM, Stephen Hemminger
<stephen@networkplumber.org> wrote:
> On Thu,  7 Mar 2013 15:21:40 -0800
> Pravin B Shelar <pshelar@nicira.com> wrote:
>
>> +static void skb_headers_offset_update(struct sk_buff *skb, int off)
>> +{
>> +     /* {transport,network,mac}_header and tail are relative to skb->head */
>> +     skb->transport_header += off;
>> +     skb->network_header   += off;
>> +     if (skb_mac_header_was_set(skb))
>> +             skb->mac_header += off;
>> +     skb->inner_transport_header += off;
>> +     skb->inner_network_header += off;
>> +}
>> +
>
> Won't this cause an unused function warning if NET_SKBUFF_DATA_USES_OFFSET is defined?

This function is used in both cases, so it should be ok.

Thanks,
Pravin.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 33245ef..b3e8db8 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -867,6 +867,17 @@  struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t gfp_mask)
 }
 EXPORT_SYMBOL(skb_clone);
 
+static void skb_headers_offset_update(struct sk_buff *skb, int off)
+{
+	/* {transport,network,mac}_header and tail are relative to skb->head */
+	skb->transport_header += off;
+	skb->network_header   += off;
+	if (skb_mac_header_was_set(skb))
+		skb->mac_header += off;
+	skb->inner_transport_header += off;
+	skb->inner_network_header += off;
+}
+
 static void copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
 {
 #ifndef NET_SKBUFF_DATA_USES_OFFSET
@@ -879,13 +890,7 @@  static void copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
 	__copy_skb_header(new, old);
 
 #ifndef NET_SKBUFF_DATA_USES_OFFSET
-	/* {transport,network,mac}_header are relative to skb->head */
-	new->transport_header += offset;
-	new->network_header   += offset;
-	if (skb_mac_header_was_set(new))
-		new->mac_header	      += offset;
-	new->inner_transport_header += offset;
-	new->inner_network_header   += offset;
+	skb_headers_offset_update(new, offset);
 #endif
 	skb_shinfo(new)->gso_size = skb_shinfo(old)->gso_size;
 	skb_shinfo(new)->gso_segs = skb_shinfo(old)->gso_segs;
@@ -1077,14 +1082,8 @@  int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
 #else
 	skb->end      = skb->head + size;
 #endif
-	/* {transport,network,mac}_header and tail are relative to skb->head */
 	skb->tail	      += off;
-	skb->transport_header += off;
-	skb->network_header   += off;
-	if (skb_mac_header_was_set(skb))
-		skb->mac_header += off;
-	skb->inner_transport_header += off;
-	skb->inner_network_header += off;
+	skb_headers_offset_update(skb, off);
 	/* Only adjust this if it actually is csum_start rather than csum */
 	if (skb->ip_summed == CHECKSUM_PARTIAL)
 		skb->csum_start += nhead;
@@ -1180,12 +1179,7 @@  struct sk_buff *skb_copy_expand(const struct sk_buff *skb,
 	if (n->ip_summed == CHECKSUM_PARTIAL)
 		n->csum_start += off;
 #ifdef NET_SKBUFF_DATA_USES_OFFSET
-	n->transport_header += off;
-	n->network_header   += off;
-	if (skb_mac_header_was_set(skb))
-		n->mac_header += off;
-	n->inner_transport_header += off;
-	n->inner_network_header	   += off;
+	skb_headers_offset_update(n, off);
 #endif
 
 	return n;