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

Re: Bug#343140: libc6: resolver always checks search list in /etc/resolv.conf



On Fri, Dec 23, 2005 at 01:21:54PM -0800, Edward Buck wrote:

> The correct query order for mx1.hotmail.com (containing 2 dots) should be:
> 
> 1. mx1.hotmail.com. - AAAA
> 2. mx1.hotmail.com. - A
> 3. mx1.hotmail.com.domain1.com. - AAAA
> 4. mx1.hotmail.com.domain1.com. - A
> 5. mx1.hotmail.com.domain2.com. - AAAA
> 6. mx1.hotmail.com.domain2.com. - A
> 
> If step 1 or 2 returns a host address, step 3 and later are skipped.
> 
> The Debian (or glibc) query order is:
> 
> 1. mx1.hotmail.com. - AAAA
> 2. mx1.hotmail.com.domain1.com. - AAAA
> 3. mx1.hotmail.com.domain2.com. - AAAA
> 4. mx1.hotmail.com. - A
> 5. mx1.hotmail.com.domain1.com. - A
> 6. mx1.hotmail.com.domain2.com. - A
> 
> With Debian's query order, mx1.hotmail.com exists as an A record yet the 
> system doesn't check until it has already done 3 queries, 2 of which do 
> not qualify as an 'initial absolute query'.

Ok, let's clarify some things here. resolv.conf(5) describes the
behaviour of a _single_ resolver query. If you look at
resolv/nss_dns/dns-host.c in the glibc source, you'll see that
gethostbyname(3) is implemented as _two_ distinct resolver invocations.
Since it is nowhere specified how many resolver invocations
gethostbyname(3) should cause, the glibc behaviour is correct and will
result in the second list of DNS queries you specified.

If you want to avoid the extra query, you should use getaddrinfo(3) or
the GNU-specific gethostbyname2(3) and specify explicitely the address
family you are interested in.
 
> The bug is not just limited to those who use the search line.  If your 
> resolv.conf contains 'domain ...', e.g.
> 
> domain example.com
> nameserver x.x.x.x
> nameserver y.y.y.y
> 
> Then a query of mx1.hotmail.com will ALWAYS yield:
> 
> 1. mx1.hotmail.com. - AAAA
> 2. mx1.hotmail.com.example.com. - AAAA (extraneous)
> 3. mx1.hotmail.com. - A

This is the same as before, as by default the search list is initialized
to contain the local domain if there are no explicit "search" lines.

Gabor

-- 
     ---------------------------------------------------------
     MTA SZTAKI Computer and Automation Research Institute
                Hungarian Academy of Sciences,
     Laboratory of Parallel and Distributed Systems
     Address   : H-1132 Budapest Victor Hugo u. 18-22. Hungary
     Phone/Fax : +36 1 329-78-64 (secretary)
     W3        : http://www.lpds.sztaki.hu
     ---------------------------------------------------------



Reply to: