Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7122893rdb; Wed, 3 Jan 2024 05:31:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGIAuWU+9uOomil0GyTwfLsRjuoJkEsNQgMOu5w9FyI7l1KWwq2X4x6M9UA302qoFmEGyUm X-Received: by 2002:a05:622a:1b02:b0:428:31ce:c4ac with SMTP id bb2-20020a05622a1b0200b0042831cec4acmr2012009qtb.42.1704288715235; Wed, 03 Jan 2024 05:31:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704288715; cv=none; d=google.com; s=arc-20160816; b=v28FiwqKiHBr2kVPmPa2hfvtJvebgplopc1eaiJZM6NN0ptHQItFRwm8X0TC9Tx+Ru hUiIHx5aK1gCwwQqcd2Rily9PlZ/TG+f62pZIYnmWWfnqhsfR3sF4+uzI643qzfJz0WI mBKITRv0unnuM7+5cFsnCpB1jrTDP8aV0Ue+TouLH5HFAkN99bmo6TZE7Y6pQ6My8J6U OxkC+ajRG7+DxDWn/bWtDxm+yBHhSUQH2GnoXivMMcimmjTfaZ/sBKVjqp96lZAnWiq0 CjNB67a8nr5GNEO1KdjXVCwldGH8q1L7VtfvoND/ZSQmPpbOutdoEG2tJx828veZegYq xJpA== 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=EG1JPJoQXcnD8x9xPNrPoCvZ57tzKqywV3MMnL/ZCpM=; fh=avLLqNRcAvwnUvUQcsb2DmhURiIyjcEiG7k3tmePp2A=; b=WJtF81gKXjFZfSHFEIkeC7Od2WAOTslDfNifO829kRnbWgAf+X1iQu6XzZZsNh8+0F 37HejWqkvEVLjZClPQ7bmxnIrS4wOpOX+O6MUMkkrtKjyZd3rIVRTTDtl7pUmGnjJVtJ v8f7otmZqEEII9n4Shf2bwhKqFjSKCBs9yvwO4rqFSQHN3htcK6CDx6LHeU2TRWDkbt9 iqX1Aiu8F6CfNP0zbMCPVDJjZVQQySlTUcpHNKU9CIABzXiouL5OhlcGziVj7w6IAw0J wnKno8uwjvpVHXAGnol9D4nEeHTo99QhJiVFHBivh6rifShRr8DIeujlt6VxuUfvdWtz pPHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=BHxFdWop; spf=pass (google.com: domain of linux-kernel+bounces-15578-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15578-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v13-20020a05622a014d00b004283193bfe4si2962740qtw.639.2024.01.03.05.31.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 05:31:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15578-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=BHxFdWop; spf=pass (google.com: domain of linux-kernel+bounces-15578-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15578-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 020E41C23678 for ; Wed, 3 Jan 2024 13:31:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8DA3A19BD6; Wed, 3 Jan 2024 13:30:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="BHxFdWop" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (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 31CDB19BAF for ; Wed, 3 Jan 2024 13:30:15 +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-f45.google.com with SMTP id 4fb4d7f45d1cf-553e36acfbaso12415a12.0 for ; Wed, 03 Jan 2024 05:30:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1704288614; x=1704893414; 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=EG1JPJoQXcnD8x9xPNrPoCvZ57tzKqywV3MMnL/ZCpM=; b=BHxFdWopckJEP9NAvDTlmOGjEg4Fn01X5MUaUJAi10nyecZh+csJO5sA6oubWNGx6z gMWWKTe6SqAaBxzHcoR8TgpNYXhfMknC/JSQ4XvBmKw7kz1WluQJEUVzy+Hfd6FjWM78 9hQ7kzWSDG62+wINIolrA4gfo/XvUDCCT1cr06ixSSWtSaHor/uzOYYImM4siHljv1Dz eJgOGwqW3+dfMgJb384jM3BEQT8pmqYQcVcohRwP5Nk5IYDyE8+9z23qP/RXflEAgu9w YklkOIK+sxUsGY0Dr4xW5S9yUfJxGcCLl4e4V+XTb9+uLbvcdkEMqdKI7YrsDveXWS/F VWVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704288614; x=1704893414; 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=EG1JPJoQXcnD8x9xPNrPoCvZ57tzKqywV3MMnL/ZCpM=; b=eLQx2LBflsqOBG1akY0oopeCpITyL1d6CYN5/3HUyeXLU4LdKMJkuitNpltICQbOO0 b8wfjYwNKExJVLUBgkcZLqlKhISm4MTQey94MX3vuSclrlOIqzy5dK0aWyt529SnfXOI hvPN6uqWw/IJluruYgMBquJZjDYPF8uWwgqnUpFrJMZN5R1Zti+u6FwZIovNtle2G/F2 pKCA1j8zC0vjmysXK6R6h2W3MALP0qbIwoq+1H4HsxEh9OTC9NX1gAv/2tkgLWmlIihy vNdKbRCM1ia3asmppVuITRE7MyGKOPrMgc7JSrx50BPbIAGeXDT1HFxreJfSoOm6Qnuf 8o4w== X-Gm-Message-State: AOJu0Yx2p1SLiRnfk8Vg+hi4NpD+Vt4L//fhTVu5t4k442NL4qeVgsv7 cbsFMZyn2mscKKM7SrwyJKmA3w0h3gVcg+TNKFXvcoIDhiI6 X-Received: by 2002:a50:9ece:0:b0:554:2501:cc8e with SMTP id a72-20020a509ece000000b005542501cc8emr157394edf.6.1704288614143; Wed, 03 Jan 2024 05:30:14 -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> <9419df03-a203-4b73-91a6-f008076c29b4@gmail.com> In-Reply-To: <9419df03-a203-4b73-91a6-f008076c29b4@gmail.com> From: Eric Dumazet Date: Wed, 3 Jan 2024 14:30:00 +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 Wed, Jan 3, 2024 at 2:08=E2=80=AFPM Richard Gobert wrote: > > > > Eric Dumazet wrote: > > 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 fr= om > >> 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 instea= d of > >> 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, al= l > >> operations use skb_gro_* helpers, and the frag0 fast path can be taken= for > >> 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 pr= oto) > >> +{ > >> + 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= , off); > > > > 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. > > > > In terms of consistency - similar helper functions (ipv6_gso_pull_exthdrs= , > ipv6_parse_hopopts) also pull 8 bytes at the beginning of every IPv6 > extension header, because the minimum extension header length is 8 bytes. > > sizeof(*opth) =3D 2, so for an IPv6 packet with one extension header with= a > common length of 8 bytes, pskb_may_pull will be called twice: first with > length =3D 2 and again with length =3D 8, which might not be ideal when p= arsing > non-linear packets. > > Willem suggested adding a constant to make the code more self-documenting= . Hmm... I was looking at skb_checksum_setup_ipv6() , it uses skb_maybe_pull_tail( ... sizeof(struct ipv6_opt_hdr)) ipv6_skip_exthdr() also uses sizeof(struct ipv6_opt_hdr) ip6_tnl_parse_tlv_enc_lim also uses the same. hbh_mt6(), ipv6header_mt6(), .. same... ip6_find_1stfragopt(), get_ipv6_ext_hdrs(), tcf_csum_ipv6(), mip6_rthdr_offset() same So it seems you found two helpers that went the other way. If you think pulling 8 bytes first is a win, I would suggest a stand alone patch, adding the magic constant using it in all places, so that a casual reader can make sense of the magical 8 value.