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