Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1926194rda; Tue, 24 Oct 2023 07:27:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEkpqeIinvRJpoQ4UezF48Vc0tslcjSE8jIljul78tSF+ISXqJslmDqsm9gFxYIqc2+k//R X-Received: by 2002:a17:902:c653:b0:1c5:f0fd:51b5 with SMTP id s19-20020a170902c65300b001c5f0fd51b5mr10651772pls.40.1698157625811; Tue, 24 Oct 2023 07:27:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698157625; cv=none; d=google.com; s=arc-20160816; b=C/drK59gYAlI2wrhN/kHDDDxyWCQ58hUAnIjHltyDtcyRO1ADfXdvQTUeBesW3AdBe U63KH74drMjSqil9vJpqJeFSLyQmdu753VdAO+NFsCZfWHCeul10mnIXVhNkG5mwXhkU NGzBcAcD+6zW6pflH0dybtFD4HYZr/QDFVnRhGBl7aUxy606TvwoFawYQdzRhkDaKye4 5tYwB0N9W1xwo6kGde6kBfiNqjUjOwi7/ePLe25DjgTMci4OwE4ssfRfO+D6ZWkKUn0s 8QZ2FjrkTfS+5v+QrKzoyWvXA3bZO6DBKf+rxkiI9xOgJ3tF/cSiOzLhwNQ1shvW4hQy gBkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ANWtBi2MdCaxrrm0KgoW1Ul1Iz1M5CJm2G0yJPXRo30=; fh=pcqFZQYW2ZOvrJzL6iYbdBSsYjMBR+cDRZVlzaRzt/k=; b=oMsxBR8j/sntsMyBMVFigW0I+f4fP5OpEaXDGdbIqpScFPOw8JeJRVs0+OiBJNN2lH u3u0UcrpF1EThrlx/in+rLbrqwz1azcMQYxSP1czSREMagw00CvA5x51+aaS1zmKKgX1 gX35iqh30gECV5lNhAB4oAjs4s2UMmQxp7BWFWGe4N2Wf8N3WPA2Tq9CISx+NuDKBVex 4K7FnIIAIx9t7pLFntcQ/uryHONadI2Uy+9OGUR7IWv47973/HAxtYjcGLnYqCWmpZkS I0eWpp1Am5swpKYAQyO199cgu3cB1LRLhvrDLxTurmyfHQzGnR4mzDNCUR0tXbwKybkM LV1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=OrnhSMSd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id lx18-20020a17090b4b1200b0027d702ca321si10075076pjb.124.2023.10.24.07.27.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 07:27:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=OrnhSMSd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 921C6803FC2C; Tue, 24 Oct 2023 07:27:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343773AbjJXO0p (ORCPT + 99 others); Tue, 24 Oct 2023 10:26:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343524AbjJXO0n (ORCPT ); Tue, 24 Oct 2023 10:26:43 -0400 Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DD49129 for ; Tue, 24 Oct 2023 07:26:41 -0700 (PDT) Received: by mail-oi1-x22c.google.com with SMTP id 5614622812f47-3b2f4a5ccebso3062702b6e.3 for ; Tue, 24 Oct 2023 07:26:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1698157600; x=1698762400; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ANWtBi2MdCaxrrm0KgoW1Ul1Iz1M5CJm2G0yJPXRo30=; b=OrnhSMSdnKPjUG1TT6wTvS5HRvmsZ9hWsPtUMTg6VK65BsAxIb3Gkks1OcNzP2K+ow qtXqofVsB40pAhadA03cDCKXbiwzsCt8d0OuZKJsjYArGw9/WfRJFCmqcVzXpzu4f3xl g5hXAEnhPe0ZuM7a9KTP784W8jISd0D0zAIETr4g4j1IcvirURdEhbCbVlTT+xJbhzM6 KeZ2WlSHSftRzEN4HsFKWn94vcifxduJT8Kb6AQA80ReNl9Zmcfaxt1+fH3Z7Za8gOht q4MkavJpxMktMppkz+okCLpkSkO+LIw7uMt5i0s88ZKFLTLAioEp3u34B/XBWIwWWrA7 ZcIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698157600; x=1698762400; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ANWtBi2MdCaxrrm0KgoW1Ul1Iz1M5CJm2G0yJPXRo30=; b=I7FAlfcxf1vpdR1wh82QRJRpnH9mQHFxD/xu/G/rUQIg8lwbPbpoJcbb8zwqnrh0hg KCEWN8hKCuZQrG4lAiHnxKg909l1FQijs0wxUyehnOhVoakml0ucruw2Euy9TDJXh01a JCnculg4i6f+3haNmIVhuaX5MomEJZCSo/rCxZjpEteiSr6KuVZX8jt8E09T6Nfa7kUS M+o/uqp9a6msaE7bF7P3A86yL5SDElHVl3KlgMxJdQdcZueGHG2j0tG136/5n4/S+0BD 8ymRmZEAx4Co6fD5ggBoiztlTM/dD1PbrdJw4XHcTx1UrkTVtX8XRGJUhXQRVYHR+nqG Dhew== X-Gm-Message-State: AOJu0YwwlIftCLZ7b79R0rG8+fJxltJAVivDLzBYVdNiW2DrNuptDVup wngIv2E8hqsODLd+RiNyTk49Fw== X-Received: by 2002:a05:6870:7e0d:b0:1ea:29cc:d2dc with SMTP id wx13-20020a0568707e0d00b001ea29ccd2dcmr15920283oab.11.1698157600641; Tue, 24 Oct 2023 07:26:40 -0700 (PDT) Received: from debian.debian ([140.141.197.139]) by smtp.gmail.com with ESMTPSA id kr25-20020ac861d9000000b004181c32dcc3sm3487025qtb.16.2023.10.24.07.26.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 07:26:40 -0700 (PDT) Date: Tue, 24 Oct 2023 07:26:37 -0700 From: Yan Zhai To: netdev@vger.kernel.org Cc: "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Aya Levin , Tariq Toukan , linux-kernel@vger.kernel.org, kernel-team@cloudflare.com, Florian Westphal , Willem de Bruijn , Alexander H Duyck Subject: [PATCH v5 net-next 2/3] ipv6: refactor ip6_finish_output for GSO handling Message-ID: <0e1d4599f858e2becff5c4fe0b5f843236bc3fe8.1698156966.git.yan@cloudflare.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 24 Oct 2023 07:27:02 -0700 (PDT) Separate GSO and non-GSO packets handling to make the logic cleaner. For GSO packets, frag_max_size check can be omitted because it is only useful for packets defragmented by netfilter hooks. Both local output and GRO logic won't produce GSO packets when defragment is needed. This also mirrors what IPv4 side code is doing. Suggested-by: Florian Westphal Signed-off-by: Yan Zhai Reviewed-by: Willem de Bruijn --- net/ipv6/ip6_output.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 86efd901ee5a..4010dd97aaf8 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -172,6 +172,16 @@ ip6_finish_output_gso_slowpath_drop(struct net *net, struct sock *sk, return ret; } +static int ip6_finish_output_gso(struct net *net, struct sock *sk, + struct sk_buff *skb, unsigned int mtu) +{ + if (!(IP6CB(skb)->flags & IP6SKB_FAKEJUMBO) && + !skb_gso_validate_network_len(skb, mtu)) + return ip6_finish_output_gso_slowpath_drop(net, sk, skb, mtu); + + return ip6_finish_output2(net, sk, skb); +} + static int __ip6_finish_output(struct net *net, struct sock *sk, struct sk_buff *skb) { unsigned int mtu; @@ -185,16 +195,14 @@ static int __ip6_finish_output(struct net *net, struct sock *sk, struct sk_buff #endif mtu = ip6_skb_dst_mtu(skb); - if (skb_is_gso(skb) && - !(IP6CB(skb)->flags & IP6SKB_FAKEJUMBO) && - !skb_gso_validate_network_len(skb, mtu)) - return ip6_finish_output_gso_slowpath_drop(net, sk, skb, mtu); + if (skb_is_gso(skb)) + return ip6_finish_output_gso(net, sk, skb, mtu); - if ((skb->len > mtu && !skb_is_gso(skb)) || + if (skb->len > mtu || (IP6CB(skb)->frag_max_size && skb->len > IP6CB(skb)->frag_max_size)) return ip6_fragment(net, sk, skb, ip6_finish_output2); - else - return ip6_finish_output2(net, sk, skb); + + return ip6_finish_output2(net, sk, skb); } static int ip6_finish_output(struct net *net, struct sock *sk, struct sk_buff *skb) -- 2.30.2