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