Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7864592rwb; Wed, 23 Nov 2022 11:49:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf539pJriAGNYgJtV/7gquJZMBU4HOO0YUnnTu1LKx4uphbA4JOB1SYEUk8K6zjw/nujZWb/ X-Received: by 2002:a05:6402:4507:b0:467:205b:723d with SMTP id ez7-20020a056402450700b00467205b723dmr7047967edb.69.1669232986644; Wed, 23 Nov 2022 11:49:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669232986; cv=none; d=google.com; s=arc-20160816; b=Q8VHyo2vKUAvUJp7AVbhzJL76Qz/pVI9J3eonCzgAvj1sXaJ1J/kcyMh0BouNZHWzh cebM1Be5WW4DdhuZaW9UiYPEtQsVmPuHDTVIvZ2oRgOC+WbCmc5wFWdG3bsvstZP+kHE o0GaxT6mZVThcnEbavUGDG6MqnmfMiH4OUfE9FFCY2AXlofW0ipNx/UE0Rm/55BLb5g+ jwCHwMx0mJehXBQ0BEUWTtmTLQ6PQmhMYk92/XBDzLRZp9GUpPoeD7TsNPUvBjRM22yU GNK8u7te/+xIDjpxc1YIxx/ZVQTuzHsm7LHR3gCK/eKWN1bi5Cn8mU3u6ATJm3UMaOYY KNtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AjWYyc8EtWPhtSrdSBiEv3+gu6q8vBlM51Wt34J8ASk=; b=nIOD4/RG8oPkSJuFm8O3GIWcIYIpVffvjc4idJT9jw4Be33exTIeam9oK9+zWS2Rzn 4TOnq31vrMg7XmH3H/BVrtLuvQkW97Q68xNwrnC1E/WqKZTetTQTlmPwFd8yTS6HLGV8 nygiIrECBeeK8j7TzFpeLVcdt7EARrrIlqLJysMNCaTiPJbyDl5S5yha/ziGnbzs3Yf8 G/pKKNdBZHZc3bmozzz7UgcjQ8LsE84Lu5U6tHqANdIg7xRs/8/KavnSqEtIY8NkFs8Z tyvKSKTGRjSlg7u50itu5UWHQwVHrj9Xv6OYSg8vNtEpv0Z1DgeMmuV3l6gAdluxYmLZ Kj4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NudbCSU3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o19-20020a170906975300b0079800b8172bsi17386571ejy.450.2022.11.23.11.49.21; Wed, 23 Nov 2022 11:49:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NudbCSU3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239452AbiKWSpM (ORCPT + 88 others); Wed, 23 Nov 2022 13:45:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238260AbiKWSpK (ORCPT ); Wed, 23 Nov 2022 13:45:10 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA07978D52; Wed, 23 Nov 2022 10:45:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669229109; x=1700765109; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KS49cPpGkhy7gLY+lTDuqpn3zAsc+OOvSKK5SN036ww=; b=NudbCSU3/oHTHv/t6FFBuykXlAk9/nsJbrLonWN6eVBMdnoYnE0dF5/T a/xnJiJc+N+mVhrFo7uCQUNgbDMK/oZounhBX4J+6XAciYim92ZIwc/Wg 0p+vIChI7KhdwTy7IAigGnFKj0rMWyMohKhFsjMBq9eyCG4Jaay/gOTJD BCLcGzS95j91h65X+ntf11Yh6rZpfXB3hnv4cZJryGIX+v/HCNTkgV9E4 OatXTkhhB0CbCV8646QDEB3ZKiug3FwPISrys2uZbyTRW7jCZJ3gDt7sd squT21Tc+I+kbghTkdXFZjPeGE1l3SHUiOB5DZLMoYcQ9XreEELF+D0tJ Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="297496164" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="297496164" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2022 10:45:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="970966434" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="970966434" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by fmsmga005.fm.intel.com with ESMTP; 23 Nov 2022 10:45:06 -0800 Received: from newjersey.igk.intel.com (newjersey.igk.intel.com [10.102.20.203]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 2ANIj5Dq005397; Wed, 23 Nov 2022 18:45:05 GMT From: Alexander Lobakin To: Coco Li Cc: Alexander Lobakin , "David S. Miller" , Hideaki YOSHIFUJI , "David Ahern" , Eric Dumazet , "Jakub Kicinski" , Paolo Abeni , Michael Chan , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next 1/2] IPv6/GRO: generic helper to remove temporary HBH/jumbo header in driver Date: Wed, 23 Nov 2022 19:44:52 +0100 Message-Id: <20221123184452.489864-1-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221123163825.485611-1-alexandr.lobakin@intel.com> References: <20221122232740.3180560-1-lixiaoyan@google.com> <20221123163825.485611-1-alexandr.lobakin@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Lobakin Date: Wed, 23 Nov 2022 17:38:25 +0100 > From: Coco Li > Date: Tue, 22 Nov 2022 15:27:39 -0800 > > > IPv6/TCP and GRO stacks can build big TCP packets with an added > > temporary Hop By Hop header. > > > > Is GSO is not involved, then the temporary header needs to be removed in > > the driver. This patch provides a generic helper for drivers that need > > to modify their headers in place. > > > > Signed-off-by: Coco Li > > --- > > include/net/ipv6.h | 33 +++++++++++++++++++++++++++++++++ > > 1 file changed, 33 insertions(+) > > > > diff --git a/include/net/ipv6.h b/include/net/ipv6.h > > index d383c895592a..a11d58c85c05 100644 > > --- a/include/net/ipv6.h > > +++ b/include/net/ipv6.h > > @@ -500,6 +500,39 @@ static inline int ipv6_has_hopopt_jumbo(const struct sk_buff *skb) > > return jhdr->nexthdr; > > } > > > > +/* Return 0 if HBH header is successfully removed > > + * Or if HBH removal is unnecessary (packet is not big TCP) > > + * Return error to indicate dropping the packet > > + */ > > +static inline int ipv6_hopopt_jumbo_remove(struct sk_buff *skb) > > +{ > > + const int hophdr_len = sizeof(struct hop_jumbo_hdr); > > + int nexthdr = ipv6_has_hopopt_jumbo(skb); > > + struct ipv6hdr *h6; > > + > > + if (!nexthdr) > > + return 0; > > + > > + if (skb_cow_head(skb, 0)) > > + return -1; > > err = skb_cow_head(skb, 0); > if (err) > return err; > > Alternatively, if you want to keep it simple, make the function bool > and return false on `if (skb_cow_head(skb, 0)` and true otherwise. > > > + > > + /* Remove the HBH header. > > + * Layout: [Ethernet header][IPv6 header][HBH][L4 Header] > > + */ > > + memmove(skb->data + hophdr_len, > > + skb->data, > > This can fit into the previous line. > > > + ETH_HLEN + sizeof(struct ipv6hdr)); > > Not correct at this point. I assume you took the implementation from > ip6_offload.c[0], but ::gso_segment() and ::ndo_start_xmit() are two Traditionally forgot to paste the links to the end of the mail. Pls look at the end of this one for them (if I don't forget to paste them again :clownface:). > different entry points. Here you may have not only Eth header, but > also VLAN, MPLS and whatnot. > Correct way would be: > > memmove(skb_mac_header(skb) + hophdr_len, skb_mac_header(skb), > ipv6_hdr(skb) - skb_mac_header(skb) + > sizeof(struct ipv6hdr)); > > > + > > + skb->data += hophdr_len; > > + skb->len -= hophdr_len; > > + skb->network_header += hophdr_len; > > skb->mac_header also needs to be adjusted, the fact that it's equal > to skb->data at the entry of ::ndo_start_xmit() doesn't mean > anything. Also, while I'm here: you should use skb_may_pull() + {,__}skb_pull() here instead of manual maths. ::network_header and ::mac_header still need to be adjusted manually tho. > > > + > > + h6 = ipv6_hdr(skb); > > + h6->nexthdr = nexthdr; > > + > > + return 0; > > +} > > Please switch all the places where the same logics is used to your > new helper. > > > + > > static inline bool ipv6_accept_ra(struct inet6_dev *idev) > > { > > /* If forwarding is enabled, RA are not accepted unless the special > > -- > > 2.38.1.584.g0f3c55d4c2-goog > > Thanks, > Olek [0] https://elixir.bootlin.com/linux/v6.1-rc6/source/net/ipv6/ip6_offload.c#L92 Thanks, Olek