Skip to content

Commit

Permalink
net: gro: use cb instead of skb->network_header
Browse files Browse the repository at this point in the history
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@gmail.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://lore.kernel.org/r/20240509190819.2985-2-richardbgobert@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Richard Gobert authored and Jakub Kicinski committed May 13, 2024
1 parent 9af9b89 commit 186b1ea
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
9 changes: 7 additions & 2 deletions include/net/gro.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,17 @@ static inline void *skb_gro_header(struct sk_buff *skb, unsigned int hlen,
return ptr;
}

static inline int skb_gro_receive_network_offset(const struct sk_buff *skb)
{
return NAPI_GRO_CB(skb)->network_offsets[NAPI_GRO_CB(skb)->encap_mark];
}

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_receive_network_offset(skb));

return skb_network_header(skb);
return skb->data + skb_gro_receive_network_offset(skb);
}

static inline __wsum inet_gro_compute_pseudo(const struct sk_buff *skb,
Expand Down
4 changes: 0 additions & 4 deletions net/ipv4/af_inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1569,10 +1569,6 @@ struct sk_buff *inet_gro_receive(struct list_head *head, struct sk_buff *skb)

NAPI_GRO_CB(skb)->is_atomic = !!(iph->frag_off & htons(IP_DF));
NAPI_GRO_CB(skb)->flush |= flush;
skb_set_network_header(skb, off);
/* The above will be needed by the transport layer if there is one
* immediately following this IP hdr.
*/
NAPI_GRO_CB(skb)->inner_network_offset = off;

/* Note : No need to call skb_gro_postpull_rcsum() here,
Expand Down
3 changes: 2 additions & 1 deletion net/ipv4/tcp_offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,8 @@ struct sk_buff *tcp4_gro_receive(struct list_head *head, struct sk_buff *skb)

INDIRECT_CALLABLE_SCOPE int tcp4_gro_complete(struct sk_buff *skb, int thoff)
{
const struct iphdr *iph = ip_hdr(skb);
const u16 offset = NAPI_GRO_CB(skb)->network_offsets[skb->encapsulation];
const struct iphdr *iph = (struct iphdr *)(skb->data + offset);
struct tcphdr *th = tcp_hdr(skb);

if (unlikely(NAPI_GRO_CB(skb)->is_flist)) {
Expand Down
5 changes: 2 additions & 3 deletions net/ipv6/ip6_offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static int ipv6_gro_pull_exthdrs(struct sk_buff *skb, int off, int proto)
off += len;
}

skb_gro_pull(skb, off - skb_network_offset(skb));
skb_gro_pull(skb, off - skb_gro_receive_network_offset(skb));
return proto;
}

Expand Down Expand Up @@ -236,7 +236,6 @@ INDIRECT_CALLABLE_SCOPE struct sk_buff *ipv6_gro_receive(struct list_head *head,
if (unlikely(!iph))
goto out;

skb_set_network_header(skb, off);
NAPI_GRO_CB(skb)->inner_network_offset = off;

flush += ntohs(iph->payload_len) != skb->len - hlen;
Expand All @@ -260,7 +259,7 @@ INDIRECT_CALLABLE_SCOPE struct sk_buff *ipv6_gro_receive(struct list_head *head,
NAPI_GRO_CB(skb)->proto = proto;

flush--;
nlen = skb_network_header_len(skb);
nlen = skb_gro_offset(skb) - off;

list_for_each_entry(p, head, list) {
const struct ipv6hdr *iph2;
Expand Down
3 changes: 2 additions & 1 deletion net/ipv6/tcpv6_offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ struct sk_buff *tcp6_gro_receive(struct list_head *head, struct sk_buff *skb)

INDIRECT_CALLABLE_SCOPE int tcp6_gro_complete(struct sk_buff *skb, int thoff)
{
const struct ipv6hdr *iph = ipv6_hdr(skb);
const u16 offset = NAPI_GRO_CB(skb)->network_offsets[skb->encapsulation];
const struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + offset);
struct tcphdr *th = tcp_hdr(skb);

if (unlikely(NAPI_GRO_CB(skb)->is_flist)) {
Expand Down

0 comments on commit 186b1ea

Please sign in to comment.