New issue
Advanced search Search tips
Starred by 8 users
Status: Fixed
Owner:
Closed: Aug 2015
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug-Regression



Sign in to add a comment
"localhost." doesn't resolve
Project Member Reported by est...@chromium.org, Jun 4 2015 Back to list
See attached net-internals log from comment #15 in  issue 455825 .

User reports that with the following /etc/hosts, http://foo.localhost:8080 fails to load because of a failure to resolve "localhost.":

/etc/hosts:
127.0.0.1 localhost foo.loc foo.localhost
 
net-internals-log.json
559 KB Download
Cc: rsleevi@chromium.org
rsleevi, do you have ideas why "localhost." might fail to resolve? User mentioned that putting an additional "127.0.0.1 localhost." line in /etc/hosts is a workaround.
Cc: ttuttle@chromium.org davidben@chromium.org
Event ID 1232 shows that it ended up returning ERR_NAME_NOT_RESOLVED after, unfortunately, going out the network (how'd that happen? I don't know! :P)

The attempted resolution for "foo.localhost" was rewritten to "localhost." (Event ID 1231 shows the original associated CONNECT_JOB; this was your change from  Issue 455825 ), but then sent it to the network.

Per RFC 6761 6.3, a couple things
- Per p3, our DNS resolver SHOULD have recognized localhost as special and used loopback and SHOULD NOT have sent to the network (SHOULD != MUST)
- Per p4, the upstream resolver SHOULD have returned the loopback address and ate it then
- Per p5, the authoritative DNS servers SHOULD have handled them

I can only speculate that 4/5 didn't happen for this user, and our lack of 3 caused the issue.

Adding "localhost." to the /etc/hosts lists would work because our Hosts file parser (//net/dns/dns_hosts) isn't smart enough to know about trailing "." squelching suffix searches, because it's just a base::hash_map on DnsHostsKey (see https://code.google.com/p/chromium/codesearch#chromium/src/net/dns/dns_hosts.h&rcl=1433300454&l=60 )

Suggestions (all of them, but any individually would resolve this)
1) DnsTransaction should implement p3 ("Name resolution APIs and libraries") logic for the RFC 6761 hosts
2) Either hash<net::DnsHostKey> ( https://code.google.com/p/chromium/codesearch#chromium/src/net/dns/dns_hosts.h&rcl=1433300454&l=27 ) or ParseHostsWithCommaMode ( https://code.google.com/p/chromium/codesearch#chromium/src/net/dns/dns_hosts.cc&l=156 ) should canonicalize the host entries and appropriately recognize . domains as matching (and probably implicit in the hosts file)


For #2, I'm not sure whether, given a hosts file, if "foo" is an entry for "foo." or "foo" + all the DNS suffix searches (including, implicitly, "."). Probably more research is needed into that format to determine the entire scope of the problem.

For the user, ironically pointed their DNS at a 'well-known good DNS server' (Google's is 8.8.8.8, although plenty of others, such as OpenDNS, exist) would likely have also squelched this error, since even though we didn't do p3, p4/p5 of 6761 would have kicked in.
Comment 3 by al...@emphanos.com, Jun 10 2015
Re: "a 'well-known good DNS server' (Google's is 8.8.8.8, although plenty of others, such as OpenDNS, exist) would likely have also squelched this error"

I'm experiencing the same behavior as the OP, using DNS servers 8.8.8.8 and 75.75.75.75 [On Chromium Version 43.0.2357.81 Ubuntu 15.04 (64-bit)]

The stated workaround (adding "127.0.0.1 localhost." to /etc/hosts) works for me.
Comment 4 by est...@chromium.org, Jun 11 2015
Status: Started
CL in progress implementing suggestion #1 from comment #2: https://codereview.chromium.org/1177933002/
I am also having the same issue (Linux also; Debian "Wheezy").  I've uploaded my log file just in case.


net-internals-log.json
2.1 MB Download
Project Member Comment 6 by bugdroid1@chromium.org, Jun 20 2015
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d1bc206e4635403d342e40d6e04845c029f1ada7

commit d1bc206e4635403d342e40d6e04845c029f1ada7
Author: estark <estark@chromium.org>
Date: Sat Jun 20 00:44:39 2015

Resolve RFC 6761 localhost names to loopback

Per section 6.3, HostResolverImpl should recognize localhost names as
special and resolve as loopback without sending the query over the
network.

This CL also modifies IsLocalhost() to allow trailing dots ( bug 460331 ),
so that IsLocalhost() can be used to detect localhost names that should
resolve to loopback.

BUG= 496479 , 460331 

Review URL: https://codereview.chromium.org/1177933002

Cr-Commit-Position: refs/heads/master@{#335402}

[modify] http://crrev.com/d1bc206e4635403d342e40d6e04845c029f1ada7/net/base/net_util.cc
[modify] http://crrev.com/d1bc206e4635403d342e40d6e04845c029f1ada7/net/base/net_util.h
[modify] http://crrev.com/d1bc206e4635403d342e40d6e04845c029f1ada7/net/base/net_util_unittest.cc
[modify] http://crrev.com/d1bc206e4635403d342e40d6e04845c029f1ada7/net/dns/host_resolver_impl.cc
[modify] http://crrev.com/d1bc206e4635403d342e40d6e04845c029f1ada7/net/dns/host_resolver_impl.h
[modify] http://crrev.com/d1bc206e4635403d342e40d6e04845c029f1ada7/net/dns/host_resolver_impl_unittest.cc
[modify] http://crrev.com/d1bc206e4635403d342e40d6e04845c029f1ada7/net/test/spawned_test_server/base_test_server.cc

Emily: Did you fix this? If so, mind updating the milestone and status?
Comment 8 by est...@chromium.org, Aug 14 2015
Labels: M-45
Status: Fixed
Cc: -ttuttle@chromium.org juliatut...@chromium.org
Sign in to add a comment