Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp303919rwb; Wed, 7 Dec 2022 18:27:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf7uGgdb+bdIIqzZ0EibcNThjneVu7XN2P4sH09UeM5f58c9f+tY5JIaaJAOjarz4d0zEPEg X-Received: by 2002:a05:6402:124a:b0:46b:8e9e:876 with SMTP id l10-20020a056402124a00b0046b8e9e0876mr32683344edw.232.1670466456810; Wed, 07 Dec 2022 18:27:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670466456; cv=none; d=google.com; s=arc-20160816; b=w4ZzBlOp/jHJpLcB4GFJhVsZDglFRLQejbd+4zbqfozexOnOS3JeUdgjlZkJcjmmtz 6mFigPSIfxoWEBQXbIiwMr3quuIhsmGRR9z4rk/lqK2S9xlmhIPh90Mr/T6earQojMa1 V0n694Bz0tU0yprYjFZvYudfn7gURh8xc9rJZCdRWV8LgfN8PRNgFvD4PLMBESoWSBns +iIoCHz5CHj5tdz4JQwYR3YL0gVZw3Xhq+EfjFltssA+F7VSLk2c4GuGSkATVKMO3lfr mRqgrILHvr6SyiyhkOR+UK61sIZcjWwNCXbFS64u6mMVXfi/vwjuoz/dWQ3njzp/cHwx 1NAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=aR88s3Ybl0DvsKtxthIky8N3akpynVM/kGiV7SX8Qbo=; b=WTAPKFKNCiBcv4Uy7sLym8mM66p1KXnt7aiX/NOYVYcmWGgae6ja3C0c9APhqpdpfF k0lloNG1XDVglGqXh5XrZwmHU2ES81aoDzM2SB00cOjmRRpJtlJqZVFav5a7c0WM3urR lf3JOItHekwCiYk3bMOopxtz5+Hw4aW/t0WHTkrnXsFDyPjZau/ybEYwGuXjZobI95GJ YIHkwTHlUIAqPDvawhd4zTMsSAEYvtM6K5NbYW5YDGoZGklw1cB60Z9hH0e/Ht6AFKqb +EUBHLEVKWmjrNJPdbA1OKW9Rr7Eu1cnbOR05nvGAwFXjotokQeVwRGojFXEDNMBEkC4 w7dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="B/xBlaIF"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y13-20020aa7d50d000000b0046a09ce4d1csi4893784edq.349.2022.12.07.18.27.18; Wed, 07 Dec 2022 18:27:36 -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=@google.com header.s=20210112 header.b="B/xBlaIF"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229756AbiLHCVu (ORCPT + 76 others); Wed, 7 Dec 2022 21:21:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbiLHCVh (ORCPT ); Wed, 7 Dec 2022 21:21:37 -0500 Received: from mail-yw1-x1132.google.com (mail-yw1-x1132.google.com [IPv6:2607:f8b0:4864:20::1132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA3737063C for ; Wed, 7 Dec 2022 18:21:36 -0800 (PST) Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-3b5d9050e48so234447b3.2 for ; Wed, 07 Dec 2022 18:21:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=aR88s3Ybl0DvsKtxthIky8N3akpynVM/kGiV7SX8Qbo=; b=B/xBlaIF+jNGf5iiBTKySZ+7r2wiB/6Xv26z88ota5t3XkT+7X3jaFadw+Q82Qq1P0 chRs2VEEEuIHVszUV9iO786js+VI5QCkZaOa7MevzcJoWFIZ57z0HhX11ZZLuJ5X14gR sr6drNTXHEhi9WRx5ZRMcB1GRSgBHLx/f4zFnwlpW/tqzcOJmZfbt9lLChFr97uz23uc A/O+w/60sZ/qChHf12ohkzNBzMwLAxUf+lrI+7EgmLTzv6iugqzCVAUpcaIuZ9uSpAer +TUeVkG4BuvM0apTeklDKZzFz+HyOsWzs8xkxWZPVI6mwkfeLH2ZQZcea/0ZKlkQBl34 b4rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=aR88s3Ybl0DvsKtxthIky8N3akpynVM/kGiV7SX8Qbo=; b=dcXA8GKVVsKffT3eDc7v1pHvl+PWpBo6zNebHSrgQX7g9nBBtBBHKpdnwgTlH+2zEj zH2e/WEg+mZAOeU+BJSozC8u7MQq9q4Jsf+qE06YNGNleGwbspb+Hsut6S1vKUYvez93 cBvgtoDLLpuubTWE+3kTATYBSxnIhQ/pkMQi2hB2ZHGXLupbbz7I0Su8YK6qGocBPLAX O/YYrQK/hmKKE7utWujUY7IG25wCyXdJ9EUu6ewO8IMzqW1ky8NpxTiblxTHV13U03yG 1VcZztoYfWX279XLE+iAEU+yepn7IORVqf1Emr6ecif+pKAuZ1hCOGJ0LK5tPwBzZtHZ ENHA== X-Gm-Message-State: ANoB5plDOTZ4q6h01jMHiRRAdA5HYhekqM8193GlJxuUiNDCGCrrB8Qi W7zDqt1UXfO11oo4fD3bUHsUcWTIz8Nt+fKJkHKkHQ== X-Received: by 2002:a81:4f46:0:b0:36c:aaa6:e571 with SMTP id d67-20020a814f46000000b0036caaa6e571mr23216066ywb.467.1670466095559; Wed, 07 Dec 2022 18:21:35 -0800 (PST) MIME-Version: 1.0 References: <20221207225435.1273226-1-lixiaoyan@google.com> In-Reply-To: <20221207225435.1273226-1-lixiaoyan@google.com> From: Eric Dumazet Date: Thu, 8 Dec 2022 03:21:24 +0100 Message-ID: Subject: Re: [PATCH net-next v5 1/2] IPv6/GRO: generic helper to remove temporary HBH/jumbo header in driver To: Coco Li Cc: "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski , Paolo Abeni , Michael Chan , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 On Wed, Dec 7, 2022 at 11:54 PM Coco Li wrote: > > 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. > > Tested: > Compiled and ran with ethtool -K eth1 tso off > Could send Big TCP packets > > Signed-off-by: Coco Li > --- > include/net/ipv6.h | 36 ++++++++++++++++++++++++++++++++++++ > net/ipv6/ip6_offload.c | 27 ++++----------------------- > 2 files changed, 40 insertions(+), 23 deletions(-) > > diff --git a/include/net/ipv6.h b/include/net/ipv6.h > index d383c895592a..6dcf93a1ec14 100644 > --- a/include/net/ipv6.h > +++ b/include/net/ipv6.h > @@ -500,6 +500,42 @@ 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; > + > + /* Remove the HBH header. > + * Layout: [Ethernet header][IPv6 header][HBH][L4 Header] > + */ > + memmove(skb_mac_header(skb) + hophdr_len, skb_mac_header(skb), > + skb_network_header(skb) - skb_mac_header(skb) + > + sizeof(struct ipv6hdr)); > + > + if (unlikely(!pskb_may_pull(skb, hophdr_len))) > + return -1; ipv6_has_hopopt_jumbo() had a stronger condition already. if (skb_network_offset(skb) + sizeof(struct ipv6hdr) + sizeof(struct hop_jumbo_hdr) > skb_headlen(skb)) return 0; So this !pskb_may_pull(skb, hophdr_len) , especially if done after the memmove(), is not needed. > + > + __skb_pull(skb, hophdr_len); > + skb->network_header += hophdr_len; > + skb->mac_header += hophdr_len; > + > + h6 = ipv6_hdr(skb); > + h6->nexthdr = nexthdr; > + > + return 0; > +} > + > static inline bool ipv6_accept_ra(struct inet6_dev *idev) > { > /* If forwarding is enabled, RA are not accepted unless the special > diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c > index 3ee345672849..00dc2e3b0184 100644 > --- a/net/ipv6/ip6_offload.c > +++ b/net/ipv6/ip6_offload.c > @@ -77,7 +77,7 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, > struct sk_buff *segs = ERR_PTR(-EINVAL); > struct ipv6hdr *ipv6h; > const struct net_offload *ops; > - int proto, nexthdr; > + int proto, err; > struct frag_hdr *fptr; > unsigned int payload_len; > u8 *prevhdr; > @@ -87,28 +87,9 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, > bool gso_partial; > > skb_reset_network_header(skb); > - nexthdr = ipv6_has_hopopt_jumbo(skb); > - if (nexthdr) { > - const int hophdr_len = sizeof(struct hop_jumbo_hdr); > - int err; > - > - err = skb_cow_head(skb, 0); > - if (err < 0) > - return ERR_PTR(err); > - > - /* remove the HBH header. > - * Layout: [Ethernet header][IPv6 header][HBH][TCP header] > - */ > - memmove(skb_mac_header(skb) + hophdr_len, > - skb_mac_header(skb), > - ETH_HLEN + sizeof(struct ipv6hdr)); > - skb->data += hophdr_len; > - skb->len -= hophdr_len; > - skb->network_header += hophdr_len; > - skb->mac_header += hophdr_len; > - ipv6h = (struct ipv6hdr *)skb->data; > - ipv6h->nexthdr = nexthdr; > - } > + err = ipv6_hopopt_jumbo_remove(skb); > + if (err) > + return ERR_PTR(err); > nhoff = skb_network_header(skb) - skb_mac_header(skb); > if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h)))) > goto out; > -- > 2.39.0.rc0.267.gcb52ba06e7-goog >