14f8ab
From 8f89aef9691b0806d7487525c6a54a1a615c8bc1 Mon Sep 17 00:00:00 2001
14f8ab
From: Mohit Agrawal <moagrawal@redhat.com>
14f8ab
Date: Mon, 2 Sep 2019 10:46:10 +0530
14f8ab
Subject: [PATCH 293/297] glusterd: IPV6 hostname address is not parsed
14f8ab
 correctly
14f8ab
14f8ab
Problem: IPV6 hostname address is not parsed correctly in function
14f8ab
         glusterd_check_brick_order
14f8ab
14f8ab
Solution: Update the code to parse hostname address
14f8ab
14f8ab
> Change-Id: Ifb2f83f9c6e987b2292070e048e97eeb51b728ab
14f8ab
> Fixes: bz#1747746
14f8ab
> Credits: Amgad Saleh <amgad.saleh@nokia.com>
14f8ab
> Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
14f8ab
> (Cherry picked from commit 6563ffb04d7ba51a89726e7c5bbb85c7dbc685b5)
14f8ab
> (Reviewed on upstream link https://review.gluster.org/#/c/glusterfs/+/23341/)
14f8ab
14f8ab
Change-Id: Ifb2f83f9c6e987b2292070e048e97eeb51b728ab
14f8ab
BUG: 1750241
14f8ab
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
14f8ab
Reviewed-on: https://code.engineering.redhat.com/gerrit/181185
14f8ab
Tested-by: RHGS Build Bot <nigelb@redhat.com>
14f8ab
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
14f8ab
---
14f8ab
 xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 16 +++++++++++-----
14f8ab
 1 file changed, 11 insertions(+), 5 deletions(-)
14f8ab
14f8ab
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
14f8ab
index 1ea8ba6..076bc80 100644
14f8ab
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
14f8ab
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
14f8ab
@@ -95,6 +95,10 @@ glusterd_check_brick_order(dict_t *dict, char *err_str)
14f8ab
     int32_t type = GF_CLUSTER_TYPE_NONE;
14f8ab
     int32_t sub_count = 0;
14f8ab
     struct addrinfo *ai_info = NULL;
14f8ab
+    char brick_addr[128] = {
14f8ab
+        0,
14f8ab
+    };
14f8ab
+    int addrlen = 0;
14f8ab
 
14f8ab
     const char failed_string[2048] =
14f8ab
         "Failed to perform brick order "
14f8ab
@@ -182,15 +186,17 @@ glusterd_check_brick_order(dict_t *dict, char *err_str)
14f8ab
         brick_list_dup = tmpptr;
14f8ab
         if (brick == NULL)
14f8ab
             goto check_failed;
14f8ab
-        brick = strtok_r(brick, ":", &tmpptr);
14f8ab
-        if (brick == NULL)
14f8ab
+        tmpptr = strrchr(brick, ':');
14f8ab
+        if (tmpptr == NULL)
14f8ab
             goto check_failed;
14f8ab
-        ret = getaddrinfo(brick, NULL, NULL, &ai_info);
14f8ab
+        addrlen = strlen(brick) - strlen(tmpptr);
14f8ab
+        strncpy(brick_addr, brick, addrlen);
14f8ab
+        brick_addr[addrlen] = '\0';
14f8ab
+        ret = getaddrinfo(brick_addr, NULL, NULL, &ai_info);
14f8ab
         if (ret != 0) {
14f8ab
             ret = 0;
14f8ab
             gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_HOSTNAME_RESOLVE_FAIL,
14f8ab
-                   "unable to resolve "
14f8ab
-                   "host name");
14f8ab
+                   "unable to resolve host name for addr %s", brick_addr);
14f8ab
             goto out;
14f8ab
         }
14f8ab
         ai_list_tmp1 = MALLOC(sizeof(addrinfo_list_t));
14f8ab
-- 
14f8ab
1.8.3.1
14f8ab