From patchwork Wed Jun 7 14:05:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13270804 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A04AC7EE25 for ; Wed, 7 Jun 2023 14:41:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 155608E0003; Wed, 7 Jun 2023 10:41:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DF5B8E0001; Wed, 7 Jun 2023 10:41:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9B7B8E0003; Wed, 7 Jun 2023 10:41:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D59D48E0001 for ; Wed, 7 Jun 2023 10:41:40 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 53B26AED2D for ; Wed, 7 Jun 2023 14:41:40 +0000 (UTC) X-FDA: 80876215560.06.1763C4D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 506F418000D for ; Wed, 7 Jun 2023 14:41:38 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ggvvRXV0; spf=pass (imf06.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686148898; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=axbQ2fmWT7oadEpv+RKPywBYD27/saJPi8A/5AZqeFc=; b=62QzR9aZi8EDo5tKD3foI30uBFIl44m7xGtXRELSql0gIKeMQFeNIV2tJCNKTlaL2AGAZz c1xmSx4ajmToTOBCi0Ljd7NDn9viPmD3yOu6WlA0IjWwIYwjLS37f4yscVsdnBffQ3AFIQ yeFem1LguLu6/q9X7XQgkUlYsYYQyTc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686148898; a=rsa-sha256; cv=none; b=Mgbedo5h7WtclKOUk0B/zum3jeSP28WFr2iQaN4hEHeduX72HtiNopX5azG2yGFL9vsNHo 4EA9SaqjpFW5e/t+X25dzHUWc+TTzEqSWtiG/Evg06bLdLPpU3U6uljwG8BZ9WGiaKnMli CSjTXQ05+FtXX1ZmCkEEYKUfoAIJceQ= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ggvvRXV0; spf=pass (imf06.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686148897; 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=axbQ2fmWT7oadEpv+RKPywBYD27/saJPi8A/5AZqeFc=; b=ggvvRXV0g5zfkv2ScHvyLqQcYBEBE+IO7FM3x+z1PIXueWOjG9M4zkW15z3FP2keY4Y5wZ x7Tw/tAOz/cwsupe864qtNCaxOYdmS9pGSTefa8YNrxdthPBoSn5u31fIgKlqY39terj+/ +jhbaFUnnoQxOTfd00eTOrS4yEywOrk= 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-135-O41qDC5EPpCAaVWMZOdERQ-1; Wed, 07 Jun 2023 10:06:42 -0400 X-MC-Unique: O41qDC5EPpCAaVWMZOdERQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6EF1E1C02D26; Wed, 7 Jun 2023 14:06:38 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5062403367; Wed, 7 Jun 2023 14:06:34 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org, Linus Torvalds Cc: David Howells , Chuck Lever , Boris Pismenny , John Fastabend , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ayush Sawal Subject: [PATCH net-next v5 08/14] chelsio/chtls: Use splice_eof() to flush Date: Wed, 7 Jun 2023 15:05:53 +0100 Message-ID: <20230607140559.2263470-9-dhowells@redhat.com> In-Reply-To: <20230607140559.2263470-1-dhowells@redhat.com> References: <20230607140559.2263470-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspamd-Queue-Id: 506F418000D X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: a6dbmp7fup5o3537e4h534ska1auerwu X-HE-Tag: 1686148898-714306 X-HE-Meta: U2FsdGVkX19r/2pY0va6oOA0gwLNN6yaxuObML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Vf0TlHdHFFzgDSprxCE7UEp+vOfZ9OlKiMmJQoINAMzcoSoY3nkainPH7xQud5G94u+4NOIlLv2Hg+4UKT78g6PzuqNV+UuPAUg3ZFH3yEykrw5gt4gDIjwptcKPHmlnBjOVE/WdctYaNj+7J/DeWkVM00qB2KE7E+UJ+qi2xomWW7tImJe4jZ8nnODK4siatTxjkug46eKF7bPwjQrSYnP7jrffAzlu+4ldMDIzlaYf85O9HJybiGBhHuxw/ABtTUm7Uc/ivL6tNlmPHCcXD03jLcGCQPZiB2OAYBN1REEazGNv9R61slLMNrl9upqNwWW8bGpXBcQoYWBC/rVEzwFYesimSmxk6CbH6Ilo2Ekq5C9d6Ij5Qi6gtipft7nIPo/u+6/em33Zjr/VAl+WitCcs1Yd0iPK040jy0SOZgsnDNf+QRiAYlVtdGUSx9gR4EAPpJ8eu5gU3pIGqU2TnZbO7obXl9cMlGVVSr9mbypeTKra9oBH7uODyh3tiOWBQQ4LTJHNqGE X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Allow splice to end a Chelsio TLS record after prematurely ending a splice/sendfile due to getting an EOF condition (->splice_read() returned 0) after splice had called sendmsg() with MSG_MORE set when the user didn't set MSG_MORE. Suggested-by: Linus Torvalds Link: https://lore.kernel.org/r/CAHk-=wh=V579PDYvkpnTobCLGczbgxpMgGmmhqiTyE34Cpi5Gg@mail.gmail.com/ Signed-off-by: David Howells cc: Ayush Sawal cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: netdev@vger.kernel.org --- drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls.h | 1 + .../net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c | 9 +++++++++ .../ethernet/chelsio/inline_crypto/chtls/chtls_main.c | 1 + 3 files changed, 11 insertions(+) diff --git a/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls.h b/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls.h index 41714203ace8..da4818d2c856 100644 --- a/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls.h +++ b/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls.h @@ -568,6 +568,7 @@ void chtls_destroy_sock(struct sock *sk); int chtls_sendmsg(struct sock *sk, struct msghdr *msg, size_t size); int chtls_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int flags, int *addr_len); +void chtls_splice_eof(struct socket *sock); int chtls_sendpage(struct sock *sk, struct page *page, int offset, size_t size, int flags); int send_tx_flowc_wr(struct sock *sk, int compl, diff --git a/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c b/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c index 5724bbbb6ee0..e08ac960c967 100644 --- a/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c +++ b/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c @@ -1237,6 +1237,15 @@ int chtls_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) goto done; } +void chtls_splice_eof(struct socket *sock) +{ + struct sock *sk = sock->sk; + + lock_sock(sk); + chtls_tcp_push(sk, 0); + release_sock(sk); +} + int chtls_sendpage(struct sock *sk, struct page *page, int offset, size_t size, int flags) { diff --git a/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_main.c b/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_main.c index 1e55b12fee51..6b6787eafd2f 100644 --- a/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_main.c +++ b/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_main.c @@ -606,6 +606,7 @@ static void __init chtls_init_ulp_ops(void) chtls_cpl_prot.destroy = chtls_destroy_sock; chtls_cpl_prot.shutdown = chtls_shutdown; chtls_cpl_prot.sendmsg = chtls_sendmsg; + chtls_cpl_prot.splice_eof = chtls_splice_eof; chtls_cpl_prot.sendpage = chtls_sendpage; chtls_cpl_prot.recvmsg = chtls_recvmsg; chtls_cpl_prot.setsockopt = chtls_setsockopt;