7f4c2a
From 2cee2186043fb8b2a80ce3540e41492b1744bd22 Mon Sep 17 00:00:00 2001
7f4c2a
From: Kaushal M <kaushal@redhat.com>
7f4c2a
Date: Tue, 7 Jul 2015 12:52:30 +0530
7f4c2a
Subject: [PATCH 225/234] glusterd: Fix management encryption issues with GlusterD
7f4c2a
7f4c2a
  Backport of commit 01b82c6 from upstream master
7f4c2a
7f4c2a
Management encryption was enabled incorrectly in GlusterD leading to
7f4c2a
issues of cluster deadlocks. This has been fixed with this commit. The
7f4c2a
fix is in two parts,
7f4c2a
7f4c2a
1. Correctly enable encrytion for the TCP listener in GlusterD and
7f4c2a
re-enable own-threads for encrypted connections.
7f4c2a
  Without this, GlusterD could try to esatblish the blocking SSL
7f4c2a
  connects in the epoll thread, for eg. when handling friend updates,
7f4c2a
  which could lead to cluster deadlocks.
7f4c2a
7f4c2a
2. Explicitly enable encryption for outgoing peer connections.
7f4c2a
  Without enabling encryption explicitly for outgoing connections was
7f4c2a
  causing SSL socket events to be handled in the epoll thread. Some
7f4c2a
  events, like disconnects during peer detach, could lead to connection
7f4c2a
  attempts to happen in the epoll thread, leading to deadlocks again.
7f4c2a
7f4c2a
Change-Id: I438c2b43f7b1965c0e04d95c000144118d36272c
7f4c2a
BUG: 1239108
7f4c2a
Signed-off-by: Kaushal M <kaushal@redhat.com>
7f4c2a
Reviewed-upstream-on: http://review.gluster.org/11559
7f4c2a
Reviewed-on: https://code.engineering.redhat.com/gerrit/52746
7f4c2a
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
7f4c2a
Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
7f4c2a
---
7f4c2a
 xlators/mgmt/glusterd/src/glusterd-handler.c |   14 ++++++++++++++
7f4c2a
 xlators/mgmt/glusterd/src/glusterd.c         |   13 +++++--------
7f4c2a
 2 files changed, 19 insertions(+), 8 deletions(-)
7f4c2a
7f4c2a
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
7f4c2a
index 3bc39c9..82bd7b1 100644
7f4c2a
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
7f4c2a
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
7f4c2a
@@ -3430,6 +3430,20 @@ glusterd_friend_rpc_create (xlator_t *this, glusterd_peerinfo_t *peerinfo,
7f4c2a
                 }
7f4c2a
         }
7f4c2a
 
7f4c2a
+        /* Enable encryption for the client connection if management encryption
7f4c2a
+         * is enabled
7f4c2a
+         */
7f4c2a
+        if (this->ctx->secure_mgmt) {
7f4c2a
+                ret = dict_set_str (options, "transport.socket.ssl-enabled",
7f4c2a
+                                    "on");
7f4c2a
+                if (ret) {
7f4c2a
+                        gf_msg ("glusterd", GF_LOG_ERROR, 0,
7f4c2a
+                                GD_MSG_DICT_SET_FAILED,
7f4c2a
+                                "failed to set ssl-enabled in dict");
7f4c2a
+                        goto out;
7f4c2a
+                }
7f4c2a
+        }
7f4c2a
+
7f4c2a
         ret = glusterd_rpc_create (&peerinfo->rpc, options,
7f4c2a
                                    glusterd_peer_rpc_notify, peerctx);
7f4c2a
         if (ret) {
7f4c2a
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
7f4c2a
index 9754e8b..05723b9 100644
7f4c2a
--- a/xlators/mgmt/glusterd/src/glusterd.c
7f4c2a
+++ b/xlators/mgmt/glusterd/src/glusterd.c
7f4c2a
@@ -1589,19 +1589,16 @@ init (xlator_t *this)
7f4c2a
                 goto out;
7f4c2a
         }
7f4c2a
 
7f4c2a
+        /* Enable encryption for the TCP listener is management encryption is
7f4c2a
+         * enabled
7f4c2a
+         */
7f4c2a
         if (this->ctx->secure_mgmt) {
7f4c2a
-                /*
7f4c2a
-                 * The socket code will turn on SSL based on the same check,
7f4c2a
-                 * but that will by default turn on own-thread as well and
7f4c2a
-                 * we're not multi-threaded enough to handle that.  Thus, we
7f4c2a
-                 * override the value here.
7f4c2a
-                 */
7f4c2a
                 ret = dict_set_str (this->options,
7f4c2a
-                                    "transport.socket.own-thread", "off");
7f4c2a
+                                    "transport.socket.ssl-enabled", "on");
7f4c2a
                 if (ret != 0) {
7f4c2a
                         gf_msg (this->name, GF_LOG_ERROR, 0,
7f4c2a
                                 GD_MSG_DICT_SET_FAILED,
7f4c2a
-                                "failed to clear own-thread");
7f4c2a
+                                "failed to set ssl-enabled in dict");
7f4c2a
                         goto out;
7f4c2a
                 }
7f4c2a
                 /*
7f4c2a
-- 
7f4c2a
1.7.1
7f4c2a