From: Mikio Hara Date: Wed, 28 Aug 2013 10:49:17 +0000 (+0900) Subject: net: BUG section for ReadFrom, ReadFromIP methods of IPConn on "ip4" network X-Git-Tag: go1.2rc2~403 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a8b4a1e63a55f55bfbb9edc34be841d802444874;p=gostls13.git net: BUG section for ReadFrom, ReadFromIP methods of IPConn on "ip4" network Fixes #3944. R=golang-dev, r CC=golang-dev https://golang.org/cl/13263043 --- diff --git a/src/pkg/net/ipraw_test.go b/src/pkg/net/ipraw_test.go index 1abaf885b2..5bee21ad3a 100644 --- a/src/pkg/net/ipraw_test.go +++ b/src/pkg/net/ipraw_test.go @@ -202,7 +202,7 @@ func TestPacketConnICMPEcho(t *testing.T) { if _, _, err := c.ReadFrom(rb); err != nil { t.Fatalf("PacketConn.ReadFrom failed: %v", err) } - // TODO: fix issue 3944 + // See BUG section. //if net == "ip4" { // rb = ipv4Payload(rb) //} diff --git a/src/pkg/net/iprawsock_posix.go b/src/pkg/net/iprawsock_posix.go index a73939fe93..401adda867 100644 --- a/src/pkg/net/iprawsock_posix.go +++ b/src/pkg/net/iprawsock_posix.go @@ -11,6 +11,18 @@ import ( "time" ) +// BUG(mikio): On every POSIX platform, reads from the "ip4" network +// using the ReadFrom or ReadFromIP method might not return a complete +// IPv4 packet, including its header, even if there is space +// available. This can occur even in cases where Read or ReadMsgIP +// could return a complete packet. For this reason, it is recommended +// that you do not uses these methods if it is important to receive a +// full packet. +// +// The Go 1 compatibliity guidelines make it impossible for us to +// change the behavior of these methods; use Read or ReadMsgIP +// instead. + func sockaddrToIP(sa syscall.Sockaddr) Addr { switch sa := sa.(type) { case *syscall.SockaddrInet4: