From 4f25ee16443b29e1a25bd26a724e1e0a577e21ff Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 18 Aug 2011 21:38:28 +0200 Subject: [PATCH] Drop AI_ADDRCONFIG when resolving TCP addresses When a system is completely offline (no interface has an IP address but 'lo'), xcb could not connect to localhost via TCP, e.g. connections with DISPLAY=127.0.0.1:0 fail. AI_ADDRCONFIG will only return IPv4 addresses if the system has an IPv4 address configured (likewise for IPv6). This also takes place when resolving localhost (or 127.0.0.0/8 or ::1). Also, as per RFC 3493, loopback addresses are not considered as valid addresses when determining whether to return IPv4 or IPv6 addresses. As per mailing-list discussion on the xcb list started with message 20110813215405.5818a0c1@x200, the AI_ADDRCONFIG flag is there for historical reasons: In the old days, the "default on-link" assumption in IPv6 made the flag vey much indispensable for dual-stack hosts on IPv4-only networks. Without it, there would be long timeouts trying non-existent IPv6 connectivity. Nowadays, this assumption has been flagged as historic bad practice by IETF, and hosts should have been updated to not make it anymore. Then AI_ADDRCONFIG became mostly cosmetic: it avoids phony "Protocol family not supported" or "Host unreachable" errors while trying to connect to a dual- stack mode from a host with no support for source address selection. Nowadays, on up-to-date systems, this flag is completely useless. Then again, I understood only the very latest MacOS release is "up-to-date" with this definition. --- src/xcb_util.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/xcb_util.c b/src/xcb_util.c index fde4f85..1bde7b7 100644 --- a/src/xcb_util.c +++ b/src/xcb_util.c @@ -277,9 +277,6 @@ static int _xcb_open_tcp(const char *host, char *protocol, const unsigned short host = "localhost"; memset(&hints, 0, sizeof(hints)); -#ifdef AI_ADDRCONFIG - hints.ai_flags |= AI_ADDRCONFIG; -#endif #ifdef AI_NUMERICSERV hints.ai_flags |= AI_NUMERICSERV; #endif -- 2.7.4