summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorBoris Pismenny <borisp@mellanox.com>2019-04-11 16:24:42 +0300
committerMatt Caswell <matt@openssl.org>2019-05-07 14:24:16 +0100
commit72fb59c72186c327e047cd29d8a66a4a323b9f3b (patch)
tree1f462b8ca55b2e96dfadf9bf6808b9f38f449592 /include
parent260a16f33682a819414fcba6161708a5e6bdff50 (diff)
Linux ktls sendfile
This commit introduces support for Linux KTLS sendfile. Sendfile semantics require the use of a kernel TLS socket to construct the TLS record headers, encrypt and authenticate the data. KTLS sendfile improves performance by avoiding the copy of file data into user space, which is required today. Signed-off-by: Boris Pismenny <borisp@mellanox.com> Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/8727)
Diffstat (limited to 'include')
-rw-r--r--include/internal/ktls.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/internal/ktls.h b/include/internal/ktls.h
index d7bd1f3b66..9f2af1200c 100644
--- a/include/internal/ktls.h
+++ b/include/internal/ktls.h
@@ -73,8 +73,14 @@ static ossl_inline int ktls_read_record(int fd, void *data, size_t length)
return -1;
}
+static ossl_inline ossl_ssize_t ktls_sendfile(int s, int fd, off_t off, size_t size, int flags)
+{
+ return -1;
+}
+
# else /* KERNEL_VERSION */
+# include <sys/sendfile.h>
# include <netinet/tcp.h>
# include <linux/tls.h>
# include <linux/socket.h>
@@ -158,6 +164,15 @@ static ossl_inline int ktls_send_ctrl_message(int fd, unsigned char record_type,
return sendmsg(fd, &msg, 0);
}
+/*
+ * KTLS enables the sendfile system call to send data from a file over TLS.
+ * @flags are ignored on Linux. (placeholder for FreeBSD sendfile)
+ * */
+static ossl_inline ossl_ssize_t ktls_sendfile(int s, int fd, off_t off, size_t size, int flags)
+{
+ return sendfile(s, fd, &off, size);
+}
+
# define K_MIN1_RX 17
# if LINUX_VERSION_CODE < KERNEL_VERSION(K_MAJ, K_MIN1_RX, K_MIN2)