[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: wasted open() on /etc/resolv.conf?
On Mon, Jan 29, 2001 at 08:13:14PM -0500, Michael B. Rash wrote:
>
> Kernel 2.2.14-5.0:
>
> Suppose that I put this following line in /etc/hosts:
> 216.32.74.52 www.yahoo.com
> ...and this line in /etc/nsswitch.conf
> hosts: files nisplus nis dns
>
> Now, if I 'ping www.yahoo.com', my machine will not have to do an nslookup
> since the entry is in /etc/hosts, and doing 'tcpdump udp port 53' shows
> that no nslookup is performed if I do the ping. Fine.
>
> Now, if I run 'strace -e trace=open ping www.yahoo.com', I get the
> following in the output (among other things):
>
> open("/etc/resolv.conf", O_RDONLY) = 4
> open("/etc/nsswitch.conf", O_RDONLY) = 4
> open("/etc/ld.so.cache", O_RDONLY) = 4
> open("/etc/host.conf", O_RDONLY) = 4
> open("/etc/hosts", O_RDONLY) = 4
>
> Since my machine does not need look up the address for www.yahoo.com, why
> is /etc/resolv.conf being opened at all? There does not need to be any
> communication with the nameserver so doesn't this seem to be
> wasteful?
>
> My only guess as to why this would happen might be that since most hosts
> will not be in /etc/hosts, it is a fairly safe assumption that
> nameservice will be needed for most communication so why not at least open
> the file anyway. Anyone know if this is correct?
>
> Can anyone point me to the appropriate kernel source files (I guess in
> the IP stack) to investigate this further?
No, this is actually a resolver issue, not kernel. Try the glibc
source instead.
Wil
--
W. Reilly Cooley wcooley@nakedape.cc
Naked Ape Consulting http://nakedape.cc
LNXS: Linux/GNU for servers, networks, and http://lnxs.org
people who take care of them. *Now with integrated crypto!*
irc.openprojects.net #lnxs
The penalty for laughing in a courtroom is six months in jail; if it
were not for this penalty, the jury would never hear the evidence.
-- H. L. Mencken
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/
IRC Channel: irc.openprojects.net / #kernelnewbies
Web Page: http://www.surriel.com/kernelnewbies.shtml