tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: lib/42405: libc: getaddrinfo() should perform T_A lookups before T_AAAA lookups, was: Resolver problems



> [B]ut if you say "just give me something I can use" without caring
> what protocol, I don't think it would be unreasonable for
> getaddrinfo() to simply return only addresses that have at least the
> potential to work - and I don't think applications should need to set
> some flag to tell getaddrinfo() not to return useless trash,

The problem is, what constitutes "useless trash"?

> if anything, for the one in a hundred application that isn't a
> diagnostic tool (which wouldn't be using getaddrinfo()),

Where do you get this idea that diagnostic tools don't use
getaddrinfo()?  Especially when trying to diagnose name resolution
issues, one of the things to do is to try the usual interface.

> doesn't care what address type, but wants everything available, even
> if it cannot possibly work,

"Cannot possibly work" is impossible for software to tell.

> a flag to indicate that would make more sense (you'd really have to
> hunt to find an application that you'd need to modify to set it).

I wouldn't have to hunt at all; I have an example at ready hand.

One of my programs (I call it addr) simply prints out the list of
addresses a name resolves to.  There is no implication that any of
those addresses are going to be used to aim network traffic; they
might, for example, be going into a router blocking list.  And there
most certainly is no implication that whatever use is to be made of the
addresses will be done on the machine where addr is running.  As such,
software - addr, getaddrinfo(), whatever - is not in a position to tell
what might or might not be useful to return.

I use addr regularly.  I wrote it because I couldn't find any other
application that could turn a name into a list of addresses without a
lot of extracting addresses from undocumented (and usually non-frozen
and thus liable to breakage upon upgrade) output formats.  I initially
meant it for use in shell scripts, but most of the times I run it turn
out to be command-line queries.

>> getaddrinfo() is only used by programs that can handle IPv6
> Typically yes, but not necessarily, [...], getaddrinfo() is a much
> nicer interface than gethostbyname().

In many respects.  It certainly has its problems, perhaps most notably
the inconvenience of initializing hints structures (I can't see any
reason for demanding that the unused fields be set to fixed values,
and, since some of them are pointers, a wholesale bzero() is not
suitable).  But most of the problems I run into when using it are not
ones that it is in a position to solve.

/~\ The ASCII                             Mouse
\ / Ribbon Campaign
 X  Against HTML                mouse%rodents-montreal.org@localhost
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index