[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: getaddrinfo address ordering [Re: IPv6 transition architecture discussion]
In message <Pine.LNX.4.44.0211270915100.28193-100000@netcore.fi>, you write:
>Do I sense this as a voice for support to modify or at least explore the
>current de-facto standard ordering?
There is no specified standard, deliberately. This is an implementation
issue. Not all implementations have this problem, but many people on this list
don't seem to understand that and instead blame getaddrinfo() or blame IPv6.
>These help quite a bit, but I guess adding some getaddrinfo hint like
>AI_PREFERV4 or AI_PREFERV6 could be added in the case that DNS lookup
>returns both addresses, you use AF_UNSPEC and you want to influence the
>default DNS record ordering.
NO! NO! NO!
getaddrinfo is a PROTOCOL INDEPENDENT API. It is NEVER appropriate to cruft
ANY protocol-specific options into getaddrinfo. Protocol-specific hacks belong
in protocol-specific APIs. If the protocol-independent APIs do not give you
the features you want, then use the protocol-dependent APIs instead, which
will give you more specific controls.
If an application wants to have getaddrinfo() return things in a particular
order, it should call getaddrinfo() multiple times in the order it wants, i.e.,
call it first for req.ai_addr=AF_INET, second for req.ai_addr=AF_INET6, etc.
HOWEVER, this behavior would be TOTALLY BROKEN as it first defeats protocol
independence (the whole point; if you're not using getaddrinfo in a protocol
independent way, why are you using it at all?), and second because it limits
you to IPv4 and IPv6.
BSDI did this right. BSD/OS had a configurable resolver return order, I
believe through a file and an environment variable. Didn't like the system
default? Users can request things be done in a different order. Problem solved.
I think BSDI gave their code to ISC for use in BIND, but it appears that
this feature got lost in the transition. Still, if someone with clues asked
the old BSDI folks nicely, you might be able to get their code for this and
fold it into your favorite implementation.
-Craig