[ https://issues.apache.org/jira/browse/THRIFT-5880?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
James E. King III updated THRIFT-5880: -------------------------------------- Fix Version/s: 0.23.0 > C++ TSocket on an IPv6-only system fails if you use a hostname of 127.0.0.1 > --------------------------------------------------------------------------- > > Key: THRIFT-5880 > URL: https://issues.apache.org/jira/browse/THRIFT-5880 > Project: Thrift > Issue Type: Bug > Components: C++ - Library > Affects Versions: 0.20.0 > Reporter: James E. King III > Assignee: James E. King III > Priority: Minor > Fix For: 0.23.0 > > Attachments: resolvtest.c > > > {{The TSocket code uses AI_ADDRCONFIG to resolve the hostname and retrieve A > and AAAA records for IPv6 compatibility. There's a nasty corner case > documented in the [getaddrinfo() > documentation|https://linux.die.net/man/3/getaddrinfo]:}} > {quote}{{If _hints.ai_flags_ includes the *AI_ADDRCONFIG* flag, then IPv4 > addresses are returned in the list pointed to by _res_ only if the local > system has at least one IPv4 address configured, and IPv6 addresses are only > returned if the local system has at least one IPv6 address configured. The > loopback address is not considered for this case as valid as a configured > address. }} > {quote} > {{Therefore on a system that has only IPv6 interfaces with the exception of > loopback, using AI_ADDRINFO results in an EAI_ADDRFAMILY error:}} > {{# ifconfig}} > {{eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500}} > {{ inet6 ffff:ffff:ffff:ffff::ffff prefixlen 128 scopeid > 0x0<global>}} > {{ inet6 ffff::ffff:ff:ffff:ffff prefixlen 64 scopeid 0x20<link>}} > {{ ether ff:ff:ff:ff:ff:ff txqueuelen 10000 (Ethernet)}} > {{ RX packets 118419 bytes 352689119 (336.3 MiB)}} > {{ RX errors 0 dropped 4 overruns 0 frame 0}} > {{ TX packets 101312 bytes 43358432 (41.3 MiB)}} > {{ TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0}} > {{lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536}} > {{ inet 127.0.0.1 netmask 255.0.0.0}} > {{ inet6 ::1 prefixlen 128 scopeid 0x10<host>}} > {{ loop txqueuelen 1000 (Local Loopback)}} > {{ RX packets 2343 bytes 277200 (270.7 KiB)}} > {{ RX errors 0 dropped 0 overruns 0 frame 0}} > {{ TX packets 2343 bytes 277200 (270.7 KiB)}} > {{ TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0}} > Calling getaddrinfo() on "127.0.0.1" causes this error. I generated a test > program to validate the behavior: > {{# ## without AI_ADDRCONFIG - it works}} > {{# ./resolvtest 127.0.0.1}} > {{Resolving hostname: 127.0.0.1}} > {{Resolution successful. Results:}} > {{ 1: IPv4: 127.0.0.1}} > {{ Family: 2, Socket type: 1, Protocol: 6}} > {{# ./resolvtest -c 127.0.0.1}} > {{Using AI_ADDRCONFIG flag}} > {{Resolving hostname: 127.0.0.1}} > {{getaddrinfo error: Address family for hostname not supported}} > {{I attached the test program as well.}} > {{The fix is simple: in TSocket.cpp around line 466 where we check for an > EAI_NODATA response, we should also check for EAI_ADDRFAMILY.}} -- This message was sent by Atlassian Jira (v8.20.10#820010)