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

gopherbot opened this issue Jul 4, 2014 · 5 comments


Copy link

@gopherbot gopherbot commented Jul 4, 2014


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

1. git clone
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
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.
Copy link

@ianlancetaylor ianlancetaylor commented Jul 5, 2014

Comment 1:

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

Copy link

@rsc 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

Status changed to Unfortunate.

Copy link

@gopherbot gopherbot commented Sep 17, 2014

Comment 3 by

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?
Copy link

@ianlancetaylor ianlancetaylor commented Sep 17, 2014

Comment 4:

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

@mikioh 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
in this case you made an AF_INET6 w/ IPV6_ONLY=0 socket using ListenUDP because you
passed "udp".  A simple fix would be;

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.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants