f338ef
From 2fa5476b95d4547bdde50f2281bf58b7db24e37a Mon Sep 17 00:00:00 2001
f338ef
From: Aravinda VK <avishwan@redhat.com>
f338ef
Date: Mon, 16 Sep 2019 10:04:26 +0530
f338ef
Subject: [PATCH 294/297] eventsapi: Set IPv4/IPv6 family based on input IP
f338ef
f338ef
server.sin_family was set to AF_INET while creating socket connection,
f338ef
this was failing if the input address is IPv6(`::1`).
f338ef
f338ef
With this patch, sin_family is set by reading the ai_family of
f338ef
`getaddrinfo` result.
f338ef
f338ef
> upstream patch : https://review.gluster.org/#/c/glusterfs/+/23423/
f338ef
f338ef
>Fixes: bz#1752330
f338ef
>Change-Id: I499f957b432842fa989c698f6e5b25b7016084eb
f338ef
>Signed-off-by: Aravinda VK <avishwan@redhat.com>
f338ef
f338ef
BUG: 1732443
f338ef
Change-Id: I499f957b432842fa989c698f6e5b25b7016084eb
f338ef
Signed-off-by: Aravinda VK <avishwan@redhat.com>
f338ef
Reviewed-on: https://code.engineering.redhat.com/gerrit/181197
f338ef
Tested-by: RHGS Build Bot <nigelb@redhat.com>
f338ef
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
f338ef
---
f338ef
 libglusterfs/src/events.c | 5 ++++-
f338ef
 1 file changed, 4 insertions(+), 1 deletion(-)
f338ef
f338ef
diff --git a/libglusterfs/src/events.c b/libglusterfs/src/events.c
f338ef
index 2509767..9d33783 100644
f338ef
--- a/libglusterfs/src/events.c
f338ef
+++ b/libglusterfs/src/events.c
f338ef
@@ -42,6 +42,7 @@ _gf_event(eventtypes_t event, const char *fmt, ...)
f338ef
     struct addrinfo hints;
f338ef
     struct addrinfo *result = NULL;
f338ef
     xlator_t *this = THIS;
f338ef
+    int sin_family = AF_INET;
f338ef
 
f338ef
     /* Global context */
f338ef
     ctx = THIS->ctx;
f338ef
@@ -75,13 +76,15 @@ _gf_event(eventtypes_t event, const char *fmt, ...)
f338ef
             ret = EVENT_ERROR_RESOLVE;
f338ef
             goto out;
f338ef
         }
f338ef
+
f338ef
+        sin_family = result->ai_family;
f338ef
     } else {
f338ef
         /* Localhost, Use the defined IP for localhost */
f338ef
         host = gf_strdup(EVENT_HOST);
f338ef
     }
f338ef
 
f338ef
     /* Socket Configurations */
f338ef
-    server.sin_family = AF_INET;
f338ef
+    server.sin_family = sin_family;
f338ef
     server.sin_port = htons(EVENT_PORT);
f338ef
     ret = inet_pton(server.sin_family, host, &server.sin_addr);
f338ef
     if (ret <= 0) {
f338ef
-- 
f338ef
1.8.3.1
f338ef