Signed-off-by: Cong Wang <xiyou.wangc...@gmail.com> --- 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