cead9d
From 2b859d1a5499a215c8c37472d4fc7d7e4d70dac6 Mon Sep 17 00:00:00 2001
cead9d
From: Mohit Agrawal <moagrawal@redhat.com>
cead9d
Date: Tue, 31 Mar 2020 16:45:35 +0530
cead9d
Subject: [PATCH 360/362] rpc: Make ssl log more useful
cead9d
cead9d
Currently, ssl_setup_connection_params throws 4 messages for every
cead9d
rpc connection that irritates a user while reading the logs. The same
cead9d
info we can print in a single log with peerinfo to make it more
cead9d
useful.ssl_setup_connection_params try to load dh_param even user
cead9d
has not configured it and if a dh_param file is not available it throws
cead9d
a failure message.To avoid the message load dh_param only while the user
cead9d
has configured it.
cead9d
cead9d
> Change-Id: I9ddb57f86a3fa3e519180cb5d88828e59fe0e487
cead9d
> Fixes: #1141
cead9d
> Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
cead9d
> Cherry pick from commit 80dd8cceab3b860bf1bc2945c8e2d8d0b3913e48
cead9d
> Reviewed on upstream link https://review.gluster.org/#/c/glusterfs/+/24270/
cead9d
cead9d
BUG: 1812824
cead9d
Change-Id: I9ddb57f86a3fa3e519180cb5d88828e59fe0e487
cead9d
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
cead9d
Reviewed-on: https://code.engineering.redhat.com/gerrit/196371
cead9d
Tested-by: RHGS Build Bot <nigelb@redhat.com>
cead9d
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
cead9d
---
cead9d
 rpc/rpc-transport/socket/src/socket.c | 46 ++++++++++++++++++++---------------
cead9d
 1 file changed, 26 insertions(+), 20 deletions(-)
cead9d
cead9d
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
cead9d
index f54ca83..65845ea 100644
cead9d
--- a/rpc/rpc-transport/socket/src/socket.c
cead9d
+++ b/rpc/rpc-transport/socket/src/socket.c
cead9d
@@ -4240,6 +4240,7 @@ ssl_setup_connection_params(rpc_transport_t *this)
cead9d
     char *cipher_list = DEFAULT_CIPHER_LIST;
cead9d
     char *dh_param = DEFAULT_DH_PARAM;
cead9d
     char *ec_curve = DEFAULT_EC_CURVE;
cead9d
+    gf_boolean_t dh_flag = _gf_false;
cead9d
 
cead9d
     priv = this->private;
cead9d
 
cead9d
@@ -4248,6 +4249,10 @@ ssl_setup_connection_params(rpc_transport_t *this)
cead9d
         return 0;
cead9d
     }
cead9d
 
cead9d
+    if (!priv->ssl_enabled && !priv->mgmt_ssl) {
cead9d
+        return 0;
cead9d
+    }
cead9d
+
cead9d
     priv->ssl_own_cert = DEFAULT_CERT_PATH;
cead9d
     if (dict_get_str(this->options, SSL_OWN_CERT_OPT, &optstr) == 0) {
cead9d
         if (!priv->ssl_enabled) {
cead9d
@@ -4294,27 +4299,25 @@ ssl_setup_connection_params(rpc_transport_t *this)
cead9d
             priv->crl_path = gf_strdup(optstr);
cead9d
     }
cead9d
 
cead9d
-    gf_log(this->name, priv->ssl_enabled ? GF_LOG_INFO : GF_LOG_DEBUG,
cead9d
-           "SSL support on the I/O path is %s",
cead9d
-           priv->ssl_enabled ? "ENABLED" : "NOT enabled");
cead9d
-    gf_log(this->name, priv->mgmt_ssl ? GF_LOG_INFO : GF_LOG_DEBUG,
cead9d
-           "SSL support for glusterd is %s",
cead9d
-           priv->mgmt_ssl ? "ENABLED" : "NOT enabled");
cead9d
-
cead9d
     if (!priv->mgmt_ssl) {
cead9d
-        if (!dict_get_int32(this->options, SSL_CERT_DEPTH_OPT, &cert_depth)) {
cead9d
-            gf_log(this->name, GF_LOG_INFO, "using certificate depth %d",
cead9d
-                   cert_depth);
cead9d
+        if (!dict_get_int32_sizen(this->options, SSL_CERT_DEPTH_OPT,
cead9d
+                                  &cert_depth)) {
cead9d
         }
cead9d
     } else {
cead9d
         cert_depth = this->ctx->ssl_cert_depth;
cead9d
-        gf_log(this->name, GF_LOG_INFO, "using certificate depth %d",
cead9d
-               cert_depth);
cead9d
     }
cead9d
-    if (!dict_get_str(this->options, SSL_CIPHER_LIST_OPT, &cipher_list)) {
cead9d
+    gf_log(this->name, priv->ssl_enabled ? GF_LOG_INFO : GF_LOG_DEBUG,
cead9d
+           "SSL support for MGMT is %s IO path is %s certificate depth is %d "
cead9d
+           "for peer %s",
cead9d
+           (priv->mgmt_ssl ? "ENABLED" : "NOT enabled"),
cead9d
+           (priv->ssl_enabled ? "ENABLED" : "NOT enabled"), cert_depth,
cead9d
+           this->peerinfo.identifier);
cead9d
+
cead9d
+    if (!dict_get_str_sizen(this->options, SSL_CIPHER_LIST_OPT, &cipher_list)) {
cead9d
         gf_log(this->name, GF_LOG_INFO, "using cipher list %s", cipher_list);
cead9d
     }
cead9d
-    if (!dict_get_str(this->options, SSL_DH_PARAM_OPT, &dh_param)) {
cead9d
+    if (!dict_get_str_sizen(this->options, SSL_DH_PARAM_OPT, &dh_param)) {
cead9d
+        dh_flag = _gf_true;
cead9d
         gf_log(this->name, GF_LOG_INFO, "using DH parameters %s", dh_param);
cead9d
     }
cead9d
     if (!dict_get_str(this->options, SSL_EC_CURVE_OPT, &ec_curve)) {
cead9d
@@ -4349,12 +4352,15 @@ ssl_setup_connection_params(rpc_transport_t *this)
cead9d
 #ifdef SSL_OP_NO_COMPRESSION
cead9d
         SSL_CTX_set_options(priv->ssl_ctx, SSL_OP_NO_COMPRESSION);
cead9d
 #endif
cead9d
-
cead9d
-        if ((bio = BIO_new_file(dh_param, "r")) == NULL) {
cead9d
-            gf_log(this->name, GF_LOG_INFO,
cead9d
-                   "failed to open %s, "
cead9d
-                   "DH ciphers are disabled",
cead9d
-                   dh_param);
cead9d
+        /* Upload file to bio wrapper only if dh param is configured
cead9d
+         */
cead9d
+        if (dh_flag) {
cead9d
+            if ((bio = BIO_new_file(dh_param, "r")) == NULL) {
cead9d
+                gf_log(this->name, GF_LOG_ERROR,
cead9d
+                       "failed to open %s, "
cead9d
+                       "DH ciphers are disabled",
cead9d
+                       dh_param);
cead9d
+            }
cead9d
         }
cead9d
 
cead9d
         if (bio != NULL) {
cead9d
-- 
cead9d
1.8.3.1
cead9d