From owner-dev-commits-src-branches@freebsd.org Fri Feb 26 00:36:42 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6E20A54F9B5; Fri, 26 Feb 2021 00:36:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DmrLy2K4Nz4TXT; Fri, 26 Feb 2021 00:36:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3891D2127F; Fri, 26 Feb 2021 00:36:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11Q0aggZ072285; Fri, 26 Feb 2021 00:36:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11Q0agkb072284; Fri, 26 Feb 2021 00:36:42 GMT (envelope-from git) Date: Fri, 26 Feb 2021 00:36:42 GMT Message-Id: <202102260036.11Q0agkb072284@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 63241a0764c9 - stable/13 - Handle partial data re-sending on ktls/sendfile on FreeBSD MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 63241a0764c9414e1bcce3bcb05bfbdba8f1f487 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Feb 2021 00:36:42 -0000 The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=63241a0764c9414e1bcce3bcb05bfbdba8f1f487 commit 63241a0764c9414e1bcce3bcb05bfbdba8f1f487 Author: Oleksandr Tymoshenko AuthorDate: 2021-02-17 22:49:30 +0000 Commit: John Baldwin CommitDate: 2021-02-25 22:45:41 +0000 Handle partial data re-sending on ktls/sendfile on FreeBSD Add a handler for EBUSY sendfile error in addition to EAGAIN. With EBUSY returned the data still can be partially sent and user code has to be notified about it, otherwise it may try to send data multiple times. PR: 251969 Obtained from: OpenSSL (dfcfd17f2818cf520ce6381aed9ec3d2fc12170d) Sponsored by: Netflix (merging to FreeBSD) (cherry picked from commit 9b2f020c14af71a2606012143432dd717c7cf90e) --- crypto/openssl/doc/man3/SSL_write.pod | 3 ++- crypto/openssl/include/internal/ktls.h | 9 +++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/crypto/openssl/doc/man3/SSL_write.pod b/crypto/openssl/doc/man3/SSL_write.pod index 20c7953deb06..9b271d8e65a2 100644 --- a/crypto/openssl/doc/man3/SSL_write.pod +++ b/crypto/openssl/doc/man3/SSL_write.pod @@ -120,7 +120,8 @@ For SSL_sendfile(), the following return values can occur: =item Z<>>= 0 The write operation was successful, the return value is the number -of bytes of the file written to the TLS/SSL connection. +of bytes of the file written to the TLS/SSL connection. The return +value can be less than B for a partial write. =item E 0 diff --git a/crypto/openssl/include/internal/ktls.h b/crypto/openssl/include/internal/ktls.h index 9032c0ed6174..622d7be76d1e 100644 --- a/crypto/openssl/include/internal/ktls.h +++ b/crypto/openssl/include/internal/ktls.h @@ -192,15 +192,12 @@ static ossl_inline int ktls_read_record(int fd, void *data, size_t length) static ossl_inline ossl_ssize_t ktls_sendfile(int s, int fd, off_t off, size_t size, int flags) { - off_t sbytes; + off_t sbytes = 0; int ret; ret = sendfile(fd, s, off, size, NULL, &sbytes, flags); - if (ret == -1) { - if (errno == EAGAIN && sbytes != 0) - return sbytes; - return -1; - } + if (ret == -1 && sbytes == 0) + return -1; return sbytes; }