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

wasted open() on /etc/resolv.conf?




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?

--Mike

Michael B. Rash
http://www.math.umd.edu/~mbr


-
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