Skip to content

Commit fda55ec

Browse files
Eric Dumazetdavem330
authored andcommitted
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: Eric Dumazet <[email protected]> Cc: Jamal Hadi Salim <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0edb7ed commit fda55ec

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

include/linux/skbuff.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,11 @@ static inline void skb_set_inner_network_header(struct sk_buff *skb,
14921492
skb->inner_network_header += offset;
14931493
}
14941494

1495+
static inline bool skb_transport_header_was_set(const struct sk_buff *skb)
1496+
{
1497+
return skb->transport_header != ~0U;
1498+
}
1499+
14951500
static inline unsigned char *skb_transport_header(const struct sk_buff *skb)
14961501
{
14971502
return skb->head + skb->transport_header;
@@ -1580,6 +1585,11 @@ static inline void skb_set_inner_network_header(struct sk_buff *skb,
15801585
skb->inner_network_header = skb->data + offset;
15811586
}
15821587

1588+
static inline bool skb_transport_header_was_set(const struct sk_buff *skb)
1589+
{
1590+
return skb->transport_header != NULL;
1591+
}
1592+
15831593
static inline unsigned char *skb_transport_header(const struct sk_buff *skb)
15841594
{
15851595
return skb->transport_header;

net/core/dev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3352,7 +3352,8 @@ static int __netif_receive_skb(struct sk_buff *skb)
33523352
orig_dev = skb->dev;
33533353

33543354
skb_reset_network_header(skb);
3355-
skb_reset_transport_header(skb);
3355+
if (!skb_transport_header_was_set(skb))
3356+
skb_reset_transport_header(skb);
33563357
skb_reset_mac_len(skb);
33573358

33583359
pt_prev = NULL;

net/core/skbuff.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
260260
skb->end = skb->tail + size;
261261
#ifdef NET_SKBUFF_DATA_USES_OFFSET
262262
skb->mac_header = ~0U;
263+
skb->transport_header = ~0U;
263264
#endif
264265

265266
/* make sure we initialize shinfo sequentially */
@@ -328,6 +329,7 @@ struct sk_buff *build_skb(void *data, unsigned int frag_size)
328329
skb->end = skb->tail + size;
329330
#ifdef NET_SKBUFF_DATA_USES_OFFSET
330331
skb->mac_header = ~0U;
332+
skb->transport_header = ~0U;
331333
#endif
332334

333335
/* make sure we initialize shinfo sequentially */

0 commit comments

Comments
 (0)