Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp827950rwd; Thu, 18 May 2023 04:41:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5qFykZo/SEpiGNdNhOmSYI7v7XzzinxFHfg9BstcWzxH3PYPsmks3CIQUwLe03Lt+HzLTv X-Received: by 2002:a17:902:cec2:b0:1ad:c736:209a with SMTP id d2-20020a170902cec200b001adc736209amr2677861plg.56.1684410065701; Thu, 18 May 2023 04:41:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684410065; cv=none; d=google.com; s=arc-20160816; b=yNzY5oGODV0hOGirQImcKd/oep1CBUnOFZJ7myHN/Fhf7u194XPtuY+XNYJfql04P1 UqUCDlmFTx0JcVan7D1UMXMdXqimkYakBautdmn2sXnXGfFPiDPdkobUamRyjGARUt39 w+rKGSg7HRMMEsk5t6fatsa66PpMf7DXQk960cO7mJqUURvLMBV3MQAd4vOm7sYGZXsB RHLa0s4VnZ+7Fz1KMhRKLRcxugfUQJNsJFFGUJt4Ea7184yQTTtBK4KMHWQEEw5ox6fy tp0eWbLORQ31fhDIFYoSw2G0H8LS6MMv5BUh8x2w1zQA1eVj5U7eE/+w5YwCtAu480+L KQMA== 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=5dEuCyEYbAeTLbptDWG+lpG3TePaGyDY6iKA6gIr8Gk=; b=vXj7K8IXfesW1/87tEp21lxSiAVK/OHo202ZSov7izfL7IlLdc3s+z586bCFEl4sFd tVIeeQsGEkk042l88z5phxsSlvkQbGqZ+iaK6eIiYdB0QDJSXy7upWRiZlBxiB5rMUeC z4LVeSNYvUwnwnf5CtvUipHcmh50bhtF/PFnd3XVDMK0Tnm+Tw+rpRXf1USiuyRD8+Ow /miIac4lMgQGyZauVGvpZRR4uTOxv4WVX4ZTZ4LuC8LNj593lycfwYDFmPE0MJKiuEHL OhZh4Hf8amQAMBPvlTMkeOKX/a1CZS1StiVtx6s9j0i9/NKRwxMUBANfAOYxMt6pXX5E h8ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WggRO0We; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n127-20020a632785000000b0050b8a7635dfsi1224128pgn.295.2023.05.18.04.40.51; Thu, 18 May 2023 04:41:05 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=WggRO0We; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231513AbjERLhg (ORCPT + 99 others); Thu, 18 May 2023 07:37:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231440AbjERLgs (ORCPT ); Thu, 18 May 2023 07:36:48 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EABF19A3 for ; Thu, 18 May 2023 04:36:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684409759; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5dEuCyEYbAeTLbptDWG+lpG3TePaGyDY6iKA6gIr8Gk=; b=WggRO0WeP/jLRWS4qJcthCtGl5EnVDsPr7ZeDxf2eUtHCkibfunl7zHUzk3Vh5oUNbOf5I zKvpF+RjKEVz5Ytqy51sSRM8MVr5e1qgR2wW6u/+4b8VE/nMbY0Oy3EtXSq3u1OK6Rk+41 Ss0zy4q9aa/LZc7PHUS2d/5MEMPYjdU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-668-jwZ3dLuJNq-_aRCVShqxqQ-1; Thu, 18 May 2023 07:35:54 -0400 X-MC-Unique: jwZ3dLuJNq-_aRCVShqxqQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7959E86C60C; Thu, 18 May 2023 11:35:53 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D35614171C0; Thu, 18 May 2023 11:35:51 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Al Viro , Christoph Hellwig , Jens Axboe , Jeff Layton , Christian Brauner , Chuck Lever III , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH net-next v8 12/16] ip6, udp6: Support MSG_SPLICE_PAGES Date: Thu, 18 May 2023 12:34:49 +0100 Message-Id: <20230518113453.1350757-13-dhowells@redhat.com> In-Reply-To: <20230518113453.1350757-1-dhowells@redhat.com> References: <20230518113453.1350757-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Make IP6/UDP6 sendmsg() support MSG_SPLICE_PAGES. This causes pages to be spliced from the source iterator if possible, copying the data if not. This allows ->sendpage() to be replaced by something that can handle multiple multipage folios in a single transaction. Signed-off-by: David Howells cc: Willem de Bruijn cc: David Ahern cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: netdev@vger.kernel.org --- Notes: ver #6) - Use common helper. net/ipv6/ip6_output.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 9554cf46ed88..c722cb881b2d 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -1589,6 +1589,14 @@ static int __ip6_append_data(struct sock *sk, skb_zcopy_set(skb, uarg, &extra_uref); } } + } else if ((flags & MSG_SPLICE_PAGES) && length) { + if (inet_sk(sk)->hdrincl) + return -EPERM; + if (rt->dst.dev->features & NETIF_F_SG) + /* We need an empty buffer to attach stuff to */ + paged = true; + else + flags &= ~MSG_SPLICE_PAGES; } /* @@ -1778,6 +1786,15 @@ static int __ip6_append_data(struct sock *sk, err = -EFAULT; goto error; } + } else if (flags & MSG_SPLICE_PAGES) { + struct msghdr *msg = from; + + err = skb_splice_from_iter(skb, &msg->msg_iter, copy, + sk->sk_allocation); + if (err < 0) + goto error; + copy = err; + wmem_alloc_delta += copy; } else if (!zc) { int i = skb_shinfo(skb)->nr_frags;