summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohit Agrawal <moagrawal@redhat.com>2019-09-02 10:46:10 +0530
committerAtin Mukherjee <amukherj@redhat.com>2019-09-06 04:36:44 +0000
commit6563ffb04d7ba51a89726e7c5bbb85c7dbc685b5 (patch)
tree5b9a10a6478ba89be28e73e90426006969d44da1
parent66bf17321655225d1096da4f2b5270f02afd102d (diff)
glusterd: IPV6 hostname address is not parsed correctly
Problem: IPV6 hostname address is not parsed correctly in function glusterd_check_brick_order Solution: Update the code to parse hostname address Change-Id: Ifb2f83f9c6e987b2292070e048e97eeb51b728ab Fixes: bz#1747746 Credits: Amgad Saleh <amgad.saleh@nokia.com> Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-ops.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
index b21c396..d3a3e65 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
@@ -91,6 +91,10 @@ glusterd_check_brick_order(dict_t *dict, char *err_str)
int32_t type = GF_CLUSTER_TYPE_NONE;
int32_t sub_count = 0;
struct addrinfo *ai_info = NULL;
+ char brick_addr[128] = {
+ 0,
+ };
+ int addrlen = 0;
const char failed_string[2048] =
"Failed to perform brick order "
@@ -178,15 +182,17 @@ glusterd_check_brick_order(dict_t *dict, char *err_str)
brick_list_dup = tmpptr;
if (brick == NULL)
goto check_failed;
- brick = strtok_r(brick, ":", &tmpptr);
- if (brick == NULL)
+ tmpptr = strrchr(brick, ':');
+ if (tmpptr == NULL)
goto check_failed;
- ret = getaddrinfo(brick, NULL, NULL, &ai_info);
+ addrlen = strlen(brick) - strlen(tmpptr);
+ strncpy(brick_addr, brick, addrlen);
+ brick_addr[addrlen] = '\0';
+ ret = getaddrinfo(brick_addr, NULL, NULL, &ai_info);
if (ret != 0) {
ret = 0;
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_HOSTNAME_RESOLVE_FAIL,
- "unable to resolve "
- "host name");
+ "unable to resolve host name for addr %s", brick_addr);
goto out;
}
ai_list_tmp1 = MALLOC(sizeof(addrinfo_list_t));