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