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