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