From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cong Wang Subject: [Patch net-next 1/2] net: introduce skb_network_header_was_set() Date: Tue, 20 Nov 2018 18:13:08 -0800 Message-ID: <20181121021309.6595-1-xiyou.wangcong@gmail.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Cc: Cong Wang To: netdev@vger.kernel.org Return-path: Received: from mail-pl1-f169.google.com ([209.85.214.169]:43807 "EHLO mail-pl1-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725913AbeKUMpp (ORCPT ); Wed, 21 Nov 2018 07:45:45 -0500 Received: by mail-pl1-f169.google.com with SMTP id gn14so3096552plb.10 for ; Tue, 20 Nov 2018 18:13:29 -0800 (PST) Sender: netdev-owner@vger.kernel.org List-ID: Signed-off-by: Cong Wang --- include/linux/skbuff.h | 5 +++++ net/core/skbuff.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index a2e8297a5b00..afddb5c17ce5 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -2444,6 +2444,11 @@ static inline u32 skb_network_header_len(const struct sk_buff *skb) return skb->transport_header - skb->network_header; } +static inline int skb_network_header_was_set(const struct sk_buff *skb) +{ + return skb->network_header != (typeof(skb->network_header))~0U; +} + static inline u32 skb_inner_network_header_len(const struct sk_buff *skb) { return skb->inner_transport_header - skb->inner_network_header; diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 9a8a72cefe9b..b6ba923e7dc7 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -227,6 +227,7 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask, skb_reset_tail_pointer(skb); skb->end = skb->tail + size; skb->mac_header = (typeof(skb->mac_header))~0U; + skb->network_header = (typeof(skb->network_header))~0U; skb->transport_header = (typeof(skb->transport_header))~0U; /* make sure we initialize shinfo sequentially */ @@ -292,6 +293,7 @@ struct sk_buff *__build_skb(void *data, unsigned int frag_size) skb_reset_tail_pointer(skb); skb->end = skb->tail + size; skb->mac_header = (typeof(skb->mac_header))~0U; + skb->network_header = (typeof(skb->network_header))~0U; skb->transport_header = (typeof(skb->transport_header))~0U; /* make sure we initialize shinfo sequentially */ -- 2.19.1