-
Notifications
You must be signed in to change notification settings - Fork 18k
net: need to document the behavior regarding the raw protocol over IP? #17738
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
Comments
if we put the protocol name or number like ip4:tcp or ip4:6 then it works at Linux too. |
I'm noticing in strace output based on the sample script provided:
IPPROTO_IP is a dummy protocol for TCP (according to |
As the existing documentation says, the network must have the form For the information about manipulating raw IP sockets, I'm not sure whether documenting the IP protocol stack implementation internal is worth because it's pretty useless for most people and I guess that each operating system's online manual describes the details. For what it's worth, on most IP stack implementations, the protocol number "0" means a wildcard and it designates a default protocol on IP transport when specifying AF_INET or AF_INET6+SOCK_RAW. On BSD variants, the default protocol number for IP transport is "255". On Linux, IIRC, there is no default protocol for IP transport and the kernel returns an error. On most Unix variants, "255" means a raw protocol on IP transport and it can transmit any protocol over IP and receive only the raw protocol over IP. The behavior of the wildcard and the raw protocol on IP transport may differ on other platforms such as Windows, Plan9. |
The Can we make something work everywhere, and then document it? 0? 255? |
The protocol number 255 is one of reserved protocol numbers by IANA, and is used as a platform-dependent scaffold on Unix variants. I don't think it's possible to make the behavior consistent across platforms. Documenting the wildcard behavior is fine if necessary. |
CL https://golang.org/cl/34875 mentions this issue. |
CL https://golang.org/cl/34876 mentions this issue. |
This change clarifies the documentation on Listen and ListenPacket to avoid unnecessary confusion about how the arguments for the connection setup functions are used to make connections. Also replaces "name" or "hostname" with "host name" when the term implies the use of DNS. Updates #17613. Updates #17614. Updates #17615. Fixes #17616. Updates #17738. Updates #17956. Change-Id: I0bad2e143207666f2358d397fc076548ee6c3ae9 Reviewed-on: https://go-review.googlesource.com/34876 Reviewed-by: Ian Lance Taylor <[email protected]>
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.7 linux/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOOS="linux"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build351337243=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
What did you do?
What did you expect to see?
It shows: listen ip4 0.0.0.0: socket: protocol not supported
but it works @ Darwin properly
https://golang.org/pkg/net/#ListenPacket
func ListenPacket(net, laddr string) (PacketConn, error)
ListenPacket announces on the local network address laddr. The network net must be a packet-oriented network: "udp", "udp4", "udp6", "ip", "ip4", "ip6" or "unixgram". For TCP and UDP, the syntax of laddr is "host:port", like "127.0.0.1:8080". If host is omitted, as in ":8080", ListenPacket listens on all available interfaces instead of just the interface with the given host address. See Dial for the syntax of laddr.
What did you see instead?
listen ip4 0.0.0.0: socket: protocol not supported
The text was updated successfully, but these errors were encountered: