From nobody Sat Oct 4 15:57:32 2025 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 16DAF2F39D8; Thu, 14 Aug 2025 11:41:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755171672; cv=none; b=A4Z8SBK7n6nmD96kX/g6VtpqAGyKH+RiRPRRHmQa8/6hB+UA+Xt/BugO5T26ARpyHGwA9rjJcCSYiuUzrPkmieHCPifrjDvBZV8StSJE2gUjpinOt2rojPTjUavqffC56OTqzIJIC4VEPhMonstCdUqitVIuJrFatiM8a8h2ntY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755171672; c=relaxed/simple; bh=jpLU+OKEQKozVDzv5dfNS6gv/Vig04JpdBFrL3kQwgc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WzklJsVpaRnUWHv2FwFKz4M7/+98nYVckcb3+c2eNDL3fJ1rOaZQrgGIct5LzqI0ZoVVHetP5N9ZqK6cf/EV0sBPB38owjFKbEUW45s+/iiQJSSwjZSBn4FsavA5F/vcX75dE6aRTENbBNVzghCksiU+CK0FlSbr+aX42ETllzA= 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=GoaM0Rex; arc=none smtp.client-ip=209.85.221.52 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="GoaM0Rex" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-3b9d41d2a5cso617726f8f.0; Thu, 14 Aug 2025 04:41:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755171669; x=1755776469; 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=8NzhLqmeUuWaJRE/GQ9MgE/+Yn40wjerKmNWNfLVMfU=; b=GoaM0RexA2tRiMHgCpvXLd7SJVgBrJZt9ESoogLKyLscZUk/YbmgSyGS7hO8nUASWy ooZJOP0+DnZs3RHtTL6rY0E4IixZzpuHyznhlhv/x6UFN3sZf5bZdt9s1fNpjThvXO4G ePjdnRKiyyTWxd6cXb2mxKdB5iHqSM4iP16ZeK+H3pQShCCQ20U6O6AxaB8RVkJ6mbsc RED4MWTw4iDv9VgrZeSerDQ5TXgYMybODGLPizwfdBXHT3cLssLziOkpEgUwZ5OpnmN+ Kwll3yq6MJEsV93GfB+NSqwm8SmhqppOZa+9g9+5yI2vsRdK521rMh73fNHxBpO4mOi+ ICPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755171669; x=1755776469; 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=8NzhLqmeUuWaJRE/GQ9MgE/+Yn40wjerKmNWNfLVMfU=; b=QmXWVTUub6WYwF+RtYzjmxFAhM4DdE1Sz1mDWTKh878LfPbp4JL0Vr+7IG3sIL+yFX 5EA2s1lOOvoG0gQILbTWwWrF0DRThzGh7dCUXOdkbgCVuOtASFKk5NdKu2egqP7NagaC VEwBQAlzBqA3FaDL74U5vqRVz+vp3k7jeT6ktlupfeDqMtaovJTHRva6Celi0lL6X9Ta J00/pQ/l4Um3Y1zhdeYi0mwcG5ZI77F06djIghqKSTIVHgJG5seUqsAfLQW5Wc96twSg I/JoA6CAP931+p6UF+gwFqD0cXGaiEtnVjvLGvx3H5lBZtWDFaOjR3ZgmEluhTIJQthW nDXA== X-Forwarded-Encrypted: i=1; AJvYcCUl1Rw2ODgzChGE49/cDvJSEkgTVw5c02GeuGPBrCkm7Q17XHb5cQVg92eFpU75whhG2mbjvaJsWlpOVRo=@vger.kernel.org X-Gm-Message-State: AOJu0Yxzm0AMCHIZ0sImda56MqgsixPEK8KUTgnsIaW9O9UGdsJp95ju dcAn/zRtIoIi6F2+3d4VHPC1+54nH5fzuHu3sEXAmwsD6rcXLEmvPW9x8s8fPDJfrY8= X-Gm-Gg: ASbGnctaotlREs99esUEZdBcnA85XrDvMCfxbT/Pe4rKiMbArq7AW2V1VWLCre/Sjme eptaSuHUmXxHMLXRoprDbkRyMjEF2gCer2uuyhVjWqcLL2GjfRrkOD0fx6d+3YPG8yYqF/hpXri mq8MepuvQuazlYB+g8XGuzhv3Loynz4xCn0i92dKeo8N56YZwbwNztWOyyaYy5i0Fc8vGoU8uxX wR9wt/NLf1TER0ffgdSoI6KdngIPhcyvqNhrvbCSSWKn9HYhHTCnj4K8grdmQJiEWACZAnJFOfa 0yV3N/8/56ofx+Zethnh80S0guLaixaD5TCKN6jNRxNB/WYHff11AwMHRwcRSgsY7oJ5IE1UC7U rkhGMVbQ84duztnXXrdtaPDxVUdmUey8d4Q== X-Google-Smtp-Source: AGHT+IF1F/U90gimi4Mu85AEgSJjQPFSucr76wX1Lk85qADC6JxJ6soSsKJUNasfd1kjjZNaPGxk/A== X-Received: by 2002:a05:6000:2dc8:b0:3b7:88f5:eaae with SMTP id ffacd0b85a97d-3b9edfe2b3amr2272020f8f.39.1755171669005; Thu, 14 Aug 2025 04:41:09 -0700 (PDT) Received: from localhost ([45.10.155.16]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b79c3bf970sm50362372f8f.25.2025.08.14.04.41.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 04:41:08 -0700 (PDT) From: Richard Gobert To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, corbet@lwn.net, shenjian15@huawei.com, salil.mehta@huawei.com, shaojijie@huawei.com, andrew+netdev@lunn.ch, saeedm@nvidia.com, tariqt@nvidia.com, mbloch@nvidia.com, leon@kernel.org, ecree.xilinx@gmail.com, dsahern@kernel.org, ncardwell@google.com, kuniyu@google.com, shuah@kernel.org, sdf@fomichev.me, ahmed.zaki@intel.com, aleksander.lobakin@intel.com, linux-kernel@vger.kernel.org, linux-net-drivers@amd.com, Richard Gobert Subject: [PATCH net-next 1/5] net: gro: remove is_ipv6 from napi_gro_cb Date: Thu, 14 Aug 2025 13:40:26 +0200 Message-Id: <20250814114030.7683-2-richardbgobert@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250814114030.7683-1-richardbgobert@gmail.com> References: <20250814114030.7683-1-richardbgobert@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 AP_INET or a AF_INET6 socket, so using sk->sk_family is reliable. Signed-off-by: Richard Gobert --- include/net/gro.h | 3 --- net/ipv4/fou_core.c | 8 ++++---- net/ipv4/udp_offload.c | 2 -- net/ipv6/udp_offload.c | 2 -- 4 files changed, 4 insertions(+), 11 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; =20 - /* 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; =20 diff --git a/net/ipv4/fou_core.c b/net/ipv4/fou_core.c index 3e30745e2c09..efd3bf6ec3ae 100644 --- a/net/ipv4/fou_core.c +++ b/net/ipv4/fou_core.c @@ -254,7 +254,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 =3D 1; =20 - offloads =3D NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads; + offloads =3D sk->sk_family =3D=3D AF_INET6 ? inet6_offloads : inet_offloa= ds; ops =3D rcu_dereference(offloads[proto]); if (!ops || !ops->callbacks.gro_receive) goto out; @@ -281,7 +281,7 @@ static int fou_gro_complete(struct sock *sk, struct sk_= buff *skb, =20 proto =3D fou->protocol; =20 - offloads =3D NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads; + offloads =3D sk->sk_family =3D=3D AF_INET6 ? inet6_offloads : inet_offloa= ds; ops =3D rcu_dereference(offloads[proto]); if (WARN_ON(!ops || !ops->callbacks.gro_complete)) { err =3D -ENOSYS; @@ -450,7 +450,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 =3D 1; =20 - offloads =3D NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads; + offloads =3D sk->sk_family =3D=3D AF_INET6 ? inet6_offloads : inet_offloa= ds; ops =3D rcu_dereference(offloads[proto]); if (!ops || !ops->callbacks.gro_receive) goto out; @@ -494,7 +494,7 @@ static int gue_gro_complete(struct sock *sk, struct sk_= buff *skb, int nhoff) return err; } =20 - offloads =3D NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads; + offloads =3D sk->sk_family =3D=3D AF_INET6 ? inet6_offloads : inet_offloa= ds; ops =3D rcu_dereference(offloads[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 5128e2a5b00a..683689cf4293 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 =3D 0; - if (static_branch_unlikely(&udp_encap_needed_key)) sk =3D udp4_gro_lookup_skb(skb, uh->source, uh->dest); =20 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); =20 skip: - NAPI_GRO_CB(skb)->is_ipv6 =3D 1; - if (static_branch_unlikely(&udpv6_encap_needed_key)) sk =3D udp6_gro_lookup_skb(skb, uh->source, uh->dest); =20 --=20 2.36.1 From nobody Sat Oct 4 15:57:32 2025 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 62175224AE0; Thu, 14 Aug 2025 11:41:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755171686; cv=none; b=BURBPZ9n5cDHCv9Ib32M2xeSP+TK6iExCCTpUoaD1fe2buzu8Z2UlfIv89QfextKTUbnAKlFCVBvpJqJzNJsBfnk/PZwdf5TmULOYagYlkuKRtk/vifwCTV7JBvumZ6DY5Pv5TkuYxwIpKHfSTO5loWWdmgSKzwggN6ZIhMqPus= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755171686; c=relaxed/simple; bh=kUrenFG87YWzm25TOBbzZcKcuHImxpugKXwDvaYI9w8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=k5kXSUEEZr2RD1nqwvjW1QqR/AZGYZWTpQorynyPSp3+yJXxjOQ21R+F4wA9g0AdaAhpbrrimnOiqy2ycTTLVv3Q6pCvjnM8d4iSCQshGrWKdVgIhDpnsLZK1pKTXcx2Jt1+hEGXEhQOzUZLAdWePG5cC8G1i9cZZfOcqaGvI3Y= 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=QSDQZx0C; arc=none smtp.client-ip=209.85.128.48 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="QSDQZx0C" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-45a1b00f187so3670145e9.0; Thu, 14 Aug 2025 04:41:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755171683; x=1755776483; 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=32/S4IqfOpUydKeSRhvHvpvUd1ekQaBREl//8hnY74M=; b=QSDQZx0CkCygG9PoV9929OKVMUmUrf5ZZTPMOKsf9JQdatKgol1GCjc39i7a+Y4ZMJ nzSmLF5L+Bqw5RAT5oZtuJxbH80AOwR59A6nik3sqEAQqPxCBKjEi9Zq3u4zCyMAWKKp kg1UpsmAOETrbCO95G8ll8euPWpi7iPw0GXTi7HJYW8HGRWiH7qppWu1dT/sYPPzOYGz Ncb2nT3wmKpBncCY1zeJ4lgqGExyzznt5+J4nXiBuCyvRi3f5VghOLmr2ja915HEgD4S p8H9NMJh7EeWKBJ4Pc1C9lI/4z03BNpvuHyekqDgtyd6+tmkvveHfLv6WrxDmrBFxvXZ rNJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755171683; x=1755776483; 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=32/S4IqfOpUydKeSRhvHvpvUd1ekQaBREl//8hnY74M=; b=OL3RimuUm1N9YgatlOBw2x56wBMtrNMt9AMB6juLwm12ZVAVYexJacROJ6XoKPEIFa bbHw9T/Xp9Ha5IbUxPxWhhSI1a0LlXewJ0AOWSRUwO43++r2OOIcbvkFQb3J8eD86lAm HVFXZPPX5to1EDFC4dsgrzr1Sf3hnJghVmHRxxyOCdhiXmeD7zZH+zv+B94ekNdi/LYy pzGyRv6W+8p769CKkpNS9yYKV2RY0cxxnWktag2P/tB33dhe3pQlGFpTdgfm1t2iVG7l 1vTqWkLHjVzTFsilq4xwQJ5zLt+J6PgTiCSkqIfQh0Fm0gAy48K+veLFqmzU1s8Ps/Mv V+wA== X-Forwarded-Encrypted: i=1; AJvYcCUmQXPbAZX0Hh900ZCwcD+mU0tZ7J0pa6t//poq16w1K0vWRBUtXiLr055F4GqBbRbwL2TunedtX7mU8Mk=@vger.kernel.org X-Gm-Message-State: AOJu0Yy7AQBbeU7cUnxTLf9O7vCGx6L4YVt9KSRhXutHFQLlZ9hLS9bs Qx52JNVzYZRo+QrSY+lrbs5liyP/lUwYnQddu/TP/9dOSzv5pEqvyIKzA75Rwate/9g= X-Gm-Gg: ASbGncs7SJCktKwMi15NFkO4jpvKElmsQu/eOjkD7rFc87pTZDlVWtD5aKmDLJbHuzG PgM/jzy/KWcuk7RmBe7dVjC6tURXjHU3yKT8rzowz6i266POgE7Rhp0F/O4AWDCQogkM8h62ho5 PKJK0MvbwjWMzJsoM7yXBurEJ9rKW2r+JfjJGtnMLeDeUdFBmDeXxYIRZ4X4VE0aV0PR66h10RK PuVY276jEGOvFbuLu1e3VLxHYgFm3U0/an0/p36tyeghyFVQR5PPfH51pM56pVoFg3qvI+edFXY 1w6E6byKdAoIo6K8KX/be2LF5jMYbF21YZywqYzGrOLMOxYHbNRbY7+iIC6i24dwl1/gaRCx8MJ mSvybxlQSjK4GV58YrZogtJcK6MMVKjOElw== X-Google-Smtp-Source: AGHT+IEFQCeNBcsu9D4xoWxHw8zO8x4LfIvj6ubvhDpp0OHyHSBnqYgu+14cxY8+0gSIgsGiX44lrw== X-Received: by 2002:a05:600c:35d3:b0:456:1514:5b04 with SMTP id 5b1f17b1804b1-45a1b6554f3mr17936255e9.21.1755171682343; Thu, 14 Aug 2025 04:41:22 -0700 (PDT) Received: from localhost ([45.10.155.16]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b79c4533f1sm51073253f8f.42.2025.08.14.04.41.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 04:41:22 -0700 (PDT) From: Richard Gobert To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, corbet@lwn.net, shenjian15@huawei.com, salil.mehta@huawei.com, shaojijie@huawei.com, andrew+netdev@lunn.ch, saeedm@nvidia.com, tariqt@nvidia.com, mbloch@nvidia.com, leon@kernel.org, ecree.xilinx@gmail.com, dsahern@kernel.org, ncardwell@google.com, kuniyu@google.com, shuah@kernel.org, sdf@fomichev.me, ahmed.zaki@intel.com, aleksander.lobakin@intel.com, linux-kernel@vger.kernel.org, linux-net-drivers@amd.com, Richard Gobert Subject: [PATCH net-next 2/5] net: gro: only merge packets with incrementing or fixed outer ids Date: Thu, 14 Aug 2025 13:40:27 +0200 Message-Id: <20250814114030.7683-3-richardbgobert@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250814114030.7683-1-richardbgobert@gmail.com> References: <20250814114030.7683-1-richardbgobert@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Only merge encapsulated packets if their outer IDs are either incrementing or fixed, just like for inner IDs and IDs of non-encapsulated packets. Add another ip_fixedid bit for a total of two bits: one for outer IDs and one for inner IDs. This commit preserves the current behavior of GSO where only the IDs of the inner-most headers are restored correctly. Signed-off-by: Richard Gobert --- include/net/gro.h | 26 +++++++++++--------------- net/ipv4/tcp_offload.c | 4 +++- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/net/gro.h b/include/net/gro.h index 87c68007f949..e7997a9fb30b 100644 --- a/include/net/gro.h +++ b/include/net/gro.h @@ -75,7 +75,7 @@ struct napi_gro_cb { u8 is_fou:1; =20 /* Used to determine if ipid_offset can be ignored */ - u8 ip_fixedid:1; + u8 ip_fixedid:2; =20 /* Number of gro_receive callbacks this packet already went through */ u8 recursion_counter:4; @@ -442,29 +442,26 @@ static inline __wsum ip6_gro_compute_pseudo(const str= uct sk_buff *skb, } =20 static inline int inet_gro_flush(const struct iphdr *iph, const struct iph= dr *iph2, - struct sk_buff *p, bool outer) + struct sk_buff *p, bool inner) { const u32 id =3D ntohl(*(__be32 *)&iph->id); const u32 id2 =3D ntohl(*(__be32 *)&iph2->id); const u16 ipid_offset =3D (id >> 16) - (id2 >> 16); const u16 count =3D NAPI_GRO_CB(p)->count; const u32 df =3D id & IP_DF; - int flush; =20 /* All fields must match except length and checksum. */ - flush =3D (iph->ttl ^ iph2->ttl) | (iph->tos ^ iph2->tos) | (df ^ (id2 & = IP_DF)); - - if (flush | (outer && df)) - return flush; + if ((iph->ttl ^ iph2->ttl) | (iph->tos ^ iph2->tos) | (df ^ (id2 & IP_DF)= )) + return true; =20 /* When we receive our second frame we can make a decision on if we * continue this flow as an atomic flow with a fixed ID or if we use * an incrementing ID. */ if (count =3D=3D 1 && df && !ipid_offset) - NAPI_GRO_CB(p)->ip_fixedid =3D true; + NAPI_GRO_CB(p)->ip_fixedid |=3D 1 << inner; =20 - return ipid_offset ^ (count * !NAPI_GRO_CB(p)->ip_fixedid); + return ipid_offset ^ (count * !(NAPI_GRO_CB(p)->ip_fixedid & (1 << inner)= )); } =20 static inline int ipv6_gro_flush(const struct ipv6hdr *iph, const struct i= pv6hdr *iph2) @@ -479,7 +476,7 @@ static inline int ipv6_gro_flush(const struct ipv6hdr *= iph, const struct ipv6hdr =20 static inline int __gro_receive_network_flush(const void *th, const void *= th2, struct sk_buff *p, const u16 diff, - bool outer) + bool inner) { const void *nh =3D th - diff; const void *nh2 =3D th2 - diff; @@ -487,19 +484,18 @@ static inline int __gro_receive_network_flush(const v= oid *th, const void *th2, if (((struct iphdr *)nh)->version =3D=3D 6) return ipv6_gro_flush(nh, nh2); else - return inet_gro_flush(nh, nh2, p, outer); + return inet_gro_flush(nh, nh2, p, inner); } =20 static inline int gro_receive_network_flush(const void *th, const void *th= 2, struct sk_buff *p) { - const bool encap_mark =3D NAPI_GRO_CB(p)->encap_mark; int off =3D skb_transport_offset(p); int flush; =20 - flush =3D __gro_receive_network_flush(th, th2, p, off - NAPI_GRO_CB(p)->n= etwork_offset, encap_mark); - if (encap_mark) - flush |=3D __gro_receive_network_flush(th, th2, p, off - NAPI_GRO_CB(p)-= >inner_network_offset, false); + flush =3D __gro_receive_network_flush(th, th2, p, off - NAPI_GRO_CB(p)->n= etwork_offset, false); + if (NAPI_GRO_CB(p)->encap_mark) + flush |=3D __gro_receive_network_flush(th, th2, p, off - NAPI_GRO_CB(p)-= >inner_network_offset, true); =20 return flush; } diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c index be5c2294610e..74f46663eeae 100644 --- a/net/ipv4/tcp_offload.c +++ b/net/ipv4/tcp_offload.c @@ -485,8 +485,10 @@ INDIRECT_CALLABLE_SCOPE int tcp4_gro_complete(struct s= k_buff *skb, int thoff) th->check =3D ~tcp_v4_check(skb->len - thoff, iph->saddr, iph->daddr, 0); =20 + bool is_fixedid =3D (NAPI_GRO_CB(skb)->ip_fixedid >> skb->encapsulation) = & 1; + skb_shinfo(skb)->gso_type |=3D SKB_GSO_TCPV4 | - (NAPI_GRO_CB(skb)->ip_fixedid * SKB_GSO_TCP_FIXEDID); + (is_fixedid * SKB_GSO_TCP_FIXEDID); =20 tcp_gro_complete(skb); return 0; --=20 2.36.1 From nobody Sat Oct 4 15:57:32 2025 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 35EFA2FABE4; Thu, 14 Aug 2025 11:41:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755171693; cv=none; b=RM8/Npz9zkGArb+5dbrZCv3PpfC3Z6bIfDKX2LjoALeOm+ik0ml5mP0EifrO7Uk3BkFJRHAUoOMVR3ugnQhbsRjSm4N/RyJcXzqnhmBgTwrftqC0nycH8YDnR5oCKxQOANHqXAHAYP7AO6OUxYddspfzkcC0hVdD+cVxuZ7eEx0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755171693; c=relaxed/simple; bh=OfLyoH0cg9GZUNRAwURHWhCQ0NMGnYXZtKLKS7BlHK8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ONYIrTKW26jZpmg23HJWD/kUgkyW10L/m681tKZ5MohL5+cCg/EX4H9qlHLGHO10PvBZ0DICEA74gNLalQrfa8zye67wt/0N/hUox84eTcb9m97kTKDbPVkq53aHsDvRsY7aPeK3j0JOWGotnKy0hF6cH+YCUvkXbfwmgcVxb0I= 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=Z4y2tQ3E; arc=none smtp.client-ip=209.85.221.47 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="Z4y2tQ3E" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-3b9edf36838so475121f8f.3; Thu, 14 Aug 2025 04:41:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755171689; x=1755776489; 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=3lA0Q2VNB/j3y3014rbHE36ssQRvnzL/ofA2ZgCqaRk=; b=Z4y2tQ3EyZPaMDGJjGKmKUJX008CbWr/LvoakCqsSjMTE7UoJUnSu6YW9SMwCbmBUx KrRXhPJI5G+7QJU6fXkzyyq7U47qzXJMu+SWu97v7mbD9y3QZzO25eoH2ssGVgi42VZZ l4RkhpkgC8TKLWR36Wi3so8hQmiGFg+DIoEaaCkgGhLoN6b37DdIj9lN6f5V2tJefCF7 5s4XQCjNs6Qj3chGKpQJsiojXVxhwwQcauwgESZKXpjI3ATeL6Io6ys6UmvhAw1YfMb7 mcUFkuyzsLBXUi/ztJ8/okvheV9qWHzu4QWSVxImyztb9YcgmwafauvD6p13ittZuuaw u9gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755171689; x=1755776489; 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=3lA0Q2VNB/j3y3014rbHE36ssQRvnzL/ofA2ZgCqaRk=; b=bPS9FBwlTJ28odKmJCENKWfumfhMZN2wx86b5bviYaTp6vCzmma/QtyixUuOdwCsqx XvZSVK09IktvjJwgt1dNX9mpYzyd9uXiKbIrHHwQfddd74/SXBuWHZvwSHwOztN4ORfE 8Vrhd424TbLCU4v5g5/LpWWUtklKGwsoAHvrb8ePXivN32e8MNeWi0OiBXWyQN413K7J olW9hlVrjH4TrKQJtB33TOvOI/ZntUeS/TUSTK1qnCHY6yBvYQxMOCvXHEEPpUQUeh8a 6y3RfIMg8dZQCBFDBfxzYi1g/kA2wNPj+YOl27BHyx1ooU8vJEeVcHAkHCyuC7Zlpz25 i+Bw== X-Forwarded-Encrypted: i=1; AJvYcCUnd5OziDSG/EsRQAP6R0YLe3XLRzfU9TxximvzBhWTaeQgom56J49L3rs/8njOGrZv++Vz93gxW3B8XDE=@vger.kernel.org X-Gm-Message-State: AOJu0YxrEymK0ci6JHPtYStLsHHir3eJ7FZBOXPHe9sngq8pAVs9Stbs tlB35IhFFxy9crFQv1Zyd27A+PYpqNjaoN7nXRuJfDqHiToKBW+mOr+xaoV4Zqf4/3U= X-Gm-Gg: ASbGncvgMyt60UQbxs62ExVYBRJXEiSMX7aXr8xzmPtl+G6MRycg1wZbzuwzzDkHhHl H4wYvXL86CS31zG10IocxhxS7yTlDhPvxAqRUYyDMaI4xwgZqXYoa5fZ9QkhgwSjFZIKBhskf8H HXW7zb0Yk4uQ7fPoklTTkUw1lAs5w2jg3zBXHscNSSypJd1Y578YcBG0hN8ehqexAZC/7osz5ch NnRnVT8383vfLB7LCRPi4WbrTabDk+c2GGewChhfOH4GfXSiDIDjnVQV1rERpLDrhlexhHY7b4U Rw/rYn0bG8uQRRmuLgQydMz43oOtrYJS81igbR2xsLyAPM9nsRdyd4MborI3mSNT2fNzu3GqBfk Wi1xTahndjoe79E7RgpArOhMGMQSFh4TSoZ/ynEdtwlPZ X-Google-Smtp-Source: AGHT+IE2Sm8joda6c48q0B6UPr0z8jPKRPsMHx2zrjXp9mPsGp8XAiPxc1y8a3WP59VxL5+uFHFXPA== X-Received: by 2002:a05:6000:310b:b0:3a1:f5c4:b81b with SMTP id ffacd0b85a97d-3b9edfb7d26mr1923455f8f.23.1755171689344; Thu, 14 Aug 2025 04:41:29 -0700 (PDT) Received: from localhost ([45.10.155.16]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3ba54b6c93fsm992385f8f.12.2025.08.14.04.41.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 04:41:29 -0700 (PDT) From: Richard Gobert To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, corbet@lwn.net, shenjian15@huawei.com, salil.mehta@huawei.com, shaojijie@huawei.com, andrew+netdev@lunn.ch, saeedm@nvidia.com, tariqt@nvidia.com, mbloch@nvidia.com, leon@kernel.org, ecree.xilinx@gmail.com, dsahern@kernel.org, ncardwell@google.com, kuniyu@google.com, shuah@kernel.org, sdf@fomichev.me, ahmed.zaki@intel.com, aleksander.lobakin@intel.com, linux-kernel@vger.kernel.org, linux-net-drivers@amd.com, Richard Gobert Subject: [PATCH net-next 3/5] net: gso: restore ids of outer ip headers correctly Date: Thu, 14 Aug 2025 13:40:28 +0200 Message-Id: <20250814114030.7683-4-richardbgobert@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250814114030.7683-1-richardbgobert@gmail.com> References: <20250814114030.7683-1-richardbgobert@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently, NETIF_F_TSO_MANGLEID indicates that the inner-most ID can be mangled. Outer IDs can always be mangled. Make GSO preserve outer IDs by default, with NETIF_F_TSO_MANGLEID allowing both inner and outer IDs to be mangled. In the future, we could add NETIF_F_TSO_MANGLEID_{INNER,OUTER} to provide more granular control to drivers. This commit also modifies a few drivers that use SKB_GSO_FIXEDID directly. Signed-off-by: Richard Gobert --- Documentation/networking/segmentation-offloads.rst | 4 ++-- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 8 ++++++-- drivers/net/ethernet/sfc/ef100_tx.c | 14 ++++++++------ include/linux/netdevice.h | 9 +++++++-- include/linux/skbuff.h | 6 +++++- net/core/dev.c | 7 +++---- net/ipv4/af_inet.c | 13 ++++++------- net/ipv4/tcp_offload.c | 4 +--- 9 files changed, 39 insertions(+), 28 deletions(-) diff --git a/Documentation/networking/segmentation-offloads.rst b/Documenta= tion/networking/segmentation-offloads.rst index 085e8fab03fd..21c759b81f4e 100644 --- a/Documentation/networking/segmentation-offloads.rst +++ b/Documentation/networking/segmentation-offloads.rst @@ -42,8 +42,8 @@ also point to the TCP header of the packet. =20 For IPv4 segmentation we support one of two types in terms of the IP ID. The default behavior is to increment the IP ID with every segment. If the -GSO type SKB_GSO_TCP_FIXEDID is specified then we will not increment the IP -ID and all segments will use the same IP ID. If a device has +GSO type SKB_GSO_TCP_FIXEDID_{OUTER,INNER} is specified then we will not +increment the IP ID and all segments will use the same IP ID. If a device= has NETIF_F_TSO_MANGLEID set then the IP ID can be ignored when performing TSO and we will either increment the IP ID for all frames, or leave it at a static value based on driver preference. diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/= ethernet/hisilicon/hns3/hns3_enet.c index bfa5568baa92..b28f890b0af5 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -3868,7 +3868,7 @@ static int hns3_gro_complete(struct sk_buff *skb, u32= l234info) skb_shinfo(skb)->gso_type |=3D SKB_GSO_TCP_ECN; =20 if (l234info & BIT(HNS3_RXD_GRO_FIXID_B)) - skb_shinfo(skb)->gso_type |=3D SKB_GSO_TCP_FIXEDID; + skb_shinfo(skb)->gso_type |=3D SKB_GSO_TCP_FIXEDID_OUTER; =20 skb->csum_start =3D (unsigned char *)th - skb->head; skb->csum_offset =3D offsetof(struct tcphdr, check); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/= ethernet/mellanox/mlx5/core/en_rx.c index b8c609d91d11..78df60c62225 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c @@ -1289,8 +1289,12 @@ static void mlx5e_shampo_update_ipv4_tcp_hdr(struct = mlx5e_rq *rq, struct iphdr * tcp->check =3D ~tcp_v4_check(skb->len - tcp_off, ipv4->saddr, ipv4->daddr, 0); skb_shinfo(skb)->gso_type |=3D SKB_GSO_TCPV4; - if (ntohs(ipv4->id) =3D=3D rq->hw_gro_data->second_ip_id) - skb_shinfo(skb)->gso_type |=3D SKB_GSO_TCP_FIXEDID; + if (ntohs(ipv4->id) =3D=3D rq->hw_gro_data->second_ip_id) { + bool encap =3D rq->hw_gro_data->fk.control.flags & FLOW_DIS_ENCAPSULATIO= N; + + skb_shinfo(skb)->gso_type |=3D encap ? + SKB_GSO_TCP_FIXEDID_INNER : SKB_GSO_TCP_FIXEDID_OUTER; + } =20 skb->csum_start =3D (unsigned char *)tcp - skb->head; skb->csum_offset =3D offsetof(struct tcphdr, check); diff --git a/drivers/net/ethernet/sfc/ef100_tx.c b/drivers/net/ethernet/sfc= /ef100_tx.c index e6b6be549581..aab2425e62bb 100644 --- a/drivers/net/ethernet/sfc/ef100_tx.c +++ b/drivers/net/ethernet/sfc/ef100_tx.c @@ -189,7 +189,8 @@ static void ef100_make_tso_desc(struct efx_nic *efx, { bool gso_partial =3D skb_shinfo(skb)->gso_type & SKB_GSO_PARTIAL; unsigned int len, ip_offset, tcp_offset, payload_segs; - u32 mangleid =3D ESE_GZ_TX_DESC_IP4_ID_INC_MOD16; + u32 mangleid_outer =3D ESE_GZ_TX_DESC_IP4_ID_INC_MOD16; + u32 mangleid_inner =3D ESE_GZ_TX_DESC_IP4_ID_INC_MOD16; unsigned int outer_ip_offset, outer_l4_offset; u16 vlan_tci =3D skb_vlan_tag_get(skb); u32 mss =3D skb_shinfo(skb)->gso_size; @@ -200,8 +201,10 @@ static void ef100_make_tso_desc(struct efx_nic *efx, bool outer_csum; u32 paylen; =20 - if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID) - mangleid =3D ESE_GZ_TX_DESC_IP4_ID_NO_OP; + if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID_OUTER) + mangleid_outer =3D ESE_GZ_TX_DESC_IP4_ID_NO_OP; + if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID_INNER) + mangleid_inner =3D ESE_GZ_TX_DESC_IP4_ID_NO_OP; if (efx->net_dev->features & NETIF_F_HW_VLAN_CTAG_TX) vlan_enable =3D skb_vlan_tag_present(skb); =20 @@ -239,14 +242,13 @@ static void ef100_make_tso_desc(struct efx_nic *efx, ESF_GZ_TX_TSO_CSO_INNER_L4, 1, ESF_GZ_TX_TSO_INNER_L3_OFF_W, ip_offset >> 1, ESF_GZ_TX_TSO_INNER_L4_OFF_W, tcp_offset >> 1, - ESF_GZ_TX_TSO_ED_INNER_IP4_ID, mangleid, + ESF_GZ_TX_TSO_ED_INNER_IP4_ID, mangleid_inner, ESF_GZ_TX_TSO_ED_INNER_IP_LEN, 1, ESF_GZ_TX_TSO_OUTER_L3_OFF_W, outer_ip_offset >> 1, ESF_GZ_TX_TSO_OUTER_L4_OFF_W, outer_l4_offset >> 1, ESF_GZ_TX_TSO_ED_OUTER_UDP_LEN, udp_encap && !gso_partial, ESF_GZ_TX_TSO_ED_OUTER_IP_LEN, encap && !gso_partial, - ESF_GZ_TX_TSO_ED_OUTER_IP4_ID, encap ? mangleid : - ESE_GZ_TX_DESC_IP4_ID_NO_OP, + ESF_GZ_TX_TSO_ED_OUTER_IP4_ID, mangleid_outer, ESF_GZ_TX_TSO_VLAN_INSERT_EN, vlan_enable, ESF_GZ_TX_TSO_VLAN_INSERT_TCI, vlan_tci ); diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 5e5de4b0a433..e55ba6918b0a 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -5287,13 +5287,18 @@ void skb_warn_bad_offload(const struct sk_buff *skb= ); =20 static inline bool net_gso_ok(netdev_features_t features, int gso_type) { - netdev_features_t feature =3D (netdev_features_t)gso_type << NETIF_F_GSO_= SHIFT; + netdev_features_t feature; + + if (gso_type & (SKB_GSO_TCP_FIXEDID_OUTER | SKB_GSO_TCP_FIXEDID_INNER)) + gso_type |=3D __SKB_GSO_TCP_FIXEDID; + + feature =3D ((netdev_features_t)gso_type << NETIF_F_GSO_SHIFT) & NETIF_F_= GSO_MASK; =20 /* check flags correspondence */ BUILD_BUG_ON(SKB_GSO_TCPV4 !=3D (NETIF_F_TSO >> NETIF_F_GSO_SHIFT)); BUILD_BUG_ON(SKB_GSO_DODGY !=3D (NETIF_F_GSO_ROBUST >> NETIF_F_GSO_SHIF= T)); BUILD_BUG_ON(SKB_GSO_TCP_ECN !=3D (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT)); - BUILD_BUG_ON(SKB_GSO_TCP_FIXEDID !=3D (NETIF_F_TSO_MANGLEID >> NETIF_F_GS= O_SHIFT)); + BUILD_BUG_ON(__SKB_GSO_TCP_FIXEDID !=3D (NETIF_F_TSO_MANGLEID >> NETIF_F_= GSO_SHIFT)); BUILD_BUG_ON(SKB_GSO_TCPV6 !=3D (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT)); BUILD_BUG_ON(SKB_GSO_FCOE !=3D (NETIF_F_FSO >> NETIF_F_GSO_SHIFT)); BUILD_BUG_ON(SKB_GSO_GRE !=3D (NETIF_F_GSO_GRE >> NETIF_F_GSO_SHIFT)); diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 14b923ddb6df..5cfbf6e8c7ea 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -674,7 +674,7 @@ enum { /* This indicates the tcp segment has CWR set. */ SKB_GSO_TCP_ECN =3D 1 << 2, =20 - SKB_GSO_TCP_FIXEDID =3D 1 << 3, + __SKB_GSO_TCP_FIXEDID =3D 1 << 3, =20 SKB_GSO_TCPV6 =3D 1 << 4, =20 @@ -707,6 +707,10 @@ enum { SKB_GSO_FRAGLIST =3D 1 << 18, =20 SKB_GSO_TCP_ACCECN =3D 1 << 19, + + /* These don't correspond with netdev features. */ + SKB_GSO_TCP_FIXEDID_OUTER =3D 1 << 30, + SKB_GSO_TCP_FIXEDID_INNER =3D 1 << 31, }; =20 #if BITS_PER_LONG > 32 diff --git a/net/core/dev.c b/net/core/dev.c index 68dc47d7e700..9941c39b5970 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3772,10 +3772,9 @@ static netdev_features_t gso_features_check(const st= ruct sk_buff *skb, * IPv4 header has the potential to be fragmented. */ if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4) { - struct iphdr *iph =3D skb->encapsulation ? - inner_ip_hdr(skb) : ip_hdr(skb); - - if (!(iph->frag_off & htons(IP_DF))) + if (!(ip_hdr(skb)->frag_off & htons(IP_DF)) || + (skb->encapsulation && + !(inner_ip_hdr(skb)->frag_off & htons(IP_DF)))) features &=3D ~NETIF_F_TSO_MANGLEID; } =20 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 76e38092cd8a..7f29b485009d 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1393,14 +1393,13 @@ struct sk_buff *inet_gso_segment(struct sk_buff *sk= b, =20 segs =3D ERR_PTR(-EPROTONOSUPPORT); =20 - if (!skb->encapsulation || encap) { - udpfrag =3D !!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP); - fixedid =3D !!(skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID); + /* fixed ID is invalid if DF bit is not set */ + fixedid =3D !!(skb_shinfo(skb)->gso_type & (SKB_GSO_TCP_FIXEDID_OUTER << = encap)); + if (fixedid && !(ip_hdr(skb)->frag_off & htons(IP_DF))) + goto out; =20 - /* fixed ID is invalid if DF bit is not set */ - if (fixedid && !(ip_hdr(skb)->frag_off & htons(IP_DF))) - goto out; - } + if (!skb->encapsulation || encap) + udpfrag =3D !!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP); =20 ops =3D rcu_dereference(inet_offloads[proto]); if (likely(ops && ops->callbacks.gso_segment)) { diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c index 74f46663eeae..83fa6b2aecf4 100644 --- a/net/ipv4/tcp_offload.c +++ b/net/ipv4/tcp_offload.c @@ -485,10 +485,8 @@ INDIRECT_CALLABLE_SCOPE int tcp4_gro_complete(struct s= k_buff *skb, int thoff) th->check =3D ~tcp_v4_check(skb->len - thoff, iph->saddr, iph->daddr, 0); =20 - bool is_fixedid =3D (NAPI_GRO_CB(skb)->ip_fixedid >> skb->encapsulation) = & 1; - skb_shinfo(skb)->gso_type |=3D SKB_GSO_TCPV4 | - (is_fixedid * SKB_GSO_TCP_FIXEDID); + (NAPI_GRO_CB(skb)->ip_fixedid * SKB_GSO_TCP_FIXEDID_OUTER); =20 tcp_gro_complete(skb); return 0; --=20 2.36.1 From nobody Sat Oct 4 15:57:32 2025 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 C49762FC873; Thu, 14 Aug 2025 11:41:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755171699; cv=none; b=fHgiQ/AqjLIuEoWut+7yUitCe/HVKyUYRMLwYSxGgRoDUQznVVh8JDyVs47a0PMsiA4fXvEwubZL+Ycqb4d/NY6mJxavh+R8PCSZtalHHmsy3zzsTkgQLMcQhvx9LliOFAKVhMZxb5+rT8DQY6vL5gsGqJkphudI9ZWzsfQ68L0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755171699; c=relaxed/simple; bh=3mc9d2A6u3r3oUg0hEgXlYh1GPhKCuMUPAX7+Fzff5I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Uz3qb4fIjV/Vq6RxBthmSgzaSa3eIfwPFsHIeUeMvXSZnSbu8iqCtOBtlzP4XlK+nnDPsJebEKF+aCRBbg8XPlAKuul5SioU3A1Ht9XCW7tU2bUeVvczDsCTWj2EtXgc46vzME0bcEeI3lMyyFwS3CI+sAP2YbxDkfSTmqf3eds= 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=QFyPECct; arc=none smtp.client-ip=209.85.221.51 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="QFyPECct" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-3b9d41c1963so426698f8f.0; Thu, 14 Aug 2025 04:41:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755171696; x=1755776496; 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=EuRJoY3GNkyWfDlJezuldyXpAwYPVRBuFKt2MQIP7HE=; b=QFyPECctvNNXe01/MlDeo0xOMfrpHQwcoT0z41l95BXIZq7FUuMzHmfoGg+ClOZBM0 pOKyEqSQFdIrYVRbcZNvIB4khlxArcsTOv2v+zzBjd/18DetnfZxNG5GfTstB4e1llP6 1qTKtJSo3WDaHBVC4jwoJ7vFLg9Lcp+fZcqr6IsRnM6N9Pfw19seTgRuRpBGXHPf1cyu Py9oBbq4TufxkOw+adOM+/adlUBcc3thtVE81IksnU5cVcugLM3Tfwm61hMhavrWSyt3 nmxis4WzJiSij7nlia2iRc7LuWwnYrfPgKlFtcdmXeF1XI6dsGWl/F41s1rlv/4nXASG lS0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755171696; x=1755776496; 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=EuRJoY3GNkyWfDlJezuldyXpAwYPVRBuFKt2MQIP7HE=; b=wrPBbGTXovUDPmQ0ILG/W/HgyYbIAi4yNGw7iCLgou3eIzNlyNxZpFphmt9BTfF3Q4 5kTS+0DBuko/lRJjduobRdrIzNf02yWoSGRibrbGud5GOFR+v6y6MtigBbgAi+ZbzUqs bnfJVD31u0K5pzcxl9roh+28yG5V+M1CsH8Rj2TbWBG0noHFzNb31prBX1d2pJdshNqG VnIh33CQfEa7K72XnolsDfkTaXJD1qVqj7NxZ8hBeR+3zgMNIDkYOngzC4ejsUfwijdE 5VwGSyNi0pYjCtwxwjraBwImeR1AjwMWb87QeGVXdFPSuTv1lebZ6/zgJhHQmcS2caXA FHgA== X-Forwarded-Encrypted: i=1; AJvYcCVmcfgx+bnyMd9JD9sqerCLbYWgrLn1KzgwbGgsk7cuZ2omWvVCROsaQsnhQcXj6RHF7gHHGanZxUE931M=@vger.kernel.org X-Gm-Message-State: AOJu0YxzeLF/F6EHs+snztxMmUkabbFMyrg4IworX2Es93sIcQ3dmkKZ cQ4Fgn7b/+bBqhvCw4NUB4Nj1O+eqtwjca9SP2XkSIQD7sr1nXjs4IutlaIRjo2ivbI= X-Gm-Gg: ASbGnctNxKu1L4K1zk6TlZ7wmSkoHNriAar+VguX9MMVaa39egR3qGIKWRdap3wBiAr 4AS8WgZIF3aB9wq1VYk4LdUH9Io0E8f0efU658Fg9it8LfB6LRsqKeBadThTzVpvzVx7yhDMt4x Qz64+jtnQZG0GWVMmeHwKU2tEc689Yh74UPnsL1b6MbpqAIhOrFJwBNRmupBsKyAxKnnEZpC0rK 3U0xCrmUPbsNEbTzPn628T4L6ie7WbRJxbgZ5wjB8Ng3EWWWDkyf810X3kdgu0uleAmuVtvAqY5 s4y+HrCBPi+hFar0oeAXWh4hC+NOtMsi7dKLbFWGF8qcYco+nWnUktGNJbzESAe10Scktg7u0SW S9PzJdolc+lkVOdOg3F/5blAvrwiJrWt4eQ== X-Google-Smtp-Source: AGHT+IF7oqr/0z9KtKpnNJiknFXg8mQzZW6PfHLCQIpA5VO6sxuqD14q263bkHJfjz+SIbGAV1Qlbw== X-Received: by 2002:a05:6000:24c2:b0:3b7:8d2a:b33c with SMTP id ffacd0b85a97d-3b9edf1e355mr1990613f8f.18.1755171695910; Thu, 14 Aug 2025 04:41:35 -0700 (PDT) Received: from localhost ([45.10.155.16]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b8f5d7deaasm29866827f8f.65.2025.08.14.04.41.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 04:41:35 -0700 (PDT) From: Richard Gobert To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, corbet@lwn.net, shenjian15@huawei.com, salil.mehta@huawei.com, shaojijie@huawei.com, andrew+netdev@lunn.ch, saeedm@nvidia.com, tariqt@nvidia.com, mbloch@nvidia.com, leon@kernel.org, ecree.xilinx@gmail.com, dsahern@kernel.org, ncardwell@google.com, kuniyu@google.com, shuah@kernel.org, sdf@fomichev.me, ahmed.zaki@intel.com, aleksander.lobakin@intel.com, linux-kernel@vger.kernel.org, linux-net-drivers@amd.com, Richard Gobert Subject: [PATCH net-next 4/5] net: gro: remove unnecessary df checks Date: Thu, 14 Aug 2025 13:40:29 +0200 Message-Id: <20250814114030.7683-5-richardbgobert@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250814114030.7683-1-richardbgobert@gmail.com> References: <20250814114030.7683-1-richardbgobert@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently, packets with fixed IDs will be merged only if their don't-fragment bit is set. Merged packets are re-split into segments before being fragmented, so the result is the same as if the packets weren't merged to begin with. Remove unnecessary don't-fragment checks. Signed-off-by: Richard Gobert --- include/net/gro.h | 5 ++--- net/ipv4/af_inet.c | 3 --- tools/testing/selftests/net/gro.c | 9 ++++----- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/include/net/gro.h b/include/net/gro.h index e7997a9fb30b..e3affb2e2ca8 100644 --- a/include/net/gro.h +++ b/include/net/gro.h @@ -448,17 +448,16 @@ static inline int inet_gro_flush(const struct iphdr *= iph, const struct iphdr *ip const u32 id2 =3D ntohl(*(__be32 *)&iph2->id); const u16 ipid_offset =3D (id >> 16) - (id2 >> 16); const u16 count =3D NAPI_GRO_CB(p)->count; - const u32 df =3D id & IP_DF; =20 /* All fields must match except length and checksum. */ - if ((iph->ttl ^ iph2->ttl) | (iph->tos ^ iph2->tos) | (df ^ (id2 & IP_DF)= )) + if ((iph->ttl ^ iph2->ttl) | (iph->tos ^ iph2->tos) | ((id ^ id2) & IP_DF= )) return true; =20 /* When we receive our second frame we can make a decision on if we * continue this flow as an atomic flow with a fixed ID or if we use * an incrementing ID. */ - if (count =3D=3D 1 && df && !ipid_offset) + if (count =3D=3D 1 && !ipid_offset) NAPI_GRO_CB(p)->ip_fixedid |=3D 1 << inner; =20 return ipid_offset ^ (count * !(NAPI_GRO_CB(p)->ip_fixedid & (1 << inner)= )); diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 7f29b485009d..b4052cabdfc4 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1393,10 +1393,7 @@ struct sk_buff *inet_gso_segment(struct sk_buff *skb, =20 segs =3D ERR_PTR(-EPROTONOSUPPORT); =20 - /* fixed ID is invalid if DF bit is not set */ fixedid =3D !!(skb_shinfo(skb)->gso_type & (SKB_GSO_TCP_FIXEDID_OUTER << = encap)); - if (fixedid && !(ip_hdr(skb)->frag_off & htons(IP_DF))) - goto out; =20 if (!skb->encapsulation || encap) udpfrag =3D !!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP); diff --git a/tools/testing/selftests/net/gro.c b/tools/testing/selftests/ne= t/gro.c index d5824eadea10..3d4a82a2607c 100644 --- a/tools/testing/selftests/net/gro.c +++ b/tools/testing/selftests/net/gro.c @@ -670,7 +670,7 @@ static void send_flush_id_case(int fd, struct sockaddr_= ll *daddr, int tcase) iph2->id =3D htons(9); break; =20 - case 3: /* DF=3D0, Fixed - should not coalesce */ + case 3: /* DF=3D0, Fixed - should coalesce */ iph1->frag_off &=3D ~htons(IP_DF); iph1->id =3D htons(8); =20 @@ -1188,10 +1188,9 @@ static void gro_receiver(void) correct_payload[0] =3D PAYLOAD_LEN * 2; check_recv_pkts(rxfd, correct_payload, 1); =20 - printf("DF=3D0, Fixed - should not coalesce: "); - correct_payload[0] =3D PAYLOAD_LEN; - correct_payload[1] =3D PAYLOAD_LEN; - check_recv_pkts(rxfd, correct_payload, 2); + printf("DF=3D0, Fixed - should coalesce: "); + correct_payload[0] =3D PAYLOAD_LEN * 2; + check_recv_pkts(rxfd, correct_payload, 1); =20 printf("DF=3D1, 2 Incrementing and one fixed - should coalesce only fir= st 2 packets: "); correct_payload[0] =3D PAYLOAD_LEN * 2; --=20 2.36.1 From nobody Sat Oct 4 15:57:32 2025 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 754242F49FA; Thu, 14 Aug 2025 11:41:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755171706; cv=none; b=PTTIuHGhVM2+K/hD0HsLxpX0gTQvTu52owc3d15Y3UtrTQch5M1UCo3QHwkR6pHCR9SaA5bDT3cy53m46Dq0jGX5raAWyRn0C2RvsmUegZtmFZiP30XdtfscAaiyxFHVbo6vKOroguf6ekgVDZSzhgDK85Wv7OMvi0p1ifOCCCw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755171706; c=relaxed/simple; bh=Km6HAM5WPy85lF6G3hIg/9d7nR8208+jUkQ5DnzMyWI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=N9MK+rt9Ek9ijocqxWizR7Y3K7lmgMnBAbgNQDNn3OSDJz0zg+et8mid0Ibhb4ef40cBAAm7vCj6S81IoDKirHQZsUuaDyHl2ljqLL+uVICyzMUqtyXKSTadnFxjcBzDsEtM4fGZCr2TYTOjJnHPy9SRYVJtocEqd7VsvDg27fA= 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=VNFYQXth; arc=none smtp.client-ip=209.85.221.49 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="VNFYQXth" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-3b9d41cd38dso539141f8f.0; Thu, 14 Aug 2025 04:41:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755171703; x=1755776503; 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=3h8+OjZKOpkiZNZr++0BKN8NT+/LAkfWQsPEcsq8Haw=; b=VNFYQXthd8k9+08KRQCC5HMK8dXi5E9R1oowszRSbcu60kE+oq7kdP+o0xxKLykDxq 4cmqkOGEtWf+zaMkozL09abFUzjUfpDADUNH8GHrZCelZ/zcolAzIWJU9FPnWrD7Pakt n3Hd2Lc7sHfnsY9Er6Olcgiip6I98pspYgSyRpSRT6dxCgEmpRnSWcday31eRx2ATONN RjmtVyYTebjwZApR80mzeWpdMe55L/Hd9RxQGtfv0Lpm7CDwnPgOzERtglSiX34O7vBn Tq19hIkIQowEse+Aos1B4Wr9UFYtTe88xPFYZxWTxoEAHuLj6SRCk+vD2ZyxGGXsA6ya dhVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755171703; x=1755776503; 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=3h8+OjZKOpkiZNZr++0BKN8NT+/LAkfWQsPEcsq8Haw=; b=DODwk5az7SBPFsshW6uK1vmOVEhqxosYJ6OQsiVJY5recBmS/vBAhr/9PecjMnSwOK IpW2eBAR19aD80OwVIqt08Yp8vJi40KlxIz3AwN59a55NT+IZxj6+lJR07hWWUEJ+XfW z1Hcxzeq9Ut4Fln02QcVLi242JiY9rnGUSgl7/1HZctQdArh735RmTK0r0wNjKRKD8WD 5VMDFWyrvYTNF049HQri+pIGE42xUbkboBibK/BRRBgufWeAH8/Mp2a+ocLq9Qo4QGSd +j1q4delw1iZaMb2d6U+3gacqSiorIXzB5NdNPPLEw1C7l13pOJKQlk6vhmknl4FNJ8l qlvg== X-Forwarded-Encrypted: i=1; AJvYcCVzjjS0s+O4rVPSy3YpL6gh/MjJL2XB0/OPNYb2l61UazhmKyHRnVYMbNsaNAHJN5U44R24EcYnmxiWJaA=@vger.kernel.org X-Gm-Message-State: AOJu0YyRMLPzU/M6UVOFBil1lFwy4qz+1+m2auTr0XF862F5CjKf8NFh umesGYU9EEl9YCtT7NOJN34C2z1Gda0Mi9TkW7lPYKW7er99lHEDkGLTyJoahXO95JA= X-Gm-Gg: ASbGncvx7aDFsfkGL2VErvH+r+f1hZXuyX1qnmQSdI+xjZs9nfB+ss52magC+yVN43F 7ef+djZvkFXVPv3iRroW2ops1LfAGFEN150l63CCjJOuBFUmyP/zlIchjHPXoLoETsJSnLdereT TbmZl4tHkBH955V3uBoGp81WEthh/6MxT858Y9DQ96sq9Jm2+6J7nq6k+ItjPIPtwVViYQBQH5q aIAex1ewXuESAwVsotUxeCCY400vv8+i9UgqIJrr3PZ0wBbnJi0LPEY9p3t7aJmZvCWY4dmCWmx M8fersvtVrLJ+yeUi97fOJmfVXmub6VNKtm1XIpy0lpw8G82rNfLsuFcvb6hjlqXWov3//h0j22 1QLOuBzCG8oeEQ1wTgBVjy6UDpmPkfOBFOg== X-Google-Smtp-Source: AGHT+IEScL1eql0ZMV/N3qkw3RbTyRwTGE8yEEAe2Y2luSwWvhuJhbXe9zC/yYLWDbi3tueJj9Dh3w== X-Received: by 2002:a05:6000:2dc6:b0:3b8:12a6:36b8 with SMTP id ffacd0b85a97d-3b9edf5f1e8mr2495461f8f.46.1755171702695; Thu, 14 Aug 2025 04:41:42 -0700 (PDT) Received: from localhost ([45.10.155.16]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b79c469319sm49568378f8f.54.2025.08.14.04.41.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Aug 2025 04:41:42 -0700 (PDT) From: Richard Gobert To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, corbet@lwn.net, shenjian15@huawei.com, salil.mehta@huawei.com, shaojijie@huawei.com, andrew+netdev@lunn.ch, saeedm@nvidia.com, tariqt@nvidia.com, mbloch@nvidia.com, leon@kernel.org, ecree.xilinx@gmail.com, dsahern@kernel.org, ncardwell@google.com, kuniyu@google.com, shuah@kernel.org, sdf@fomichev.me, ahmed.zaki@intel.com, aleksander.lobakin@intel.com, linux-kernel@vger.kernel.org, linux-net-drivers@amd.com, Richard Gobert Subject: [PATCH net-next 5/5] selftests/net: test ipip packets in gro.sh Date: Thu, 14 Aug 2025 13:40:30 +0200 Message-Id: <20250814114030.7683-6-richardbgobert@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250814114030.7683-1-richardbgobert@gmail.com> References: <20250814114030.7683-1-richardbgobert@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add IPIP test-cases to the GRO selftest. This selftest already contains IP ID test-cases. They are now also tested for encapsulated packets. Signed-off-by: Richard Gobert --- tools/testing/selftests/net/gro.c | 38 +++++++++++++++++++++++------- tools/testing/selftests/net/gro.sh | 5 ++-- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/net/gro.c b/tools/testing/selftests/ne= t/gro.c index 3d4a82a2607c..a129c7965fb8 100644 --- a/tools/testing/selftests/net/gro.c +++ b/tools/testing/selftests/net/gro.c @@ -93,6 +93,7 @@ static bool tx_socket =3D true; static int tcp_offset =3D -1; static int total_hdr_len =3D -1; static int ethhdr_proto =3D -1; +static bool ipip; static const int num_flush_id_cases =3D 6; =20 static void vlog(const char *fmt, ...) @@ -114,7 +115,9 @@ static void setup_sock_filter(int fd) int ipproto_off, opt_ipproto_off; int next_off; =20 - if (proto =3D=3D PF_INET) + if (ipip) + next_off =3D sizeof(struct iphdr) + offsetof(struct iphdr, protocol); + else if (proto =3D=3D PF_INET) next_off =3D offsetof(struct iphdr, protocol); else next_off =3D offsetof(struct ipv6hdr, nexthdr); @@ -244,7 +247,7 @@ static void fill_datalinklayer(void *buf) eth->h_proto =3D ethhdr_proto; } =20 -static void fill_networklayer(void *buf, int payload_len) +static void fill_networklayer(void *buf, int payload_len, int protocol) { struct ipv6hdr *ip6h =3D buf; struct iphdr *iph =3D buf; @@ -254,7 +257,7 @@ static void fill_networklayer(void *buf, int payload_le= n) =20 ip6h->version =3D 6; ip6h->payload_len =3D htons(sizeof(struct tcphdr) + payload_len); - ip6h->nexthdr =3D IPPROTO_TCP; + ip6h->nexthdr =3D protocol; ip6h->hop_limit =3D 8; if (inet_pton(AF_INET6, addr6_src, &ip6h->saddr) !=3D 1) error(1, errno, "inet_pton source ip6"); @@ -266,7 +269,7 @@ static void fill_networklayer(void *buf, int payload_le= n) iph->version =3D 4; iph->ihl =3D 5; iph->ttl =3D 8; - iph->protocol =3D IPPROTO_TCP; + iph->protocol =3D protocol; iph->tot_len =3D htons(sizeof(struct tcphdr) + payload_len + sizeof(struct iphdr)); iph->frag_off =3D htons(0x4000); /* DF =3D 1, MF =3D 0 */ @@ -313,9 +316,19 @@ static void create_packet(void *buf, int seq_offset, i= nt ack_offset, { memset(buf, 0, total_hdr_len); memset(buf + total_hdr_len, 'a', payload_len); + fill_transportlayer(buf + tcp_offset, seq_offset, ack_offset, payload_len, fin); - fill_networklayer(buf + ETH_HLEN, payload_len); + + if (ipip) { + fill_networklayer(buf + ETH_HLEN + sizeof(struct iphdr), + payload_len, IPPROTO_TCP); + fill_networklayer(buf + ETH_HLEN, payload_len + sizeof(struct iphdr), + IPPROTO_IPIP); + } else { + fill_networklayer(buf + ETH_HLEN, payload_len, IPPROTO_TCP); + } + fill_datalinklayer(buf); } =20 @@ -777,7 +790,7 @@ static void send_fragment4(int fd, struct sockaddr_ll *= daddr) */ memset(buf + total_hdr_len, 'a', PAYLOAD_LEN * 2); fill_transportlayer(buf + tcp_offset, PAYLOAD_LEN, 0, PAYLOAD_LEN * 2, 0); - fill_networklayer(buf + ETH_HLEN, PAYLOAD_LEN); + fill_networklayer(buf + ETH_HLEN, PAYLOAD_LEN, IPPROTO_TCP); fill_datalinklayer(buf); =20 iph->frag_off =3D htons(0x6000); // DF =3D 1, MF =3D 1 @@ -1250,6 +1263,7 @@ static void parse_args(int argc, char **argv) { "iface", required_argument, NULL, 'i' }, { "ipv4", no_argument, NULL, '4' }, { "ipv6", no_argument, NULL, '6' }, + { "ipip", no_argument, NULL, 'e' }, { "rx", no_argument, NULL, 'r' }, { "saddr", required_argument, NULL, 's' }, { "smac", required_argument, NULL, 'S' }, @@ -1259,7 +1273,7 @@ static void parse_args(int argc, char **argv) }; int c; =20 - while ((c =3D getopt_long(argc, argv, "46d:D:i:rs:S:t:v", opts, NULL)) != =3D -1) { + while ((c =3D getopt_long(argc, argv, "46ed:D:i:rs:S:t:v", opts, NULL)) != =3D -1) { switch (c) { case '4': proto =3D PF_INET; @@ -1269,6 +1283,11 @@ static void parse_args(int argc, char **argv) proto =3D PF_INET6; ethhdr_proto =3D htons(ETH_P_IPV6); break; + case 'e': + ipip =3D true; + proto =3D PF_INET; + ethhdr_proto =3D htons(ETH_P_IP); + break; case 'd': addr4_dst =3D addr6_dst =3D optarg; break; @@ -1304,7 +1323,10 @@ int main(int argc, char **argv) { parse_args(argc, argv); =20 - if (proto =3D=3D PF_INET) { + if (ipip) { + tcp_offset =3D ETH_HLEN + sizeof(struct iphdr) * 2; + total_hdr_len =3D tcp_offset + sizeof(struct tcphdr); + } else if (proto =3D=3D PF_INET) { tcp_offset =3D ETH_HLEN + sizeof(struct iphdr); total_hdr_len =3D tcp_offset + sizeof(struct tcphdr); } else if (proto =3D=3D PF_INET6) { diff --git a/tools/testing/selftests/net/gro.sh b/tools/testing/selftests/n= et/gro.sh index 9e3f186bc2a1..d16ec365b3cf 100755 --- a/tools/testing/selftests/net/gro.sh +++ b/tools/testing/selftests/net/gro.sh @@ -4,7 +4,7 @@ readonly SERVER_MAC=3D"aa:00:00:00:00:02" readonly CLIENT_MAC=3D"aa:00:00:00:00:01" readonly TESTS=3D("data" "ack" "flags" "tcp" "ip" "large") -readonly PROTOS=3D("ipv4" "ipv6") +readonly PROTOS=3D("ipv4" "ipv6" "ipip") dev=3D"" test=3D"all" proto=3D"ipv4" @@ -31,7 +31,8 @@ run_test() { 1>>log.txt wait "${server_pid}" exit_code=3D$? - if [[ ${test} =3D=3D "large" && -n "${KSFT_MACHINE_SLOW}" && \ + if [[ ( ${test} =3D=3D "large" || ${protocol} =3D=3D "ipip" ) && \ + -n "${KSFT_MACHINE_SLOW}" && \ ${exit_code} -ne 0 ]]; then echo "Ignoring errors due to slow environment" 1>&2 exit_code=3D0 --=20 2.36.1