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 ignores local port on Plan 9 #39747

Closed
fhs opened this issue Jun 21, 2020 · 1 comment
Closed

net: Dial ignores local port on Plan 9 #39747

fhs opened this issue Jun 21, 2020 · 1 comment

Comments

@fhs
Copy link
Contributor

@fhs fhs commented Jun 21, 2020

What version of Go are you using (go version)?

$ go version
go version devel +master Sat Jun 20 01:48:54 EDT 2020 plan9/amd64

What did you do?

Run:

package main

import (
	"fmt"
	"net"
)

func main() {
	la, err := net.ResolveTCPAddr("tcp", ":1234")
	if err != nil {
		panic(err)
	}
	d := net.Dialer{
		LocalAddr: la,
	}
	c, err := d.Dial("tcp", "golang.org:80")
	if err != nil {
		panic(err)
	}
	defer c.Close()
	fmt.Printf("local=%v remote=%v\n", c.LocalAddr(), c.RemoteAddr())
}

What did you expect to see?

local=192.168.1.254:1234 remote=172.253.63.141:80

What did you see instead?

local=192.168.1.254:41592 remote=172.253.63.141:80

It should be possible to support this on Plan 9. The control message takes the local port (but not IP) as an argument. From ip(3):

connect ip–address!port!r local

Establish a connection to the remote ip–address and port. If local is specified, it is used as the local port number. If local is not specified but !r is, the system will allocate a restricted port number (less than 1024) for the connection to allow communication with Unix login and exec services. Otherwise a free port number starting at 5000 is chosen. The connect fails if the combination of local and remote address/port pairs are already assigned to another port.

@gopherbot Add labels OS-Plan9, NeedsFix

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 26, 2020

Change https://golang.org/cl/240064 mentions this issue: net: add support for dialing from a custom local port on Plan 9

@gopherbot gopherbot closed this in 152ffca Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.