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: ipv4-onlly socket options cannot be applied to AF_INET6 w/ IPV6_V6ONLY=0 socket #8329

Closed
gopherbot opened this issue Jul 4, 2014 · 5 comments

Comments

@gopherbot
Copy link

by omrib@everything.me:

What does 'go version' print?
go version go1.3 darwin/amd64

What steps reproduce the problem?
If possible, include a link to a program on play.golang.org.

1. git clone https://github.com/omribahumi/go-darwin-udp-bug
2. cd go-darwin-udp-bug
3. go test

What happened?
--- FAIL: TestGoUdpListener (0.00 seconds)
    main_test.go:39: Unable to setsockopt() on UDP socket: invalid argument
FAIL
exit status 1
FAIL    _/Users/omrib/workspace/go-darwin-udp-bug   0.013s

What should have happened instead?
Tests should be idential, both should have passed, not just TestSyscalls.
@ianlancetaylor
Copy link
Contributor

Comment 1:

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

@rsc
Copy link
Contributor

rsc commented Sep 16, 2014

Comment 2:

The difference between the two tests is that ListenUDP both creates the socket and calls
Bind to listen to the given address (":1025"). The TestSyscalls version is not doing the
Bind. They are not comparable.
If you need a special socket option before bind, the easiest way to do that is to create
the socket yourself, following the code in TestSyscall (but adding a Bind), and then
call net.FileConn(os.NewFile(fd)) to get a net.Conn for it.
Note that calling the File method on a net.Conn puts it in blocking mode, which will
limit your scalability. So creating the socket yourself is probably the best option
anyway.

Status changed to Unfortunate.

@gopherbot
Copy link
Author

Comment 3 by omrib@everything.me:

What I was trying to show is that the bug is caused because we're calling bind() before
the setsockopt().
You can't use Setsockopt() on sockets created with the standard library on Mac (because
the socket object is returned after a call to bind()).
As for the new bug status, what does "Unfortunate" status mean?

@ianlancetaylor
Copy link
Contributor

Comment 4:

"Unfortunate" means that we aren't going to make any changes.  The bug is closed.

@mikioh
Copy link
Contributor

mikioh commented Sep 18, 2014

Comment 5:

perhaps, it might be an api design flaw but we think that trying to control address
family A protocol stack by using address family B control knob (e.g., consumer, i mean
normal, socket, routing socket, sysctl, blah blah) is waste of time. also this
functionality is not supported on BSD variants. what synchronicity! see
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=193246.
in this case you made an AF_INET6 w/ IPV6_ONLY=0 socket using ListenUDP because you
passed "udp".  A simple fix would be;
s/ListenUDP("udp"/ListenUDP("udp4"/
fwiw:
http://godoc.org/code.google.com/p/go.net/ipv4
http://godoc.org/code.google.com/p/go.net/ipv6

Labels changed: removed release-go1.4.

Status changed to Invalid.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants