From 9e85e118cae401f2887346926a87ab24a7ffa7d6 Mon Sep 17 00:00:00 2001 From: Zhimin Feng Date: Mon, 2 Mar 2020 16:26:51 +0800 Subject: [PATCH] rpc: getaddrinfo: also accept IPv4-mapped IPv6 addresses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If only IPv6 is configured on the host, getaddrinfo with AI_ADDRCONFIG in hints would return EAI_ADDRFAMILY for nodenames that resolve to IPv4. Also pass AI_V4MAPPED to accept IPv4-mapped addresses on IPv6-only systems. Signed-off-by: Zhimin Feng [rewrote the commit message - jtomko] Signed-off-by: Ján Tomko Reviewed-by: Ján Tomko Reviewed-by: Daniel P. Berrangé --- src/rpc/virnetsocket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index 360711acb6..6c790cb577 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -575,7 +575,7 @@ int virNetSocketNewConnectTCP(const char *nodename, memset(&hints, 0, sizeof(hints)); hints.ai_family = family; - hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG; + hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG | AI_V4MAPPED; hints.ai_socktype = SOCK_STREAM; int e = getaddrinfo(nodename, service, &hints, &ai);