net: gro: rename skb_gro_header_hard()
authorEric Dumazet <edumazet@google.com>
Fri, 1 Mar 2024 19:37:37 +0000 (19:37 +0000)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 5 Mar 2024 12:30:11 +0000 (13:30 +0100)
skb_gro_header_hard() is renamed to skb_gro_may_pull() to match
the convention used by common helpers like pskb_may_pull().

This means the condition is inverted:

if (skb_gro_header_hard(skb, hlen))
slow_path();

becomes:

if (!skb_gro_may_pull(skb, hlen))
slow_path();

Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/geneve.c
include/net/gro.h
net/core/gro.c
net/ipv4/fou_core.c
net/ipv4/gre_offload.c
net/ipv4/tcp_offload.c

index 6f3f9b4..e25e0a3 100644 (file)
@@ -508,7 +508,7 @@ static struct sk_buff *geneve_gro_receive(struct sock *sk,
        gh_len = geneve_hlen(gh);
 
        hlen = off_gnv + gh_len;
-       if (skb_gro_header_hard(skb, hlen)) {
+       if (!skb_gro_may_pull(skb, hlen)) {
                gh = skb_gro_header_slow(skb, hlen, off_gnv);
                if (unlikely(!gh))
                        goto out;
index b435f0d..ffc2c96 100644 (file)
@@ -145,9 +145,10 @@ static inline void *skb_gro_header_fast(struct sk_buff *skb,
        return NAPI_GRO_CB(skb)->frag0 + offset;
 }
 
-static inline int skb_gro_header_hard(struct sk_buff *skb, unsigned int hlen)
+static inline bool skb_gro_may_pull(const struct sk_buff *skb,
+                                   unsigned int hlen)
 {
-       return NAPI_GRO_CB(skb)->frag0_len < hlen;
+       return hlen <= NAPI_GRO_CB(skb)->frag0_len;
 }
 
 static inline void skb_gro_frag0_invalidate(struct sk_buff *skb)
@@ -172,7 +173,7 @@ static inline void *skb_gro_header(struct sk_buff *skb,
        void *ptr;
 
        ptr = skb_gro_header_fast(skb, offset);
-       if (skb_gro_header_hard(skb, hlen))
+       if (!skb_gro_may_pull(skb, hlen))
                ptr = skb_gro_header_slow(skb, hlen, offset);
        return ptr;
 }
index 0759277..927ccf6 100644 (file)
@@ -700,7 +700,7 @@ static struct sk_buff *napi_frags_skb(struct napi_struct *napi)
        skb_reset_mac_header(skb);
        skb_gro_reset_offset(skb, hlen);
 
-       if (unlikely(skb_gro_header_hard(skb, hlen))) {
+       if (unlikely(!skb_gro_may_pull(skb, hlen))) {
                eth = skb_gro_header_slow(skb, hlen, 0);
                if (unlikely(!eth)) {
                        net_warn_ratelimited("%s: dropping impossible skb from %s\n",
index 0c41076..a8494f7 100644 (file)
@@ -351,7 +351,7 @@ static struct sk_buff *gue_gro_receive(struct sock *sk,
        optlen = guehdr->hlen << 2;
        len += optlen;
 
-       if (skb_gro_header_hard(skb, len)) {
+       if (!skb_gro_may_pull(skb, len)) {
                guehdr = skb_gro_header_slow(skb, len, off);
                if (unlikely(!guehdr))
                        goto out;
index 311e70b..5028c72 100644 (file)
@@ -174,7 +174,7 @@ static struct sk_buff *gre_gro_receive(struct list_head *head,
                grehlen += GRE_HEADER_SECTION;
 
        hlen = off + grehlen;
-       if (skb_gro_header_hard(skb, hlen)) {
+       if (!skb_gro_may_pull(skb, hlen)) {
                greh = skb_gro_header_slow(skb, hlen, off);
                if (unlikely(!greh))
                        goto out;
index 8311c38..875456e 100644 (file)
@@ -204,7 +204,7 @@ struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb)
                goto out;
 
        hlen = off + thlen;
-       if (skb_gro_header_hard(skb, hlen)) {
+       if (!skb_gro_may_pull(skb, hlen)) {
                th = skb_gro_header_slow(skb, hlen, off);
                if (unlikely(!th))
                        goto out;