]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: gro: remove is_ipv6 from napi_gro_cb
authorRichard Gobert <richardbgobert@gmail.com>
Tue, 23 Sep 2025 08:59:04 +0000 (10:59 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 25 Sep 2025 10:42:49 +0000 (12:42 +0200)
Remove is_ipv6 from napi_gro_cb and use sk->sk_family instead.
This frees up space for another ip_fixedid bit that will be added
in the next commit.

udp_sock_create always creates either a AF_INET or a AF_INET6 socket,
so using sk->sk_family is reliable. In IPv6-FOU, cfg->ipv6_v6only is
always enabled.

Signed-off-by: Richard Gobert <richardbgobert@gmail.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20250923085908.4687-2-richardbgobert@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
include/net/gro.h
net/ipv4/fou_core.c
net/ipv4/udp_offload.c
net/ipv6/udp_offload.c

index a0fca7ac6e7e74bbc629b9aa8826efaa665d2192..87c68007f94978013769afcca1ef1952fb721d68 100644 (file)
@@ -71,9 +71,6 @@ struct napi_gro_cb {
                /* Free the skb? */
                u8      free:2;
 
-               /* Used in foo-over-udp, set in udp[46]_gro_receive */
-               u8      is_ipv6:1;
-
                /* Used in GRE, set in fou/gue_gro_receive */
                u8      is_fou:1;
 
index 3e30745e2c09aca866239f77d068ff78f0334309..3970b6b7ace537c9abc49248ed7e2bfb245d6df8 100644 (file)
@@ -228,21 +228,27 @@ drop:
        return 0;
 }
 
+static const struct net_offload *fou_gro_ops(const struct sock *sk,
+                                            int proto)
+{
+       const struct net_offload __rcu **offloads;
+
+       /* FOU doesn't allow IPv4 on IPv6 sockets. */
+       offloads = sk->sk_family == AF_INET6 ? inet6_offloads : inet_offloads;
+       return rcu_dereference(offloads[proto]);
+}
+
 static struct sk_buff *fou_gro_receive(struct sock *sk,
                                       struct list_head *head,
                                       struct sk_buff *skb)
 {
-       const struct net_offload __rcu **offloads;
        struct fou *fou = fou_from_sock(sk);
        const struct net_offload *ops;
        struct sk_buff *pp = NULL;
-       u8 proto;
 
        if (!fou)
                goto out;
 
-       proto = fou->protocol;
-
        /* We can clear the encap_mark for FOU as we are essentially doing
         * one of two possible things.  We are either adding an L4 tunnel
         * header to the outer L3 tunnel header, or we are simply
@@ -254,8 +260,7 @@ static struct sk_buff *fou_gro_receive(struct sock *sk,
        /* Flag this frame as already having an outer encap header */
        NAPI_GRO_CB(skb)->is_fou = 1;
 
-       offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
-       ops = rcu_dereference(offloads[proto]);
+       ops = fou_gro_ops(sk, fou->protocol);
        if (!ops || !ops->callbacks.gro_receive)
                goto out;
 
@@ -268,10 +273,8 @@ out:
 static int fou_gro_complete(struct sock *sk, struct sk_buff *skb,
                            int nhoff)
 {
-       const struct net_offload __rcu **offloads;
        struct fou *fou = fou_from_sock(sk);
        const struct net_offload *ops;
-       u8 proto;
        int err;
 
        if (!fou) {
@@ -279,10 +282,7 @@ static int fou_gro_complete(struct sock *sk, struct sk_buff *skb,
                goto out;
        }
 
-       proto = fou->protocol;
-
-       offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
-       ops = rcu_dereference(offloads[proto]);
+       ops = fou_gro_ops(sk, fou->protocol);
        if (WARN_ON(!ops || !ops->callbacks.gro_complete)) {
                err = -ENOSYS;
                goto out;
@@ -323,7 +323,6 @@ static struct sk_buff *gue_gro_receive(struct sock *sk,
                                       struct list_head *head,
                                       struct sk_buff *skb)
 {
-       const struct net_offload __rcu **offloads;
        const struct net_offload *ops;
        struct sk_buff *pp = NULL;
        struct sk_buff *p;
@@ -450,8 +449,7 @@ next_proto:
        /* Flag this frame as already having an outer encap header */
        NAPI_GRO_CB(skb)->is_fou = 1;
 
-       offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
-       ops = rcu_dereference(offloads[proto]);
+       ops = fou_gro_ops(sk, proto);
        if (!ops || !ops->callbacks.gro_receive)
                goto out;
 
@@ -467,7 +465,6 @@ out:
 static int gue_gro_complete(struct sock *sk, struct sk_buff *skb, int nhoff)
 {
        struct guehdr *guehdr = (struct guehdr *)(skb->data + nhoff);
-       const struct net_offload __rcu **offloads;
        const struct net_offload *ops;
        unsigned int guehlen = 0;
        u8 proto;
@@ -494,8 +491,7 @@ static int gue_gro_complete(struct sock *sk, struct sk_buff *skb, int nhoff)
                return err;
        }
 
-       offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
-       ops = rcu_dereference(offloads[proto]);
+       ops = fou_gro_ops(sk, proto);
        if (WARN_ON(!ops || !ops->callbacks.gro_complete))
                goto out;
 
index b1f3fd302e9d4b290631917ccbadc5688b5f51cb..19d0b5b09ffae6bc0cda0b67fc229fa01dc37e8e 100644 (file)
@@ -891,8 +891,6 @@ struct sk_buff *udp4_gro_receive(struct list_head *head, struct sk_buff *skb)
                skb_gro_checksum_try_convert(skb, IPPROTO_UDP,
                                             inet_gro_compute_pseudo);
 skip:
-       NAPI_GRO_CB(skb)->is_ipv6 = 0;
-
        if (static_branch_unlikely(&udp_encap_needed_key))
                sk = udp4_gro_lookup_skb(skb, uh->source, uh->dest);
 
index d8445ac1b2e43d0aa993e5704170117356da86b8..046f13b1d77a19b9ec4e0a07f531081d174defb1 100644 (file)
@@ -154,8 +154,6 @@ struct sk_buff *udp6_gro_receive(struct list_head *head, struct sk_buff *skb)
                                             ip6_gro_compute_pseudo);
 
 skip:
-       NAPI_GRO_CB(skb)->is_ipv6 = 1;
-
        if (static_branch_unlikely(&udpv6_encap_needed_key))
                sk = udp6_gro_lookup_skb(skb, uh->source, uh->dest);