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: tcp4 and udp4 calls return IPv4-mapped IPv6 addresses on Plan 9 #40016

Closed
fhs opened this issue Jul 3, 2020 · 1 comment
Closed

net: tcp4 and udp4 calls return IPv4-mapped IPv6 addresses on Plan 9 #40016

fhs opened this issue Jul 3, 2020 · 1 comment

Comments

@fhs
Copy link
Contributor

@fhs fhs commented Jul 3, 2020

Dial and Listen returns IPv4-mapped IPv6 addresses for tcp4 and udp4. This happens even if the system has no IPv6 address, and can confuse some Go programs.

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

$ go version
go version devel +master Mon Jun 29 19:58:54 EDT 2020 plan9/386

What did you do?

Run:

package main

import (
	"fmt"
	"net"
)

func main() {
	l, err := net.Listen("tcp4", "127.0.0.1:1234")
	if err != nil {
		panic(err)
	}
	defer l.Close()
	fmt.Printf("Listen Addr: %#v\n", l.Addr().(*net.TCPAddr).IP)

	c, err := net.Dial("udp4", "8.8.8.8:53")
	if err != nil {
		panic(err)
	}
	defer c.Close()
	fmt.Printf("Dial LocalAddr: %#v\n", c.LocalAddr().(*net.UDPAddr).IP)
	fmt.Printf("Dial RemoteAddr: %#v\n", c.RemoteAddr().(*net.UDPAddr).IP)
}

What did you expect to see?

What I see on a Linux system:

Listen Addr: net.IP{0x7f, 0x0, 0x0, 0x1}
Dial LocalAddr: net.IP{0xc0, 0xa8, 0x1, 0xd}
Dial RemoteAddr: net.IP{0x8, 0x8, 0x8, 0x8}

What did you see instead?

Listen Addr: net.IP{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0x7f, 0x0, 0x0, 0x1}
Dial LocalAddr: net.IP{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xa, 0x0, 0x2, 0xf}
Dial RemoteAddr: net.IP{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0x8, 0x8, 0x8, 0x8}

@gopherbot Add label OS-Plan9, NeedsFix

@fhs
Copy link
Contributor Author

@fhs fhs commented Jul 4, 2020

While this might be something we might want to address so that Plan 9 behaves similar to other systems, using IPv4-mapped IPv6 address is still correct. The problem I was having was due to #40045, which is a more serious issue. Closing this one.

@fhs fhs closed this Jul 4, 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.