Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: an entry with many aliases in /etc/hosts confuses both cgo and netgo lookup functions #8235

Closed
tamasd opened this issue Jun 19, 2014 · 11 comments

Comments

Projects
None yet
5 participants
@tamasd
Copy link

commented Jun 19, 2014

go version go1.3 darwin/amd64

I cloned the hg repository, and ran ./all.bash. Some network tests have failed. I tried
turning off my firewall. I also removed the repository and recloned the contents. I am
running Mac OS X 10.9.3 on a Late 2013 MacBook Pro.

--- FAIL: TestDialDualStackLocalhost (0.00 seconds)
    dial_test.go:493: Dial failed: dial tcp 127.0.0.1:64057: connection refused
--- FAIL: TestResolveIPAddr (0.00 seconds)
    ipraw_test.go:76: got &net.IPAddr{IP:net.IP{0xfe, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}, Zone:""}; expected &net.IPAddr{IP:net.IP{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}, Zone:""}
--- FAIL: TestResolveTCPAddr (0.00 seconds)
    tcp_test.go:335: ResolveTCPAddr("tcp6", "localhost:7") = &net.TCPAddr{IP:net.IP{0xfe, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}, Port:7, Zone:""}, want &net.TCPAddr{IP:net.IP{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}, Port:7, Zone:""}
--- FAIL: TestResolveUDPAddr (0.00 seconds)
    udp_test.go:22: ResolveUDPAddr("udp6", "localhost:7") = &net.UDPAddr{IP:net.IP{0xfe, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}, Port:7, Zone:""}, want &net.TCPAddr{IP:net.IP{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}, Port:7, Zone:""}
FAIL
FAIL    net 2.087s
@mikioh

This comment has been minimized.

Copy link
Contributor

commented Jun 19, 2014

Comment 1:

Thanks for the report. Looks like latest OS X's /etc/hosts contains
"fe80::1%somewhere_loopback_interface_name" entry as a localhost. This is an issue on
flaky test cases, don't worry about it and sorry for the confusion. I should update my
laptop to OS X Mavericks...
P.S. Probably adding "::1 localhost" entry just before existing ipv6 localhost entry in
/etc/hosts would be a workaround.
@mikioh

This comment has been minimized.

Copy link
Contributor

commented Jun 19, 2014

Comment 2:

Ouch, looks lie almost all the lookup functions in net drop IPv6 scoped addressing zone
identifier. This fails: net.Listen("tcp6", "localhost:0"), because "localhost" is
resolved as "fe80::1" instead of "fe80::1%lo0".
@mikioh

This comment has been minimized.

Copy link
Contributor

commented Jun 19, 2014

Comment 3:

For the record, the default /etc/hosts on OS X Mavericks looks like the following:
--
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost       hostname.local
::1             localhost       hostname.local
fe80::1%lo0     localhost       hostname.local
255.255.255.255 broadcasthost
--
Can you show us your /etc/hosts?
@tamasd

This comment has been minimized.

Copy link
Author

commented Jun 19, 2014

Comment 4:

This is my /etc/hosts file.
--
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost mac lolcathost EbonHawk
255.255.255.255 broadcasthost
::1             localhost lolcathost EbonHawk
fe80::1%lo0 localhost lolcathost
--
@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Jun 19, 2014

Comment 5:

Labels changed: added repo-main, release-go1.4, os-macosx.

@mikioh

This comment has been minimized.

Copy link
Contributor

commented Jun 19, 2014

Comment 6:

I now see the root cause. Your /etc/hosts makes getaddrinfo confusing with many aliases.
You can fix the issue to write:
::1             localhost EbonHawk lolcathost
fe80::1%lo0 localhost lolcathost
instead of
::1             localhost lolcathost EbonHawk
fe80::1%lo0 localhost lolcathost
Will keep this issue to make sure the behavior of net package lookup functions. Also
filed issue #8243 for handling ipv6 zone identifier.

Labels changed: removed os-macosx.

@tamasd

This comment has been minimized.

Copy link
Author

commented Jun 20, 2014

Comment 8:

Thank you, the tests now run fine :)
@rsc

This comment has been minimized.

Copy link
Contributor

commented Sep 16, 2014

Comment 9:

Fix seems too complex. Too late to fix this for 1.4.

Labels changed: added release-go1.5, removed release-go1.4.

Status changed to Accepted.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Sep 16, 2014

Comment 10:

Fix seems too complex. Too late to fix this for 1.4.
@mikioh

This comment has been minimized.

Copy link
Contributor

commented Sep 16, 2014

Comment 11:

Labels changed: added release-none, removed release-go1.5.

@rsc rsc added this to the Unplanned milestone Apr 10, 2015

@rsc rsc removed release-none labels Apr 10, 2015

@mikioh

This comment has been minimized.

Copy link
Contributor

commented Jun 19, 2015

Closing. There's no easy way to solve this sort of issue except keeping files or databases clean.

@mikioh mikioh closed this Jun 19, 2015

@mikioh mikioh changed the title net: ipv6 entries with many aliases in /etc/hosts confuse both cgo and netgo lookup functions net: an entry with many aliases in /etc/hosts confuse both cgo and netgo lookup functions Jun 19, 2015

@mikioh mikioh changed the title net: an entry with many aliases in /etc/hosts confuse both cgo and netgo lookup functions net: an entry with many aliases in /etc/hosts confuses both cgo and netgo lookup functions Jun 19, 2015

@golang golang locked and limited conversation to collaborators Jun 25, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.