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: ListenPacket can't be used on multicast address #34728

Open
quentinmit opened this issue Oct 7, 2019 · 3 comments

Comments

@quentinmit
Copy link
Contributor

commented Oct 7, 2019

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

go version go1.12.9

Does this issue reproduce with the latest release?

Yes, the code is unchanged on master.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/quentin/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/quentin/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/kn/0gfzt13x37j63313z_5szy3h0000gn/T/go-build593496325=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

net.ListenPacket("udp4", "224.0.0.128:5076")

What did you expect to see?

A socket bound to 224.0.0.128:5076 (but not joined to a multicast group)

What did you see instead?

A socket bound to 0.0.0.0:5076 (and not joined to any multicast group)

net.ListenPacket's documentation says:

For UDP and IP networks, if the host in the address parameter is empty or a literal unspecified IP address, ListenPacket listens on all available IP addresses of the local system except multicast IP addresses.

But in fact it also applies this logic if the address is a multicast address. I suspect this is because net.ListenMulticastUDP is documented as having this behavior:

ListenMulticastUDP listens on all available IP addresses of the local system including the group, multicast IP address.

and it shares an implementation function with ListenPacket:

https://github.com/golang/go/blob/master/src/net/sock_posix.go#L210

And no, golang.org/x/net/ipv4 does not provide a workaround here, because all of its APIs require that you start with net.Listen* to get a net.PacketConn. Likewise, the syscall package doesn't provide an escape hatch because net.FilePacketConn is not implemented on Windows (though I will likely end up doing that anyway, with my resulting code only supporting POSIX environments).

quentinmit added a commit to quentinmit/go-pvaccess that referenced this issue Oct 7, 2019
@katiehockman

This comment has been minimized.

Copy link
Contributor

commented Oct 7, 2019

/cc @bradfitz

@bradfitz

This comment has been minimized.

Copy link
Member

commented Oct 7, 2019

/cc @mikioh

@networkimprov

This comment has been minimized.

Copy link

commented Oct 7, 2019

Last issue-tracker comments by mikioh were last spring, despite several CCs since. Maybe his github notifications are off?

https://github.com/golang/go/issues?utf8=%E2%9C%93&q=is%3Aissue+commenter%3Amikioh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.