From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A4BA27A47C for ; Mon, 22 Sep 2025 08:41:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758530483; cv=none; b=l1kJ+b5gZKtvWBOiTn99ugJBg2koeb3NnqZhq74HVKHrKXmWveAxymygptzWmZMlbqu11fNgdHjI/cM0frjaVaxoc2Iqn4RW35xLqZ13dFM9dqAIiQrdxoPWINwNRI0aYI0HDNXzCWlonb1QlIDaTAlTvscGYOLYw9dWN585D9g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758530483; c=relaxed/simple; bh=5DFBuSdlxaCcOvy2y416jSTiEqL4AHa8+uh89xjhSCs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SrIQeYOPpPKxxhM1ATh2yB4e2ieosKMs6kXEEFl8F+60RnB00ivYc8bj5CBzo2TghK9CenHzezvFo5hc4KoWW2vEEQxb+ZIMYGIbRJWV6c7GLj4vtEkjh1q+ZIvrHhJWpmt87EFQkdsoLXG+LakgfZdbOZUpSUA2kUVsR8D/iqQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TH4Eyr15; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TH4Eyr15" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-45dcfecdc0fso36172455e9.1 for ; Mon, 22 Sep 2025 01:41:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1758530480; x=1759135280; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nwLDNBiVN98UCDyIlQ/l+MZhscT3bhY9tzLzQhwCiT8=; b=TH4Eyr15ly7xG5pCTVxVpUAo1HBR/BHbnNEJeVqZ1Hc0S5181IuTfJYsRWBU8DlLn1 qj38WVIqYbfiLUvn0FwIpe7orUwGN9DYrtHiWi9Df7GBu7ffuHYihBj7r3WMmCzQXcnA 1PEG18FCm1JrBPG7dFJ9mToNGam/sZThllCve3NQTW2btJ+1ZgiqjCgKWmYBxPp9Jxyv ens5znhc1E5kw2R7h14+wxNJM+oGbiqxJLXuVia5WMCrtBys2jfDAQqO3wa400FMnxGz oft/7rNAISjKhqF2QX/gLmCGQDQ5PX9grFlmo89Yl5YH7RrmsPsIjj0nFqJ40JI5LB4N rS3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758530480; x=1759135280; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nwLDNBiVN98UCDyIlQ/l+MZhscT3bhY9tzLzQhwCiT8=; b=VKOxtyekGMaqwCHoCOwcxthjIoq3QeeDywoqLV0X6hmwPxKw8Ea4rEPjyJF3lH1n5B JILC7xIztqMJf/V7S4R6P5wc/gQxfBzJyuZ8pTuQj+UzRAkbMIYNkM40+K5Ol9S04Z/i Cy2Fgf7bn86p0chBWy3iKsuubsdrdCT4DdsY3SnAd8qe8Nq3/+2SjWbV9ttrSAMUiw+1 tJ+d67Xplf56rYR0fX3o16bpVozQhsO7LwEDtbelydWPEy5nkhpesKvHZ28tSSS81Ib+ yK5/7q/8jztQXO0nXAz/aELyQk8Y/a8IlF2MHDvsKbKP5qLyNSw5K5xuDsZdTg845Ptk d9Ww== X-Gm-Message-State: AOJu0YxkEp5A6Br0qxEUfzzN83uiXH9K44QatA54UBKbj5VHx0kCg7X7 cREeqgsa9PUlJ3EZPfwYYGHEu74x9YUo/8oZW4o4+Kf65++F7FWPpl19hVpfEw== X-Gm-Gg: ASbGncttlJvedSjmrdoZAZtkIy1ikoSmOOdg49mzoPRhGUCL7VC0smPlqRar9c/xzus hcnweIEVGeFPvY6PPbXup2t2ecy95Ts3alPBXhMMSQPIV1oMPp80Qu9qRt3w4A9FLlCFhu9NFcY 0pByyEnm9aVe8Iuk3/mGVPfyf8ftedlRbRbWZ41c8YJ/VJ6L/MOedd2Nctrc2Bmae8ikaYgH7aC vkSEWh72p1r/yC+pbi/XFyPSJ9XY9Pc9Xai0RbvwLig5CCApjgmQTQc4w0IIEgFtwGbDGO77ljA IuIookV6O3/XDr/C0o3fZ90OtHHYw9ZE4Bm/8oQIbKFheWKZuhOtKJ/nPDJX5cFxkSWaO6FOkZg 7oCxHIwYYdMe+fB9EDFOAn3c= X-Google-Smtp-Source: AGHT+IHaiGSsCBoFehcEyd4rvxskZuoU5lMZMYuxI8AuJMk7Xjxp08j/sF42lAeZOvktZWRU0AnQTw== X-Received: by 2002:a05:600c:3b05:b0:45f:2cd5:507c with SMTP id 5b1f17b1804b1-467ebda8e6emr110357565e9.36.1758530479585; Mon, 22 Sep 2025 01:41:19 -0700 (PDT) Received: from localhost ([45.10.155.17]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46da6900832sm10404135e9.0.2025.09.22.01.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Sep 2025 01:41:19 -0700 (PDT) From: Richard Gobert To: netdev@vger.kernel.org, pabeni@redhat.com, ecree.xilinx@gmail.com, willemdebruijn.kernel@gmail.com Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, horms@kernel.org, corbet@lwn.net, saeedm@nvidia.com, tariqt@nvidia.com, mbloch@nvidia.com, leon@kernel.org, dsahern@kernel.org, ncardwell@google.com, kuniyu@google.com, shuah@kernel.org, sdf@fomichev.me, aleksander.lobakin@intel.com, florian.fainelli@broadcom.com, alexander.duyck@gmail.com, linux-kernel@vger.kernel.org, linux-net-drivers@amd.com, Richard Gobert , Willem de Bruijn Subject: [PATCH net-next v7 1/5] net: gro: remove is_ipv6 from napi_gro_cb Date: Mon, 22 Sep 2025 10:40:59 +0200 Message-Id: <20250922084103.4764-2-richardbgobert@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250922084103.4764-1-richardbgobert@gmail.com> References: <20250922084103.4764-1-richardbgobert@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Willem de Bruijn --- include/net/gro.h | 3 --- net/ipv4/fou_core.c | 32 ++++++++++++++------------------ net/ipv4/udp_offload.c | 2 -- net/ipv6/udp_offload.c | 2 -- 4 files changed, 14 insertions(+), 25 deletions(-) diff --git a/include/net/gro.h b/include/net/gro.h index a0fca7ac6e7e..87c68007f949 100644 --- a/include/net/gro.h +++ b/include/net/gro.h @@ -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; diff --git a/net/ipv4/fou_core.c b/net/ipv4/fou_core.c index 3e30745e2c09..3970b6b7ace5 100644 --- a/net/ipv4/fou_core.c +++ b/net/ipv4/fou_core.c @@ -228,21 +228,27 @@ static int gue_udp_recv(struct sock *sk, struct sk_buff *skb) 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 @@ static struct sk_buff *fou_gro_receive(struct sock *sk, 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 @@ static struct sk_buff *gue_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, proto); if (!ops || !ops->callbacks.gro_receive) goto out; @@ -467,7 +465,6 @@ static struct sk_buff *gue_gro_receive(struct sock *sk, 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; diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c index b1f3fd302e9d..19d0b5b09ffa 100644 --- a/net/ipv4/udp_offload.c +++ b/net/ipv4/udp_offload.c @@ -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); diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c index d8445ac1b2e4..046f13b1d77a 100644 --- a/net/ipv6/udp_offload.c +++ b/net/ipv6/udp_offload.c @@ -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); -- 2.36.1