Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2854246rwd; Mon, 22 May 2023 05:28:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4oA2vphoM1hUGbR0prnBR1EJMOl1kPXkaTFBez+hALRx4Qa99qIhfKJLRDuwazGJsJQuyx X-Received: by 2002:a17:90a:6fa1:b0:255:4c74:187f with SMTP id e30-20020a17090a6fa100b002554c74187fmr4366167pjk.29.1684758501800; Mon, 22 May 2023 05:28:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684758501; cv=none; d=google.com; s=arc-20160816; b=Wo+bRIvTTznFwCoU7FDE7IDDYFRGiCXlZD3xB+yr8sCOPE16ysEEOu9o8jVwgICokC i5Bm422yzdLiIONWUlj5ztpwbxYPQ3L9bhkIytlR6wImX4C3anteKcxK1QXK6kT64Q9/ C606+AXyZ9CY9qbuHRKH0EFWnY3UYYQYTJ8Vj/PGbQKOiCMehqF2+ZgsLo2OP5OAsXi0 UAXOE2unNSB65f2vV3r1RIB7OZdQ8fQmzQXp+qbUpRFvdaWQ4KOBxYADCi8A9i3yEiag 7WoHdTnRmUWIdwTmgh7Go11TQ8ucfl6NLpYewg8+Fn4f7uMwUjQrmZJ7hrjGEQD0BYW6 UMWA== 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=ffd3YawaEPueAPXBl1MQC14SZ3eQhu85Pa0T2P1YDChOpR75bmkCMN46y06omwrq44 dh9to8Bxe9CFnyzv7km4FGyIWw5wTtxeJX9vuuTQAMZr0ChJruQzu5pdevjCtmqRXGPN vOIEEVncOTUSrbD7UZsePmA9iJmj3ETO0FoZ9NdUrKJb/fUD74UEdeiFj6cW5IRUxYOO DXxmN9RBoFZcT3iGm7tm6jcyqyBoyM0fT1Hg1HCSuUjsJNmBOtqJKLcB3QrtWMGuHqI8 HS3BraKdsl/0mRK13u0NKh3Hguwf6HySqw7dWR06zZukCS+AYISGYhLc++AAW4/FBhdw RM3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=f9MGfhu+; 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 bs186-20020a6328c3000000b0053578f3de77si176504pgb.239.2023.05.22.05.28.07; Mon, 22 May 2023 05:28:21 -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=f9MGfhu+; 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 S233763AbjEVMNb (ORCPT + 99 others); Mon, 22 May 2023 08:13:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232889AbjEVMNM (ORCPT ); Mon, 22 May 2023 08:13:12 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D29410C for ; Mon, 22 May 2023 05:12:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684757538; 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=f9MGfhu+kYRZ553CRO+KZiiRJvo9JTj5p0xr8Q8GLJMsnwVOKxCdi28aY8N4IbIqnLU79H Csh03QSQtP4XJJDuOp9mbWGMYfr3hcdi30/MJeoxHtwbZCXBY98JtCbf3tumoI9Mq8+GdW q8EIlvJRZd+n5Z5XYnLU06d/gaea6aY= 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-569-bsmo5ELVM-2TXNBTHt6zHg-1; Mon, 22 May 2023 08:12:14 -0400 X-MC-Unique: bsmo5ELVM-2TXNBTHt6zHg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8B87B85A5A8; Mon, 22 May 2023 12:12:13 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0EFBB1121314; Mon, 22 May 2023 12:12:10 +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 v10 12/16] ip6, udp6: Support MSG_SPLICE_PAGES Date: Mon, 22 May 2023 13:11:21 +0100 Message-Id: <20230522121125.2595254-13-dhowells@redhat.com> In-Reply-To: <20230522121125.2595254-1-dhowells@redhat.com> References: <20230522121125.2595254-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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=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 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;