[PATCH v5 1/2] resolv: implement ipv4+ipv6 flags in resolv.conf (bug 30544)

Petr Menšík pemensik@redhat.com
Thu Oct 16 08:29:37 GMT 2025


These are not added into /etc/gai.conf intentionally. Because for link 
local protocols provided by mdns or mdns_minimal, they can connect to 
other hosts on the same network, even if the network provides absolutely 
no infrastructure for it.

I can put 2 machines into powered switch, leading to no router at all. 
Those 2 machines connected to it (or bridge without a router) should be 
able both A and AAAA queries to find themselves on multicast DNS.

But unless I have at least one route leading outside, classic unicast 
DNS AAAA response is not connected to specific interface. That is 
default configuration in default libvirt network for example. It has 
only IPv4 route and has NAT enabled. IPv6 traffic fails at the host with 
no route failure. Just try ping -c1 example.com.

I want to restrict intentionally only dns plugin and clients using DNS 
stub by this change. The file all of such client will parse is resolv.conf.

Additional advantage is it already has implemented monitoring of 
/etc/resolv.conf. If those flags changes, applicaitons using glibc 
functions should catch it. Something like that is not implemeted for 
/etc/gai.conf, I think. Correct me if I am wrong.

Petr

On 15/10/2025 22:05, Florian Weimer wrote:
> * Petr Menšík:
>
>> Add separate flags to mark support of address family. Its intention is
>> to react dynamically to changing network conditions. If the host has
>> IPv4 connectivity only, it would set ipv4 option. If it has also IPv6
>> connectivity, it would set ipv6 option. If it connects IPv6-only
>> network, then it set ipv6 only.
>>
>> For backward compatibility it will keep old behaviour when both ipv4 and
>> ipv6 flags are missing. In this case it behaves the same way as if both
>> were present.
>>
>> This is quite useful when default AF_UNSPEC is used in hints, but the
>> host is on network with just single AF used.
>>
>> Unlike no-aaaa option it would change just AF_UNSPEC behaviour, ie.
>> getent ahosts example.com. getent ahostsv4 and getent ahostsv6 would
>> remain unmodified.
> These should be /etc/gai.conf options.  This means that we get extra
> queries for IPv6 mode (which has to use gethostnameby4 if AAAA lookups
> are requested even if A lookups are disabled).  We can disable those for
> the internal dns module through an internal interface, but it won't help
> external NSS modules.  For those, a new interface would be needed.
>
> I consider _res.options an obsolescent interface, but this change would
> encourage NSS modules to examine it, potentially having to call res_init
> first.  Parsing /etc/gai.conf would be getaddrinfo's responsibility.
>
> I understand that replacing gethostbyname4 is a major undertaking
> (because it would make sense to get rid of the ERANGE protocol at the
> same time).
>
> Thanks,
> Florian
>
-- 
Petr Menšík
Senior Software Engineer, RHEL
Red Hat, https://www.redhat.com/
PGP: DFCF908DB7C87E8E529925BC4931CA5B6C9FC5CB



More information about the Libc-alpha mailing list