Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5731580rwl; Tue, 11 Apr 2023 09:12:25 -0700 (PDT) X-Google-Smtp-Source: AKy350aRwy5dwUsPMUX6XhbbauwimEKPXmchoAqHUK1MYaVYT63WuEbYOUDQPtXOtjV7R9Ra3b8v X-Received: by 2002:a17:902:fb44:b0:1a5:d0:740c with SMTP id lf4-20020a170902fb4400b001a500d0740cmr3443243plb.46.1681229545563; Tue, 11 Apr 2023 09:12:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681229545; cv=none; d=google.com; s=arc-20160816; b=Fs7CnM90PIqKvVpFu0+Eaxy3psqDqmE95cdIiUGwbXL1KVYLs4DL6mMAzNLQi4rW49 dR04mGq69vmRnfwmzcnxoTWHTLE1UsOuEECsNnkFvA3w1LnqkOcHAnwEZGqBqwa30Whb FZpQqLP4yq1VHyxnLk01M92JG49jY4ZjsLtgcna4v1q1I+QviTRH13VhPSgNdyB/5Xhf btFsajJIA+l1ZuSZ6V6HuhtEsyHYZsNeGg5p3eO5SP/Hc/mLWwY8sgsQnYEWUfzBS/Uv 25hLUGEmDCaEWT21AjHc3CaLasYhG6n7OLIzkYpd7BCn/aB8iUfctL5bJrzJEG1OpJYN IaFA== 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=yN2nDE+ENFPKsoCAxX3Et3Pc/YScpeBgJ5SXmU8JiBg=; b=0serbErx17T0v3Q74zOmez5dD/ehgwthtBUPQGJ4CXiQxHEO5ZYOlLeGim1FkaofpN m7tkEK7rlgunB6yN5i/6Vr2pkPBPB/x65eUssL+r5YK3IcEI/HpN1gTkcqul5qcdVsFd GFGGTa202kMUQiNhAZyKuR1o3hQueaKPw5TplfmU7Pj8FLUqIySzlOBDLAls1ovH62OB a68AEJICLqEiOKMz5sbbbWL07p5a/8Ok66T4jruwLmzsKedOeT1J4vWENakaxTW2gQRA kKxa3mKCU71mMdc8SKzSc9bZHFUDFwu7qYC20+PuoHV7kfMDBqdyClsgFM8pXQPGUaEe eweg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Xv+czgsg; 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 y3-20020a1709027c8300b001a6458c9f96si4506132pll.37.2023.04.11.09.12.13; Tue, 11 Apr 2023 09:12:25 -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=Xv+czgsg; 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 S229906AbjDKQKq (ORCPT + 99 others); Tue, 11 Apr 2023 12:10:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229709AbjDKQKp (ORCPT ); Tue, 11 Apr 2023 12:10:45 -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 8893A40DB for ; Tue, 11 Apr 2023 09:09:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681229371; 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=yN2nDE+ENFPKsoCAxX3Et3Pc/YScpeBgJ5SXmU8JiBg=; b=Xv+czgsgiGtLcemamu76MdGSs61WY3oGlnA6RpPI5V7HUVM7oqUPJvDWJ5BLb7ibWnBYoj kPNU9wL+ZZs20ieMbZmBpXLbipyblfspOsGaAi2/LfG79mYtPwNSy74nUsXf5y1WBWqOa/ B5MMMuNMAxAYVD671pYBl9nzMdeZGhI= 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-673-JgBL6_p-OsWYijzjp0KjTQ-1; Tue, 11 Apr 2023 12:09:27 -0400 X-MC-Unique: JgBL6_p-OsWYijzjp0KjTQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3E43A185A7AC; Tue, 11 Apr 2023 16:09:26 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2233A40BC797; Tue, 11 Apr 2023 16:09:24 +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 05/18] net: Pass max frags into skb_append_pagefrags() Date: Tue, 11 Apr 2023 17:08:49 +0100 Message-Id: <20230411160902.4134381-6-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.2 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 Pass the maximum number of fragments into skb_append_pagefrags() rather than using MAX_SKB_FRAGS so that it can be used from code that wants to specify sysctl_max_skb_frags. Signed-off-by: David Howells cc: Eric Dumazet cc: "David S. Miller" cc: David Ahern cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: netdev@vger.kernel.org --- include/linux/skbuff.h | 2 +- net/core/skbuff.c | 4 ++-- net/ipv4/ip_output.c | 3 ++- net/unix/af_unix.c | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 82511b2f61ea..6e508274d2a5 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1364,7 +1364,7 @@ static inline int skb_pad(struct sk_buff *skb, int pad) #define dev_kfree_skb(a) consume_skb(a) int skb_append_pagefrags(struct sk_buff *skb, struct page *page, - int offset, size_t size); + int offset, size_t size, size_t max_frags); struct skb_seq_state { __u32 lower_offset; diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 3d05ed64b606..d96175f58ca4 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -4132,13 +4132,13 @@ unsigned int skb_find_text(struct sk_buff *skb, unsigned int from, EXPORT_SYMBOL(skb_find_text); int skb_append_pagefrags(struct sk_buff *skb, struct page *page, - int offset, size_t size) + int offset, size_t size, size_t max_frags) { int i = skb_shinfo(skb)->nr_frags; if (skb_can_coalesce(skb, i, page, offset)) { skb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], size); - } else if (i < MAX_SKB_FRAGS) { + } else if (i < max_frags) { skb_zcopy_downgrade_managed(skb); get_page(page); skb_fill_page_desc_noacc(skb, i, page, offset, size); diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 22a90a9392eb..bd002222cf2d 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -1450,7 +1450,8 @@ ssize_t ip_append_page(struct sock *sk, struct flowi4 *fl4, struct page *page, if (len > size) len = size; - if (skb_append_pagefrags(skb, page, offset, len)) { + if (skb_append_pagefrags(skb, page, offset, len, + MAX_SKB_FRAGS)) { err = -EMSGSIZE; goto error; } diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index fb31e8a4409e..ea45dcc80232 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -2349,7 +2349,7 @@ static ssize_t unix_stream_sendpage(struct socket *socket, struct page *page, newskb = NULL; } - if (skb_append_pagefrags(skb, page, offset, size)) { + if (skb_append_pagefrags(skb, page, offset, size, MAX_SKB_FRAGS)) { tail = skb; goto alloc_skb; }