netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Patch net-next] net: clean up skb headers code
@ 2013-05-29  6:09 Cong Wang
  2013-05-29  6:36 ` David Miller
  0 siblings, 1 reply; 19+ messages in thread
From: Cong Wang @ 2013-05-29  6:09 UTC (permalink / raw)
  To: netdev; +Cc: Cong Wang, David S. Miller, Simon Horman

commit 1a37e412a0225fcba5587 (net: Use 16bits for *_headers
fields of struct skbuff) converts skb->*_header to u16,
therefore 1) we could just use 0xFFFFF instead of (__u16) ~0U
2) some #if NET_SKBUFF_DATA_USES_OFFSET is useless now.


Cc: David S. Miller <davem@davemloft.net>
Cc: Simon Horman <horms@verge.net.au>
Signed-off-by: Cong Wang <amwang@redhat.com>

---
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 8f2b830..3c896b7 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1584,7 +1584,7 @@ static inline void skb_set_inner_mac_header(struct sk_buff *skb,
 }
 static inline bool skb_transport_header_was_set(const struct sk_buff *skb)
 {
-	return skb->transport_header != ~0U;
+	return skb->transport_header != 0xFFFF;
 }
 
 static inline unsigned char *skb_transport_header(const struct sk_buff *skb)
@@ -1627,7 +1627,7 @@ static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
 
 static inline int skb_mac_header_was_set(const struct sk_buff *skb)
 {
-	return skb->mac_header != ~0U;
+	return skb->mac_header != 0xFFFF;
 }
 
 static inline void skb_reset_mac_header(struct sk_buff *skb)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index f45de07..0c3742f 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -199,9 +199,7 @@ struct sk_buff *__alloc_skb_head(gfp_t gfp_mask, int node)
 	skb->truesize = sizeof(struct sk_buff);
 	atomic_set(&skb->users, 1);
 
-#ifdef NET_SKBUFF_DATA_USES_OFFSET
-	skb->mac_header = (__u16) ~0U;
-#endif
+	skb->mac_header = 0xFFFF;
 out:
 	return skb;
 }
@@ -275,10 +273,8 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
 	skb->data = data;
 	skb_reset_tail_pointer(skb);
 	skb->end = skb->tail + size;
-#ifdef NET_SKBUFF_DATA_USES_OFFSET
-	skb->mac_header = (__u16) ~0U;
-	skb->transport_header = (__u16) ~0U;
-#endif
+	skb->mac_header = 0xFFFF;
+	skb->transport_header = 0xFFFF;
 
 	/* make sure we initialize shinfo sequentially */
 	shinfo = skb_shinfo(skb);
@@ -344,10 +340,8 @@ struct sk_buff *build_skb(void *data, unsigned int frag_size)
 	skb->data = data;
 	skb_reset_tail_pointer(skb);
 	skb->end = skb->tail + size;
-#ifdef NET_SKBUFF_DATA_USES_OFFSET
-	skb->mac_header = (__u16) ~0U;
-	skb->transport_header = (__u16) ~0U;
-#endif
+	skb->mac_header = 0xFFFF;
+	skb->transport_header = 0xFFFF;
 
 	/* make sure we initialize shinfo sequentially */
 	shinfo = skb_shinfo(skb);

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2013-05-30 14:11 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-29  6:09 [Patch net-next] net: clean up skb headers code Cong Wang
2013-05-29  6:36 ` David Miller
2013-05-29  6:48   ` Cong Wang
2013-05-29  6:49     ` David Miller
2013-05-29 19:34   ` Ben Hutchings
2013-05-29 19:44     ` Antonio Quartulli
2013-05-29 21:02       ` Ben Hutchings
2013-05-30  8:59         ` Antonio Quartulli
2013-05-30 11:41         ` David Laight
2013-05-30 11:45           ` Antonio Quartulli
2013-05-30 12:12             ` David Laight
2013-05-30 12:22               ` David Laight
2013-05-30 12:24                 ` Antonio Quartulli
2013-05-30 12:40                   ` David Laight
2013-05-30 12:23               ` Antonio Quartulli
2013-05-30  1:59     ` Cong Wang
2013-05-30 12:30       ` Sergei Shtylyov
2013-05-30 10:40     ` David Miller
2013-05-30 14:11       ` Ben Hutchings

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).