Debugging the case of scope ID == 0 when family is set to AF_INET6...
I'm finding that when family is set to AF_INET6, then _nss_gethostbyname2_r is called instead of _nss_gethostbyname4_r. This decision is made by libresolv. I did 'apt-get source libc6', which got me eglib-2.17 source (this is on Ubuntu 13.10 at the moment). In sysdeps/posix/getaddrinfo.c, I indeed see that it's only calling _nss_gethostbyname4_r when family is set to AF_UNSPEC. A comment says "gethostbyname4_r sends out parallel A and AAAA queries and is thus only suitable for PF_UNSPEC."
So that looks like a clash of requirements:
a) _nss_gethostbyname4_r is needed for IPv6 scope ID
b) _nss_gethostbyname4_r is allegedly not suitable for IPv6-only queries, because it sends out parallel A and AAAA queries.
Surely _nss_gethostbyname4_r SHOULD be used in order to get IPv6 scope ID.
Debugging the case of scope ID == 0 when family is set to AF_INET6...
I'm finding that when family is set to AF_INET6, then _nss_gethostbyn ame2_r is called instead of _nss_gethostbyn ame4_r. This decision is made by libresolv. I did 'apt-get source libc6', which got me eglib-2.17 source (this is on Ubuntu 13.10 at the moment). In sysdeps/ posix/getaddrin fo.c, I indeed see that it's only calling _nss_gethostbyn ame4_r when family is set to AF_UNSPEC. A comment says "gethostbyname4_r sends out parallel A and AAAA queries and is thus only suitable for PF_UNSPEC."
So that looks like a clash of requirements:
a) _nss_gethostbyn ame4_r is needed for IPv6 scope ID ame4_r is allegedly not suitable for IPv6-only queries, because it sends out parallel A and AAAA queries.
b) _nss_gethostbyn
Surely _nss_gethostbyn ame4_r SHOULD be used in order to get IPv6 scope ID.
What should we do next?