From patchwork Tue Oct 24 02:35:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhai X-Patchwork-Id: 157231 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1677464vqx; Mon, 23 Oct 2023 19:36:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFYsX93WJBMyuHx8o4Y8ivuF14rzAjLssCMYdvoYyFBbwYe9Wow787r74NRsKFhjDwY/5zf X-Received: by 2002:a17:90a:183:b0:27f:bd9e:5a15 with SMTP id 3-20020a17090a018300b0027fbd9e5a15mr2534789pjc.28.1698115007884; Mon, 23 Oct 2023 19:36:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698115007; cv=none; d=google.com; s=arc-20160816; b=V7KZluwl2BPTicIWmOZdKvguchxz40Hm1itMC7h0pct5+uh5V8lW4mM1tMf02VIZ4f Dx2893D59mQxVxytlMi1/qTcy1Y4gJMOz4VJuWIpAmz4XkzWKy89tFofCZqu9gNycZ2y q3TRAog5MzzXScjzBhY16tpCDIFOxYeRVFmzxWR0TBOk4neU9+ES+9+JiQ+ZH6W6J7yy KoTAPfeGeEJ+kosVdB6ImzD0S7HHEpZp/DJNZGZK6M0RCGUNxK0iPIkwqOPaKPj9yTtz lMG80xvznj9dG6FO7CrJbeSV6rqzRRFD34PJE6cG4zA9+YL2tR9KcsMDztkzz6XfwPE4 08Fg== 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=TkoH9W9AE3pJVfRR9dnIbF7cHA+qXZ0zJZUVKChcfwyUfMm8nENIVGKi5tVRdHTaoc 4RuDMheq5VLyj5Cw3IlN+JnPlezyk5z3MOV/1VKwnIpWQ+F10idkWhR1XL5k0b5ZwdFK p5V7Ru8Beskiy/71oy23DnUmZGkTABWOh8gV91tgT/E3EJWZYSvcuC2Titt8SWY9GWjp GSti2UvQd42ncvpPD7d7ElbiV/VNTk5fqYZyLZLGLcZah5pTFQe+tjxvBYFOfPUUtoCW UQ43f4g5DqQXhzRbJ4ZManrCB0nWuFkqZGzhOMl0XVXNLqxDUrLZHiawASYT6NKCfH6c s7Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=ZgPXYpxW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id w4-20020a17090abc0400b0027d82c2b020si7597030pjr.88.2023.10.23.19.36.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 19:36:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=ZgPXYpxW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 5A9D78051913; Mon, 23 Oct 2023 19:36:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232156AbjJXCft (ORCPT + 27 others); Mon, 23 Oct 2023 22:35:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232103AbjJXCfo (ORCPT ); Mon, 23 Oct 2023 22:35:44 -0400 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6854510D4 for ; Mon, 23 Oct 2023 19:35:38 -0700 (PDT) Received: by mail-qv1-xf2b.google.com with SMTP id 6a1803df08f44-66d190a8f87so25334466d6.0 for ; Mon, 23 Oct 2023 19:35:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1698114937; x=1698719737; 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=ZgPXYpxWibYgwNLYUFrWHe7A825rT5FTXIi3PBQql3SiaZVJCVQ+VgFmP2vpSzA2ry gpb01jcgA4QCfPbOm25cYE62fq1SPXDNLv/qiqjv3bn4oFu4W1Qga/PQ8hF11khbcd7h 48sK2vm6tVPPgsLmQy/kkt39ZwK2c5Jwm+vzA9fEH52245eC9Oz8C9N0hmH+M5MyMFuX g8qHZzwpUFqBqZ8kKKfd4quZ/Tl7vat76J8IjsOyY40tozL4gaRz/YfnbW+dcjEPEV4o 9m6VESPn/PekhvERmayft5i0rh5ZdGGmVwn2VmQVbRic7FUzotqLB+W5ex6iDnAQtcdj GfBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698114937; x=1698719737; 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=MK1jM6FtvLxx0PvzXO8HmLmE0nob8oHMOEtetQr9cgKiHnxBX1ruYDroSU8U0pjeZt N0Y/OtETHXki2RHmnpvWo4qYdrA2x8lFTwn5tQkwzelC8HOYgrzQ8JZK4WAZLWV9G+qk 1T5newDsvua8uzAXKNwXByitL+8dzrUnUj4UbX+7717HG6rDBmjz/8lP4CXlhsPS0cQp RVz0j716N/ptPXPOthKpWmrPU2Obvx4a4zxOKamQrlO9GuL6htbkqYaPWh0xBuZTskqW 3vsRHMUR5Whuq2VUzVyxgEztjtQ/WJuWVYcGNo6wnVUC2mYqyZW1nR348kcdLJSlcObm 7/uA== X-Gm-Message-State: AOJu0Yy3zQKbPPwJlYgsb3JEgkarNGH98gSQvjvb9ja3C3o/zW6MxufW WDyL7USiYa1kWL7zcwU8SGbGTA== X-Received: by 2002:a05:6214:27eb:b0:65a:fc6a:1423 with SMTP id jt11-20020a05621427eb00b0065afc6a1423mr15754968qvb.17.1698114937549; Mon, 23 Oct 2023 19:35:37 -0700 (PDT) Received: from debian.debian ([140.141.197.139]) by smtp.gmail.com with ESMTPSA id d11-20020a05620a140b00b00767d4a3f4d9sm3153295qkj.29.2023.10.23.19.35.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 19:35:37 -0700 (PDT) Date: Mon, 23 Oct 2023 19:35:35 -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 v4 net-next 2/3] ipv6: refactor ip6_finish_output for GSO handling Message-ID: <489a6b97c123700de4d28df86a95e79471cfe12b.1698114636.git.yan@cloudflare.com> References: MIME-Version: 1.0 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 fry.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 (fry.vger.email [0.0.0.0]); Mon, 23 Oct 2023 19:36:41 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780602642106051607 X-GMAIL-MSGID: 1780602642106051607 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)