git: 974504783922 - releng/13.0 - Handle partial data re-sending on ktls/sendfile on FreeBSD

John Baldwin jhb at FreeBSD.org
Fri Feb 26 21:36:11 UTC 2021


The branch releng/13.0 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=9745047839225ede45594ae4ec2b26df6bafbd22

commit 9745047839225ede45594ae4ec2b26df6bafbd22
Author:     Oleksandr Tymoshenko <gonzo at FreeBSD.org>
AuthorDate: 2021-02-17 22:49:30 +0000
Commit:     John Baldwin <jhb at FreeBSD.org>
CommitDate: 2021-02-26 21:35:05 +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
    Approved by:    re (gjb)
    Obtained from:  OpenSSL (dfcfd17f2818cf520ce6381aed9ec3d2fc12170d)
    Sponsored by:   Netflix (merging to FreeBSD)
    
    (cherry picked from commit 9b2f020c14af71a2606012143432dd717c7cf90e)
    (cherry picked from commit 63241a0764c9414e1bcce3bcb05bfbdba8f1f487)
---
 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<size> for a partial write.
 
 =item E<lt> 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;
 }
 


More information about the dev-commits-src-all mailing list