[PATCH] nss: Use gethostbyname4_r when requesting IPv6 addresses (bug 14413)

Florian Weimer fw@deneb.enyo.de
Tue Oct 28 22:15:04 GMT 2025


* Patrick Griffis:

> On 2025-10-27 08:40, Carlos O'Donell wrote:
>> Patrick,
>> 
>> This still fails pre-commit CI as noted by Adhemerval in an earlier post.
>> 
>> https://patchwork.sourceware.org/project/glibc/patch/20251025002359.2093627-1-pgriffis@igalia.com/
>> 
>> Have you had a chance to look into the regression?
>
> Hi Carlos,
>
> I have looked but unfortunately I don’t think it’s possible to fix this
> bug and keep the exact same behavior for error codes.
>
> Previously if you only request IPv6 addresses with gethostbyname3_r and
> it has none it always errors with EAI_NONAME which makes sense as the
> resolver doesn’t care about IPv4.
>
> Since we need to use gethostbyname4_r the resolver does consider the
> IPv4 results and may error with EAI_NODATA. This also makes sense, and
> is closer to the truth, but it’s a behavior change.
>
> Trying to emulate the previous behavior is tricky since both errors are
> valid and we just don’t have enough information.
>
> To me it sounds fine to change the one nss test to expect EAI_NONAME
> instead.

This is a genuine bug, either in the test or in getaddrinfo.  The
names an1.ns2.ar1.example and an3.ns2.ar1.example are supposed to
exist (yielding positive answers from the DNS server).  There is quite
a bit of code that tries to make sure that the expected NODATA result
is produced even with RES_NOAAA (mapping AAAA lookups to A lookups if
necessary), and that no longer seems to be working.

There is also a formatting glitch:

+      /* The gethostbyname4_r API is always expected to return both address families
+       * which means we would prefer gethostbyname3_r when requesting only IPv4 addresses.
+       * Unfortunately when requesting IPv6 only we have to use this API for link-local
+       * information (scope_id is not in the hostent struct).
+       * This means we may collect unncessary IPv4 addresses. */

These lines are too long.  Subsequent comment lines should not start
with “*”.  There should be two spaces after the period at the end of
the comment.


More information about the Libc-alpha mailing list