Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5732581rwl; Tue, 11 Apr 2023 09:13:05 -0700 (PDT) X-Google-Smtp-Source: AKy350ZTn0/BC4oZE2/GYabo4IHvJd7kAY2z2+6EEaQki2cg2fqPb+jRmttswZD67aLUmgQkHzpN X-Received: by 2002:a17:902:e552:b0:1a1:c3eb:af7 with SMTP id n18-20020a170902e55200b001a1c3eb0af7mr18206602plf.55.1681229585533; Tue, 11 Apr 2023 09:13:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681229585; cv=none; d=google.com; s=arc-20160816; b=s/EIFsTQVNO/aSdeBujGVjGQ1aTa7+NZMZqR3FPLwI9Hhzdi7F9oJgBtHxD0qQwq5M B5pm19HyIDZcZHwAnkKh/3pceYrkJSHLk6Fs24zCPvVRRoVA5LvTBR5SvU5a1JusEeN1 xjeFIpq+/o4YyeOFTw3NpxS+xha3+lRW1T8BHEzhcrbAkNBb9zLOkh8vuVLjd33PG+np y8ZLpHVLyjf2emZ2oRu9BHB9YaKlX9r8EBzp6p6R9YsreVLPHZqxrn/7S1sbH3FWGe2V FDm+YA00/MC4/D8bgYqWFWsoEiP+A4N5Kl1yni1+eHwlJacWdqilq0F1lhti9qh1IoAv faxg== 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=TEhCbtxSk4TMLvu3MRYCcpyvU5YZgAJ2W7fFU6gbWbo=; b=RXNMpFvKzya2f+rpytR+swH/YHXdiZAvNeDWvWs/bXX69/uFp4jRLWvV9I40TuNZsC Q3nGZkhybxn8rammOHlHHJfwdXxDH75HyZFdEad+eUadFaHxp0x8rdu0TE/BgQLDO9bu 1hRnk9sOxsTNuPJTFA45r4poz8op1m6LtQPe6zJBancJJCdIB0eGEyAHgn9aSbhjWMJv E/LaZE4ZIi57Xs624AXEFv/zKniLB2ng+TrZWwHYTX/xUu6JcOXY+/6lPhkRBB5ZhuaJ uYIp24Lpj9yxENetQjhxKjCRqoDcP3K9/QgWWUnKfQ2N2Hp1BAojlyYfxEw6aSTkhvVa gzbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jDogx6jL; 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 f18-20020a170902ce9200b001a043389a7asi14203310plg.310.2023.04.11.09.12.52; Tue, 11 Apr 2023 09:13: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=jDogx6jL; 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 S230388AbjDKQMY (ORCPT + 99 others); Tue, 11 Apr 2023 12:12:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230445AbjDKQL3 (ORCPT ); Tue, 11 Apr 2023 12:11:29 -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 3207F2D53 for ; Tue, 11 Apr 2023 09:10:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681229400; 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=TEhCbtxSk4TMLvu3MRYCcpyvU5YZgAJ2W7fFU6gbWbo=; b=jDogx6jLrYmnikRKHODKH31/xuW1J6Pce6xbYd/QySlQk08qQgacPuqbrsBex+WZwnMXio DvcAIBsFTnkcwkBDFW2uh+1nmW8zGeJCJl/GGZrEX+8ofqjIQQY6hMvGBwxJAIMQI30p2c KcvvJwQrg91Zi+ucd2UxSOYAC2af2jA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-260-nNzlZ67MPNC336uggXNYTg-1; Tue, 11 Apr 2023 12:09:56 -0400 X-MC-Unique: nNzlZ67MPNC336uggXNYTg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BE0ED2807D62; Tue, 11 Apr 2023 16:09:55 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2A98C15BB8; Tue, 11 Apr 2023 16:09:53 +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 v6 15/18] ip6, udp6: Support MSG_SPLICE_PAGES Date: Tue, 11 Apr 2023 17:08:59 +0100 Message-Id: <20230411160902.4134381-16-dhowells@redhat.com> In-Reply-To: <20230411160902.4134381-1-dhowells@redhat.com> References: <20230411160902.4134381-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Spam-Status: No, score=-0.2 required=5.0 tests=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 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 0b6140f0179d..4709abee5966 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;