Unnecessary DNS queries in Konqueror (second part of BR#88855)

Thiago Macieira thiago.macieira at kdemail.net
Mon Oct 11 15:10:18 BST 2004

Dawit A. wrote:
>Is there any reason why we do a DNS query even when the host is listed in
>the /etc/hosts file ?  We even do a lookup for "localhost" !!! Why ? This
> was really a surprise to me, but tcpdump confirms that it does indeed
> happen. Thiago any comments on this ?

"localhost" is special-cased. It's handled by our code directly. There 
should never be queries about it.

As for hosts in /etc/hosts, blame your glibc for doing the unnecessary 

The reason that they are done is because we do IPv6 lookups. 
Since /etc/hosts contains only IPv4 addresses, libnss_files.so returns an 
error code of "not found", instead of "found: it doesn't exist". Therefore, 
the query is passed along to libnss_dns.so, which sends the DNS query.

A test with "kde.org" in Konqueror resulted in the following lookups:
- query A kde.org
- query AAAA kde.org
- response A
- response (probably for AAAA)
- AAAA kde.org.local.lan
- response, No such name
- query AAAA kde.org.macieira.info
- response, No such name

Then this repeats three more times. Why? Because each ioslave must resolve 
the name again. For a solution for this, see bugs #63088 and #68894.

As for the unnecessary queries, the blame goes to libnss_files and 
libnss_dns. As you can see, the query for "AAAA kde.org" returned NOTFOUND 
from nss_files, so DNS kicked in. Then, the DNS query returned correctly a 
"NOERROR" DNS packet, indicating that the name exists, but has no IPv6 

But, nooo.... nss_dns decided that wasn't good enough and tried appending 
the domains listed in /etc/resolv.conf's search directive.
  Thiago Macieira  -  Registered Linux user #65028
   thiago (AT) macieira (DOT) info
    ICQ UIN: 1967141   PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20041011/b1ccf918/attachment.sig>

More information about the kde-core-devel mailing list