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