Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7641836rwb; Wed, 23 Nov 2022 08:58:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Mx8/uwig4pnKw6BHFDQ6Kl0pln5ek4BxJ/LLxxVHfwSh4706DTkJNrJ/plfQLXdycfNZ4 X-Received: by 2002:a17:90a:e657:b0:218:f115:792c with SMTP id ep23-20020a17090ae65700b00218f115792cmr2144454pjb.121.1669222718528; Wed, 23 Nov 2022 08:58:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669222718; cv=none; d=google.com; s=arc-20160816; b=lNH/20q6SVl9iTmpIB8ZXbRQT3ni70xdnjnbG/Q3NR7wLAqpsQX1z03R78Zviwr0ah ZOIQlN2jvxbF8tlPvtu3imnfB3Q8XrmZMPgRETZn4XGnO+1Ja1ogiohNenNgCudEiuLh aoMzcOmnCUspFX7zLZDXJ24gwPNDYIYF7rv6/kM46dGiTWxx8jziHbzQMY9XEGs2vGag oIlU5JSk+WnBmSc4XRzZVTvswQ1YiTui9qstu+B+u0R7YpUQja33mgJRP7rGU7LQVVLQ 3RXvL6zwtadG4XTB21FVNGngKWvYt39FO18a7vQGfBzG07RQZL/ysufbMpTWtAGt+OBe TyTA== 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=89lrrNQGE9AyegoXB81tbw+G6UKVvNn/EbQAVv+0TUI=; b=kZKlm2Md/lz3eui9C1Q6X1Ap78S2cQ1F+NkNBnugtC8j98GuHl6/HWmUc2swO7Txgc nARKhlQqCkhZ7pgBdgfbh3WzyJNGvTrL4tNNWGuj9+KTWhr+j45/HPF3IX/myxeIzQu3 PbB0TlYcDDTbAXPgYCKUUgInx6LFl/nCUkqd9Ed3oNrAKrucpM7OPCQXqYsefrxbgTT5 RXISDvvFwYvD/bP2z+XmRh3bj2RS5+MoaNzT21PubxmWoI/2+cCaXnZYGuIKT2UNRUMa U2P5rm/wFwpPiSvyzF8TaGvyPkcX0pidmHoYlUtSWVNg1wolPvJiIWU6ZOAa314dZ+65 OUKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ensJe5w0; 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 l8-20020a654c48000000b0047704a39c8fsi6312717pgr.636.2022.11.23.08.58.26; Wed, 23 Nov 2022 08:58:38 -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=ensJe5w0; 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 S238758AbiKWQic (ORCPT + 88 others); Wed, 23 Nov 2022 11:38:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238590AbiKWQia (ORCPT ); Wed, 23 Nov 2022 11:38:30 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3ADEB949A; Wed, 23 Nov 2022 08:38:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669221509; x=1700757509; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5dcDy5vLKZoiJgPni3aoK2TER1oYOGkhC5nskxQ9DSE=; b=ensJe5w08cseI6aeVWRYpF4Fu5t9o1ydsvKfvZMOI4QaXrntxCC1mrBz e6K3zTfBZ6AGa+foSkBKXloKY/cRsazxCUC4OARTnX13Tlxxo0ySXx85l mqzNA6CpSsbJzS6+sny9pDEcJlqNz5SXVCIXJ7X5LUrM6t0DfojuW7fXV XPsOEUVE1RvZfD3WkOLIts4X8QpSOTtuFFRxriUja2TNL3DqK+1ewkKtS mpHxaK2TBNBsh39N6ZZXzd2SprQl+WqueQcLE/xV+Od2J1oJsrzJC+5pc fNy6/2cVJk3yk7YVpKNJ9VLplHIIJ2jXF5A9yofQU00aN0wU7lXDzdvZR Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="400401130" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="400401130" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2022 08:38:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="784303640" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="784303640" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by fmsmga001.fm.intel.com with ESMTP; 23 Nov 2022 08:38:27 -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 2ANGcP7H012699; Wed, 23 Nov 2022 16:38:26 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 17:38:25 +0100 Message-Id: <20221123163825.485611-1-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221122232740.3180560-1-lixiaoyan@google.com> References: <20221122232740.3180560-1-lixiaoyan@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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: 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 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. > + > + 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