50dc83
From 769263ad422e3c1069de0994ff2274044982b242 Mon Sep 17 00:00:00 2001
50dc83
From: Mohit Agrawal <moagrawal@redhat.com>
50dc83
Date: Sun, 1 Sep 2019 12:01:09 +0530
50dc83
Subject: [PATCH 292/297] rpc: Update address family if it is not provide in
50dc83
 cmd-line arguments
50dc83
50dc83
Problem: After enabling transport-type to inet6 and passed ipv6
50dc83
         transport.socket.bind-address in glusterd.vol clients are
50dc83
         not started.
50dc83
50dc83
Solution: Need to update address-family based on remote-address for
50dc83
          all gluster client process
50dc83
50dc83
> Change-Id: Iaa3588cd87cebc45231bfd675745c1a457dc9b31
50dc83
> Fixes: bz#1747746
50dc83
> Credits: Amgad Saleh <amgad.saleh@nokia.com>
50dc83
> Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
50dc83
> (Cherry picked from commit 80b8cfe3f1386606bada97a76a0cad7acdf6b877)
50dc83
> (Reviewed on upstream link https://review.gluster.org/#/c/glusterfs/+/23340/)
50dc83
50dc83
Change-Id: Iaa3588cd87cebc45231bfd675745c1a457dc9b31
50dc83
BUG: 1750241
50dc83
Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
50dc83
Reviewed-on: https://code.engineering.redhat.com/gerrit/181184
50dc83
Tested-by: Mohit Agrawal <moagrawa@redhat.com>
50dc83
Tested-by: RHGS Build Bot <nigelb@redhat.com>
50dc83
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
50dc83
---
50dc83
 rpc/rpc-transport/socket/src/name.c | 13 ++++++++++++-
50dc83
 1 file changed, 12 insertions(+), 1 deletion(-)
50dc83
50dc83
diff --git a/rpc/rpc-transport/socket/src/name.c b/rpc/rpc-transport/socket/src/name.c
50dc83
index 7f18cc4..b473f3b 100644
50dc83
--- a/rpc/rpc-transport/socket/src/name.c
50dc83
+++ b/rpc/rpc-transport/socket/src/name.c
50dc83
@@ -214,6 +214,7 @@ af_inet_client_get_remote_sockaddr(rpc_transport_t *this,
50dc83
     uint16_t remote_port = 0;
50dc83
     struct addrinfo *addr_info = NULL;
50dc83
     int32_t ret = 0;
50dc83
+    struct in6_addr serveraddr;
50dc83
 
50dc83
     remote_host_data = dict_get(options, "remote-host");
50dc83
     if (remote_host_data == NULL) {
50dc83
@@ -249,6 +250,13 @@ af_inet_client_get_remote_sockaddr(rpc_transport_t *this,
50dc83
         goto err;
50dc83
     }
50dc83
 
50dc83
+    /* Need to update transport-address family if address-family is not provide
50dc83
+       to command-line arguments
50dc83
+    */
50dc83
+    if (inet_pton(AF_INET6, remote_host, &serveraddr)) {
50dc83
+        sockaddr->sa_family = AF_INET6;
50dc83
+    }
50dc83
+
50dc83
     /* TODO: gf_resolve is a blocking call. kick in some
50dc83
        non blocking dns techniques */
50dc83
     ret = gf_resolve_ip6(remote_host, remote_port, sockaddr->sa_family,
50dc83
@@ -522,7 +530,10 @@ socket_client_get_remote_sockaddr(rpc_transport_t *this,
50dc83
             ret = -1;
50dc83
     }
50dc83
 
50dc83
-    if (*sa_family == AF_UNSPEC) {
50dc83
+    /* Address-family is updated based on remote_host in
50dc83
+       af_inet_client_get_remote_sockaddr
50dc83
+    */
50dc83
+    if (*sa_family != sockaddr->sa_family) {
50dc83
         *sa_family = sockaddr->sa_family;
50dc83
     }
50dc83
 
50dc83
-- 
50dc83
1.8.3.1
50dc83