|
|
14f8ab |
From 85a5cce40dba0393e636c0eb5af9d8f8746f2315 Mon Sep 17 00:00:00 2001
|
|
|
14f8ab |
From: Mohit Agrawal <moagrawal@redhat.com>
|
|
|
14f8ab |
Date: Thu, 2 Jan 2020 10:23:52 +0530
|
|
|
14f8ab |
Subject: [PATCH 497/511] socket: Use AES128 cipher in SSL if AES is supported
|
|
|
14f8ab |
by CPU
|
|
|
14f8ab |
|
|
|
14f8ab |
SSL performance is improved after configuring AES128 cipher
|
|
|
14f8ab |
so use AES128 cipher as a default cipher on the CPU those
|
|
|
14f8ab |
enabled AES bits otherwise ssl use AES256 cipher
|
|
|
14f8ab |
|
|
|
14f8ab |
> Change-Id: I91c50fe987cbb22ed76f8012094730c592c63506
|
|
|
14f8ab |
> Fixes: #1050
|
|
|
14f8ab |
> Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
|
|
|
14f8ab |
> (Cherry pick from commit 177cc09d24515596eb51739ce0a276c26e3c52f1)
|
|
|
14f8ab |
> (Reviewed on upstream link https://review.gluster.org/#/c/glusterfs/+/23952/)
|
|
|
14f8ab |
|
|
|
14f8ab |
Change-Id: I91c50fe987cbb22ed76f8012094730c592c63506
|
|
|
14f8ab |
Bug: 1612973
|
|
|
14f8ab |
Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
|
|
|
14f8ab |
Reviewed-on: https://code.engineering.redhat.com/gerrit/220870
|
|
|
14f8ab |
Tested-by: Mohit Agrawal <moagrawa@redhat.com>
|
|
|
14f8ab |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
14f8ab |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
14f8ab |
---
|
|
|
14f8ab |
rpc/rpc-transport/socket/src/socket.c | 32 ++++++++++++++++++++++++++++++++
|
|
|
14f8ab |
1 file changed, 32 insertions(+)
|
|
|
14f8ab |
|
|
|
14f8ab |
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
|
|
|
14f8ab |
index 54cd5df..1ee7320 100644
|
|
|
14f8ab |
--- a/rpc/rpc-transport/socket/src/socket.c
|
|
|
14f8ab |
+++ b/rpc/rpc-transport/socket/src/socket.c
|
|
|
14f8ab |
@@ -4238,6 +4238,34 @@ static void __attribute__((destructor)) fini_openssl_mt(void)
|
|
|
14f8ab |
ERR_free_strings();
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
+/* The function returns 0 if AES bit is enabled on the CPU */
|
|
|
14f8ab |
+static int
|
|
|
14f8ab |
+ssl_check_aes_bit(void)
|
|
|
14f8ab |
+{
|
|
|
14f8ab |
+ FILE *fp = fopen("/proc/cpuinfo", "r");
|
|
|
14f8ab |
+ int ret = 1;
|
|
|
14f8ab |
+ size_t len = 0;
|
|
|
14f8ab |
+ char *line = NULL;
|
|
|
14f8ab |
+ char *match = NULL;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ GF_ASSERT(fp != NULL);
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ while (getline(&line, &len, fp) > 0) {
|
|
|
14f8ab |
+ if (!strncmp(line, "flags", 5)) {
|
|
|
14f8ab |
+ match = strstr(line, " aes");
|
|
|
14f8ab |
+ if ((match != NULL) && ((match[4] == ' ') || (match[4] == 0))) {
|
|
|
14f8ab |
+ ret = 0;
|
|
|
14f8ab |
+ break;
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ free(line);
|
|
|
14f8ab |
+ fclose(fp);
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ return ret;
|
|
|
14f8ab |
+}
|
|
|
14f8ab |
+
|
|
|
14f8ab |
static int
|
|
|
14f8ab |
ssl_setup_connection_params(rpc_transport_t *this)
|
|
|
14f8ab |
{
|
|
|
14f8ab |
@@ -4261,6 +4289,10 @@ ssl_setup_connection_params(rpc_transport_t *this)
|
|
|
14f8ab |
return 0;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
+ if (!ssl_check_aes_bit()) {
|
|
|
14f8ab |
+ cipher_list = "AES128:" DEFAULT_CIPHER_LIST;
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+
|
|
|
14f8ab |
priv->ssl_own_cert = DEFAULT_CERT_PATH;
|
|
|
14f8ab |
if (dict_get_str(this->options, SSL_OWN_CERT_OPT, &optstr) == 0) {
|
|
|
14f8ab |
if (!priv->ssl_enabled) {
|
|
|
14f8ab |
--
|
|
|
14f8ab |
1.8.3.1
|
|
|
14f8ab |
|