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: Dial with specified source address selects wrong scoped destination address #11837

Closed
mikioh opened this issue Jul 23, 2015 · 5 comments

Comments

Projects
None yet
4 participants
@mikioh
Copy link
Contributor

commented Jul 23, 2015

When running TestDialRoutingToBlackhole in golang.org/cl/12561, we see the following on various platforms:

# sudo GODEBUG=netdns=go go test -v -run=Blackhole
=== RUN   TestDialRoutingToBlackhole
installing [route add -host -inet6 2404:6800:4004:807::1011/128 ::1 -blackhole]
installing [route add -host 173.194.117.241/32 127.0.0.1 -blackhole]
installing [route add -host 173.194.117.244/32 127.0.0.1 -blackhole]
installing [route add -host 173.194.117.242/32 127.0.0.1 -blackhole]
installing [route add -host 173.194.117.243/32 127.0.0.1 -blackhole]
installing [route add -host 173.194.117.240/32 127.0.0.1 -blackhole]
uninstalling [route add -host -inet6 2404:6800:4004:807::1011/128 ::1 -blackhole]
uninstalling [route add -host 173.194.117.241/32 127.0.0.1 -blackhole]
uninstalling [route add -host 173.194.117.244/32 127.0.0.1 -blackhole]
uninstalling [route add -host 173.194.117.242/32 127.0.0.1 -blackhole]
uninstalling [route add -host 173.194.117.243/32 127.0.0.1 -blackhole]
uninstalling [route add -host 173.194.117.240/32 127.0.0.1 -blackhole]
--- FAIL: TestDialRoutingToBlackhole (9.25s)
    dial_unix_test.go:58: #0/0: elapsed 504.732193ms for {500ms 0001-01-01 00:00:00 +0000 UTC [240f:6d:1ced:1:815b:276a:fe81:7727]:0 false 0 0}
    dial_unix_test.go:58: #0/1: elapsed 504.187842ms for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 false 0 0}
    dial_unix_test.go:66: #0/1: dial tcp 192.168.0.2:0->[2404:6800:4004:807::1011]:80: connect: no route to host for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 false 0 0}
    dial_unix_test.go:58: #0/2: elapsed 505.047238ms for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 false 0 0}
    dial_unix_test.go:66: #0/2: dial tcp 192.168.0.2:0->[2404:6800:4004:807::1011]:80: connect: no route to host for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 false 0 0}
    dial_unix_test.go:58: #0/3: elapsed 502.103169ms for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 false 0 0}
    dial_unix_test.go:66: #0/3: dial tcp 192.168.0.2:0->[2404:6800:4004:807::1011]:80: connect: no route to host for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 false 0 0}
    dial_unix_test.go:58: #0/4: elapsed 503.668158ms for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 false 0 0}
    dial_unix_test.go:66: #0/4: dial tcp 192.168.0.2:0->[2404:6800:4004:807::1011]:80: connect: no route to host for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 false 0 0}
    dial_unix_test.go:58: #0/5: elapsed 502.566501ms for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 false 0 0}
    dial_unix_test.go:66: #0/5: dial tcp 192.168.0.2:0->[2404:6800:4004:807::1011]:80: connect: no route to host for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 false 0 0}
    dial_unix_test.go:58: #1/0: elapsed 502.806944ms for {500ms 0001-01-01 00:00:00 +0000 UTC [240f:6d:1ced:1:815b:276a:fe81:7727]:0 true 0 0}
    dial_unix_test.go:58: #1/1: elapsed 503.798456ms for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 true 0 0}
    dial_unix_test.go:66: #1/1: dial tcp 192.168.0.2:0->[2404:6800:4004:807::1011]:80: connect: no route to host for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 true 0 0}
    dial_unix_test.go:58: #1/2: elapsed 504.844686ms for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 true 0 0}
    dial_unix_test.go:66: #1/2: dial tcp 192.168.0.2:0->[2404:6800:4004:807::1011]:80: connect: no route to host for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 true 0 0}
    dial_unix_test.go:58: #1/3: elapsed 505.069618ms for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 true 0 0}
    dial_unix_test.go:66: #1/3: dial tcp 192.168.0.2:0->[2404:6800:4004:807::1011]:80: connect: no route to host for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 true 0 0}
    dial_unix_test.go:58: #1/4: elapsed 503.374228ms for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 true 0 0}
    dial_unix_test.go:66: #1/4: dial tcp 192.168.0.2:0->[2404:6800:4004:807::1011]:80: connect: no route to host for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 true 0 0}
    dial_unix_test.go:58: #1/5: elapsed 501.865917ms for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 true 0 0}
    dial_unix_test.go:66: #1/5: dial tcp 192.168.0.2:0->[2404:6800:4004:807::1011]:80: connect: no route to host for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 true 0 0}
    dial_unix_test.go:58: #2/0: elapsed 502.118066ms for {500ms 0001-01-01 00:00:00 +0000 UTC [240f:6d:1ced:1:815b:276a:fe81:7727]:0 true 1ns 0}
    dial_unix_test.go:58: #2/1: elapsed 502.060709ms for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 true 1ns 0}
    dial_unix_test.go:66: #2/1: dial tcp 192.168.0.2:0->[2404:6800:4004:807::1011]:80: connect: no route to host for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 true 1ns 0}
    dial_unix_test.go:58: #2/2: elapsed 501.901003ms for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 true 1ns 0}
    dial_unix_test.go:66: #2/2: dial tcp 192.168.0.2:0->[2404:6800:4004:807::1011]:80: connect: no route to host for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 true 1ns 0}
    dial_unix_test.go:58: #2/3: elapsed 504.841677ms for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 true 1ns 0}
    dial_unix_test.go:66: #2/3: dial tcp 192.168.0.2:0->[2404:6800:4004:807::1011]:80: connect: no route to host for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 true 1ns 0}
    dial_unix_test.go:58: #2/4: elapsed 504.515092ms for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 true 1ns 0}
    dial_unix_test.go:66: #2/4: dial tcp 192.168.0.2:0->[2404:6800:4004:807::1011]:80: connect: no route to host for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 true 1ns 0}
    dial_unix_test.go:58: #2/5: elapsed 500.103138ms for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 true 1ns 0}
    dial_unix_test.go:66: #2/5: dial tcp 192.168.0.2:0->[2404:6800:4004:807::1011]:80: connect: no route to host for {500ms 0001-01-01 00:00:00 +0000 UTC 192.168.0.2:0 true 1ns 0}
FAIL

"dial tcp 192.168.0.2:0->[2404:6800:4004:807::1011]:80" looks clearly wrong.

@mikioh mikioh added this to the Go1.6 milestone Jul 23, 2015

@mikioh

This comment has been minimized.

Copy link
Contributor Author

commented Jul 23, 2015

@mikioh

This comment has been minimized.

Copy link
Contributor Author

commented Jul 23, 2015

This issue would not be critical for go1.5 because it implements new Dial using connect-by-name method that tries each IP address until one succeeds.

@pmarks-net

This comment has been minimized.

Copy link
Contributor

commented Jul 23, 2015

Looks like there are two problems here:

  • LocalAddr is a single value, when it should be a mapping from destination prefix to source address. But taking a step back, isn't source address selection supposed to be the kernel's job?
  • If you specify an IPv4 source but connect to an IPv6 destination (or vice versa), the failure requires a timeout to elapse. Instead, Dial should either filter out incompatible destinations, or ignore LocalAddr when using an incompatible destination.
@mikioh

This comment has been minimized.

Copy link
Contributor Author

commented Jul 24, 2015

But taking a step back, isn't source address selection supposed to be the kernel's job?

I don't think so. If the net package abandons taking that responsibility, users could not implement an application which needs to be run on multi-homed nodes. I think that source and/or destination address selection is part of IP routing, and we've introduced the feature for fancy connect-by-name method in go1.5. Seems like we need to make the feature work correctly for both [dst:name, src:literal] and [dst:name, src:wildcard] cases.

@rsc rsc modified the milestones: Unplanned, Go1.6 Dec 5, 2015

@mikioh mikioh modified the milestones: Go1.7, Unplanned Mar 15, 2016

@gopherbot

This comment has been minimized.

Copy link

commented Mar 15, 2016

CL https://golang.org/cl/20586 mentions this issue.

@gopherbot gopherbot closed this in 790053b Mar 16, 2016

@golang golang locked and limited conversation to collaborators Mar 19, 2017

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.