Commit fda55eca authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net: introduce skb_transport_header_was_set()

We have skb_mac_header_was_set() helper to tell if mac_header
was set on a skb. We would like the same for transport_header.

__netif_receive_skb() doesn't reset the transport header if already
set by GRO layer.

Note that network stacks usually reset the transport header anyway,
after pulling the network header, so this change only allows
a followup patch to have more precise qdisc pkt_len computation
for GSO packets at ingress side.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0edb7ede
...@@ -1492,6 +1492,11 @@ static inline void skb_set_inner_network_header(struct sk_buff *skb, ...@@ -1492,6 +1492,11 @@ static inline void skb_set_inner_network_header(struct sk_buff *skb,
skb->inner_network_header += offset; skb->inner_network_header += offset;
} }
static inline bool skb_transport_header_was_set(const struct sk_buff *skb)
{
return skb->transport_header != ~0U;
}
static inline unsigned char *skb_transport_header(const struct sk_buff *skb) static inline unsigned char *skb_transport_header(const struct sk_buff *skb)
{ {
return skb->head + skb->transport_header; return skb->head + skb->transport_header;
...@@ -1580,6 +1585,11 @@ static inline void skb_set_inner_network_header(struct sk_buff *skb, ...@@ -1580,6 +1585,11 @@ static inline void skb_set_inner_network_header(struct sk_buff *skb,
skb->inner_network_header = skb->data + offset; skb->inner_network_header = skb->data + offset;
} }
static inline bool skb_transport_header_was_set(const struct sk_buff *skb)
{
return skb->transport_header != NULL;
}
static inline unsigned char *skb_transport_header(const struct sk_buff *skb) static inline unsigned char *skb_transport_header(const struct sk_buff *skb)
{ {
return skb->transport_header; return skb->transport_header;
......
...@@ -3352,6 +3352,7 @@ static int __netif_receive_skb(struct sk_buff *skb) ...@@ -3352,6 +3352,7 @@ static int __netif_receive_skb(struct sk_buff *skb)
orig_dev = skb->dev; orig_dev = skb->dev;
skb_reset_network_header(skb); skb_reset_network_header(skb);
if (!skb_transport_header_was_set(skb))
skb_reset_transport_header(skb); skb_reset_transport_header(skb);
skb_reset_mac_len(skb); skb_reset_mac_len(skb);
......
...@@ -260,6 +260,7 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask, ...@@ -260,6 +260,7 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
skb->end = skb->tail + size; skb->end = skb->tail + size;
#ifdef NET_SKBUFF_DATA_USES_OFFSET #ifdef NET_SKBUFF_DATA_USES_OFFSET
skb->mac_header = ~0U; skb->mac_header = ~0U;
skb->transport_header = ~0U;
#endif #endif
/* make sure we initialize shinfo sequentially */ /* make sure we initialize shinfo sequentially */
...@@ -328,6 +329,7 @@ struct sk_buff *build_skb(void *data, unsigned int frag_size) ...@@ -328,6 +329,7 @@ struct sk_buff *build_skb(void *data, unsigned int frag_size)
skb->end = skb->tail + size; skb->end = skb->tail + size;
#ifdef NET_SKBUFF_DATA_USES_OFFSET #ifdef NET_SKBUFF_DATA_USES_OFFSET
skb->mac_header = ~0U; skb->mac_header = ~0U;
skb->transport_header = ~0U;
#endif #endif
/* make sure we initialize shinfo sequentially */ /* make sure we initialize shinfo sequentially */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment