Re: [PATCH net-next v8 1/3] net: gro: use cb instead of skb->network_header

From: Willem de Bruijn
Date: Mon May 06 2024 - 12:46:31 EST


Richard Gobert wrote:
> This patch converts references of skb->network_header to napi_gro_cb's
> network_offset and inner_network_offset.
>
> Signed-off-by: Richard Gobert <richardbgobert@xxxxxxxxx>
> ---
> include/net/gro.h | 9 +++++++--
> net/ipv4/af_inet.c | 4 ----
> net/ipv4/tcp_offload.c | 3 ++-
> net/ipv6/ip6_offload.c | 5 ++---
> net/ipv6/tcpv6_offload.c | 3 ++-
> 5 files changed, 13 insertions(+), 11 deletions(-)
>
> diff --git a/include/net/gro.h b/include/net/gro.h
> index c1d4ca0463a1..1faff23b66e8 100644
> --- a/include/net/gro.h
> +++ b/include/net/gro.h
> @@ -181,12 +181,17 @@ static inline void *skb_gro_header(struct sk_buff *skb, unsigned int hlen,
> return ptr;
> }
>
> +static inline int skb_gro_network_offset(const struct sk_buff *skb)
> +{
> + return NAPI_GRO_CB(skb)->network_offsets[NAPI_GRO_CB(skb)->encap_mark];
> +}
> +

The fact that .._receive sets encap_mark, but .._complete must read
encapsulation, due to the clear in udp_gro_complete, is non-obvious.

Can you add a comment to clarify this or rename this to
skb_gro_receive_network_offset?

> static inline void *skb_gro_network_header(const struct sk_buff *skb)
> {
> if (skb_gro_may_pull(skb, skb_gro_offset(skb)))
> - return skb_gro_header_fast(skb, skb_network_offset(skb));
> + return skb_gro_header_fast(skb, skb_gro_network_offset(skb));
>
> - return skb_network_header(skb);
> + return skb->data + skb_gro_network_offset(skb);
> }