diff options
author | Aravinda VK <avishwan@redhat.com> | 2019-09-16 10:04:26 +0530 |
---|---|---|
committer | Atin Mukherjee <amukherj@redhat.com> | 2019-09-17 06:31:33 +0000 |
commit | fc10f370289e32da6753ac9a9a529b60abb16c4d (patch) | |
tree | d3476b642bdcec0edfb32fce610c3747c1345d9b /libglusterfs | |
parent | 304640e55c0f3c6d15f4e230dc6376e4f5020fea (diff) |
eventsapi: Set IPv4/IPv6 family based on input IP
server.sin_family was set to AF_INET while creating socket connection,
this was failing if the input address is IPv6(`::1`).
With this patch, sin_family is set by reading the ai_family of
`getaddrinfo` result.
Fixes: bz#1752330
Change-Id: I499f957b432842fa989c698f6e5b25b7016084eb
Signed-off-by: Aravinda VK <avishwan@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r-- | libglusterfs/src/events.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libglusterfs/src/events.c b/libglusterfs/src/events.c index 25097675a9e..9d337831387 100644 --- a/libglusterfs/src/events.c +++ b/libglusterfs/src/events.c @@ -42,6 +42,7 @@ _gf_event(eventtypes_t event, const char *fmt, ...) struct addrinfo hints; struct addrinfo *result = NULL; xlator_t *this = THIS; + int sin_family = AF_INET; /* Global context */ ctx = THIS->ctx; @@ -75,13 +76,15 @@ _gf_event(eventtypes_t event, const char *fmt, ...) ret = EVENT_ERROR_RESOLVE; goto out; } + + sin_family = result->ai_family; } else { /* Localhost, Use the defined IP for localhost */ host = gf_strdup(EVENT_HOST); } /* Socket Configurations */ - server.sin_family = AF_INET; + server.sin_family = sin_family; server.sin_port = htons(EVENT_PORT); ret = inet_pton(server.sin_family, host, &server.sin_addr); if (ret <= 0) { |