Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6681199rdb; Tue, 2 Jan 2024 09:34:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IHsTJDlgT5iV1n3Ro6iSpA/uUzw+WFcz8E3lxrXC3V2qmEFRWTAV6noA2M++OAoDJuvsIVp X-Received: by 2002:a17:906:a043:b0:a28:6317:ceb4 with SMTP id bg3-20020a170906a04300b00a286317ceb4mr547779ejb.76.1704216868328; Tue, 02 Jan 2024 09:34:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704216868; cv=none; d=google.com; s=arc-20160816; b=ZEs0uQ95t+gQVW4EZYAqdsZU6VayXM0KZwHGfRjD8SUxSPLgr8odlmfFeGYtBiA8AX KhhRU48MvI9g1Ke5QSjHSIA/OY0cD6BzidzCbBXCa+aC0D0lbFOZ+1U1Ktm7cksXiZiG Hbknwmice4RmBJt5xQSoeiJkGEBNr7kakwFGqEDV9WrQzLDaJYFb1dePSg2DOg7kJSka jOFiJqApUjoFLMumqxNcjNL+ptRDjEr6HRJM7tt9Masv9nFSv3jxzQIxdjgdUFKeI1Sa L+MudE/1u8ptcIpJNGfX1c9PGa4m/GhO/+GUeKBvqm9QGAqxK5EWHDz+mmSSg4zBUtll hONA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=O4H4STx0XR17w8qdB0s8hsPN6AziBcrpsvvrusepEl8=; fh=avLLqNRcAvwnUvUQcsb2DmhURiIyjcEiG7k3tmePp2A=; b=h9QYIcA3iVXcG6maj1WhXAgkzi5zAhIbE4+0QyyfC3HG8lgyEMfUuQE9Xc9ynIJ5Ua 2vhV8fbjVpmII8BdlpHwT1I6SelaoHq8lnpp/LOm/00AW+qDDbh6eqzrZbg0GDMx15pE nYp10Pa+Qb9fnd2/N94AktItaoJ1zRzY3GekjdTFocKOPrakPKkt1Q4GnmELuoojpQaA qRu6pT46KutoJIKrZFIrZTRR4rtG551pwyzpWvTqdVaod7pl60WYNiqjcWTxhpzmYSMO 6cmlKs1DOCVmDfg0mq8wWIMtiVUtdEj6ujfQ/gyqqfoJkdcCB0juUY0uYe55K4wURORT /WJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=eIKxHN22; spf=pass (google.com: domain of linux-kernel+bounces-14661-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14661-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id o19-20020a1709061b1300b00a26d8051b01si8608074ejg.282.2024.01.02.09.34.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 09:34:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14661-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=eIKxHN22; spf=pass (google.com: domain of linux-kernel+bounces-14661-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14661-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id ABBBD1F22C9E for ; Tue, 2 Jan 2024 17:34:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F0CDE156C1; Tue, 2 Jan 2024 17:34:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="eIKxHN22" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.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 9B943154AA for ; Tue, 2 Jan 2024 17:34:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-55679552710so14157a12.1 for ; Tue, 02 Jan 2024 09:34:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1704216850; x=1704821650; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=O4H4STx0XR17w8qdB0s8hsPN6AziBcrpsvvrusepEl8=; b=eIKxHN22uF4ipZEbLfODcakewE4ub9/F+bb1dYH9tupsBPW2YIaKE4oiYgqJCz1ZBm ijN0/H2iRO7BrSt2f1+40qumD5oTf4Or9wps8rQfOnBnxqHB6+wd873X3BkMRIO0Bn9r 6ug04rSW23EUlK3iDBodaERaDBEjyo8EY9/olsXcRuysdcAIMN3rKt7ARAQ57zryxuV3 NNdApwgtGobV9WKWympscfUXdcTlnFu3JG6gHFOWwkTU40Y7kkVUkXC5qXnUwgggk4LR phEN/r8G6RuCG8veF9m6NKn7+E0a6OcBBehZ2OW9SqhwWTrJ2TmCoCGHvRElERarsJg7 xPsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704216850; x=1704821650; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O4H4STx0XR17w8qdB0s8hsPN6AziBcrpsvvrusepEl8=; b=g1GChVU1qTjeiNKNwSfxPXRPqHHSuyDrAKBuHHXPoHPJWabq14Q7ZiztdMjNlZrmSb 62BwSkOWteJCSsnHSMJeGK+zSO41exvqNdQ0bpuABty76Z+p42jPuTQEb0NcIP9mrEMO xRLvt4wuKi8/kSZ2Vmfz0xtqW2WppK4je+GWxjH/7Vx+QsLBYACZ/vR3i7hG73objWWO yKZ1Go53ZSe3YZ9IyJqjWZA4farxyr/tAA0A4PSJrDGSoFa06QkTfY2nkZTL+S1IPf7Z 2ta//TUy97AORD+1nTIBuumO102LxSd2MnmDO5B++8YH7wFjJzuNH5VGOiwFWuW7M8Xk yfuw== X-Gm-Message-State: AOJu0YyfVyKXm4e5rCxA62a4j9/Lk0CUVA8nLRl0d/1XYQ9Afw73ydhy OS6zC0C9p1AJjsLjVgikCgLG7ezG/eCvCQ4hOOQQo4AXtYQ/ X-Received: by 2002:a50:ba8e:0:b0:554:228f:4b8e with SMTP id x14-20020a50ba8e000000b00554228f4b8emr1136022ede.2.1704216849665; Tue, 02 Jan 2024 09:34:09 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <127b8199-1cd4-42d7-9b2b-875abaad93fe@gmail.com> <90117449-1f4a-47d7-baf4-2ed6540bc436@gmail.com> In-Reply-To: <90117449-1f4a-47d7-baf4-2ed6540bc436@gmail.com> From: Eric Dumazet Date: Tue, 2 Jan 2024 18:33:58 +0100 Message-ID: Subject: Re: [PATCH net-next v2 2/3] net: gro: parse ipv6 ext headers without frag0 invalidation To: Richard Gobert Cc: davem@davemloft.net, dsahern@kernel.org, kuba@kernel.org, pabeni@redhat.com, shuah@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jan 2, 2024 at 2:25=E2=80=AFPM Richard Gobert wrote: > > The existing code always pulls the IPv6 header and sets the transport > offset initially. Then optionally again pulls any extension headers in > ipv6_gso_pull_exthdrs and sets the transport offset again on return from > that call. skb->data is set at the start of the first extension header > before calling ipv6_gso_pull_exthdrs, and must disable the frag0 > optimization because that function uses pskb_may_pull/pskb_pull instead o= f > skb_gro_ helpers. It sets the GRO offset to the TCP header with > skb_gro_pull and sets the transport header. Then returns skb->data to its > position before this block. > > This commit introduces a new helper function - ipv6_gro_pull_exthdrs - > which is used in ipv6_gro_receive to pull ipv6 ext headers instead of > ipv6_gso_pull_exthdrs. Thus, there is no modification of skb->data, all > operations use skb_gro_* helpers, and the frag0 fast path can be taken fo= r > IPv6 packets with ext headers. > > Signed-off-by: Richard Gobert > Reviewed-by: Willem de Bruijn > --- > include/net/ipv6.h | 1 + > net/ipv6/ip6_offload.c | 51 +++++++++++++++++++++++++++++++++--------- > 2 files changed, 42 insertions(+), 10 deletions(-) > > diff --git a/include/net/ipv6.h b/include/net/ipv6.h > index 78d38dd88aba..217240efa182 100644 > --- a/include/net/ipv6.h > +++ b/include/net/ipv6.h > @@ -26,6 +26,7 @@ struct ip_tunnel_info; > #define SIN6_LEN_RFC2133 24 > > #define IPV6_MAXPLEN 65535 > +#define IPV6_MIN_EXTHDR_LEN 8 // Hmm see my following comment. > > /* > * NextHeader field of IPv6 header > diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c > index 0e0b5fed0995..c07111d8f56a 100644 > --- a/net/ipv6/ip6_offload.c > +++ b/net/ipv6/ip6_offload.c > @@ -37,6 +37,40 @@ > INDIRECT_CALL_L4(cb, f2, f1, head, skb); \ > }) > > +static int ipv6_gro_pull_exthdrs(struct sk_buff *skb, int off, int proto= ) > +{ > + const struct net_offload *ops =3D NULL; > + struct ipv6_opt_hdr *opth; > + > + for (;;) { > + int len; > + > + ops =3D rcu_dereference(inet6_offloads[proto]); > + > + if (unlikely(!ops)) > + break; > + > + if (!(ops->flags & INET6_PROTO_GSO_EXTHDR)) > + break; > + > + opth =3D skb_gro_header(skb, off + IPV6_MIN_EXTHDR_LEN, o= ff); I do not see a compelling reason for adding yet another constant here. I would stick to opth =3D skb_gro_header(skb, off + sizeof(*opth), off); Consistency with similar helpers is desirable. > + if (unlikely(!opth)) > + break; > + > + len =3D ipv6_optlen(opth); > + > + opth =3D skb_gro_header(skb, off + len, off); Note this call will take care of precise pull. > + if (unlikely(!opth)) > + break; > + proto =3D opth->nexthdr; > + > + off +=3D len; > + } > + > + skb_gro_pull(skb, off - skb_network_offset(skb)); > + return proto; > +} > + > static int ipv6_gso_pull_exthdrs(struct sk_buff *skb, int proto) > { > const struct net_offload *ops =3D NULL; > @@ -203,28 +237,25 @@ INDIRECT_CALLABLE_SCOPE struct sk_buff *ipv6_gro_re= ceive(struct list_head *head, > goto out; > > skb_set_network_header(skb, off); > - skb_gro_pull(skb, sizeof(*iph)); > - skb_set_transport_header(skb, skb_gro_offset(skb)); > > - flush +=3D ntohs(iph->payload_len) !=3D skb_gro_len(skb); > + flush +=3D ntohs(iph->payload_len) !=3D skb->len - hlen; > > proto =3D iph->nexthdr; > ops =3D rcu_dereference(inet6_offloads[proto]); > if (!ops || !ops->callbacks.gro_receive) { > - pskb_pull(skb, skb_gro_offset(skb)); > - skb_gro_frag0_invalidate(skb); > - proto =3D ipv6_gso_pull_exthdrs(skb, proto); > - skb_gro_pull(skb, -skb_transport_offset(skb)); > - skb_reset_transport_header(skb); > - __skb_push(skb, skb_gro_offset(skb)); > + proto =3D ipv6_gro_pull_exthdrs(skb, hlen, proto); > > ops =3D rcu_dereference(inet6_offloads[proto]); > if (!ops || !ops->callbacks.gro_receive) > goto out; > > - iph =3D ipv6_hdr(skb); > + iph =3D skb_gro_network_header(skb); > + } else { > + skb_gro_pull(skb, sizeof(*iph)); > } > > + skb_set_transport_header(skb, skb_gro_offset(skb)); > + > NAPI_GRO_CB(skb)->proto =3D proto; > > flush--; > -- > 2.36.1 >