AF_INET6 link-local addresses in getaddrinfo
Ronan Pigott
ronan@rjp.ie
Tue Nov 19 20:08:47 GMT 2024
Hi glibc,
I work on systemd-resolved, which offers an nss hosts module that implements
both DNS and mDNS via systemd-resolved. mDNS is widely used where traditional
DNS service is not available, and it is very common to recieve answers with
link-local addresses in ipv6 networks. The NSS interface currently doesn't
adequately support this use case, because nss_gethostbyname3_r does not
support the necessary scope id, and nss_gethostbyname4_r is necessarily
dual-stack, and is therefore never selected by getaddrinfo when the requested
address family is AF_INET6. As a result, AF_INET6 lookups are broken in many
cases because they omit the required scope id of link-local addresses even if
it was determined correctly by the nss service.
Consequently, years ago I submitted a patch to inet-utils ping to remove the
use of AF_INET6, even where a v6 connection was explicitly requested via the
-6 flag, which enables invocations like ping -6 $HOST.local to function
properly. This has come up again recently in [1] , so I'm wondering: is this
fixable in glibc instead? I assume at least a nss_gethostbyname5_r is
required. As best I can tell, this issue was originally reported in [2].
Otherwise, I suppose we should keep this workaround in ping, and possibly
other applications as well.
[1] https://github.com/iputils/iputils/pull/567#issuecomment-2484997571
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=14413
Thanks,
Ronan
More information about the Libc-alpha
mailing list