Update dependencies

This commit is contained in:
Zlatko Čalušić
2017-06-25 12:06:41 +02:00
parent 0c22253d41
commit 4873fd9ffe
47 changed files with 11212 additions and 9462 deletions

View File

@@ -83,14 +83,14 @@ func (cm *ControlMessage) Parse(b []byte) error {
if lvl != iana.ProtocolIP {
continue
}
switch typ {
case ctlOpts[ctlTTL].name:
switch {
case typ == ctlOpts[ctlTTL].name && l >= ctlOpts[ctlTTL].length:
ctlOpts[ctlTTL].parse(cm, m.Data(l))
case ctlOpts[ctlDst].name:
case typ == ctlOpts[ctlDst].name && l >= ctlOpts[ctlDst].length:
ctlOpts[ctlDst].parse(cm, m.Data(l))
case ctlOpts[ctlInterface].name:
case typ == ctlOpts[ctlInterface].name && l >= ctlOpts[ctlInterface].length:
ctlOpts[ctlInterface].parse(cm, m.Data(l))
case ctlOpts[ctlPacketInfo].name:
case typ == ctlOpts[ctlPacketInfo].name && l >= ctlOpts[ctlPacketInfo].length:
ctlOpts[ctlPacketInfo].parse(cm, m.Data(l))
}
}

21
vendor/golang.org/x/net/ipv4/control_test.go generated vendored Normal file
View File

@@ -0,0 +1,21 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ipv4_test
import (
"testing"
"golang.org/x/net/ipv4"
)
func TestControlMessageParseWithFuzz(t *testing.T) {
var cm ipv4.ControlMessage
for _, fuzz := range []string{
"\f\x00\x00\x00\x00\x00\x00\x00\x14\x00\x00\x00",
"\f\x00\x00\x00\x00\x00\x00\x00\x1a\x00\x00\x00",
} {
cm.Parse([]byte(fuzz))
}
}

View File

@@ -43,3 +43,21 @@ func netAddrToIP4(a net.Addr) net.IP {
}
return nil
}
func opAddr(a net.Addr) net.Addr {
switch a.(type) {
case *net.TCPAddr:
if a == nil {
return nil
}
case *net.UDPAddr:
if a == nil {
return nil
}
case *net.IPAddr:
if a == nil {
return nil
}
}
return a
}

View File

@@ -69,13 +69,16 @@ func TestUDPMultiplePacketConnWithMultipleGroupListeners(t *testing.T) {
}
for _, gaddr := range udpMultipleGroupListenerTests {
c1, err := net.ListenPacket("udp4", "224.0.0.0:1024") // wildcard address with reusable port
c1, err := net.ListenPacket("udp4", "224.0.0.0:0") // wildcard address with reusable port
if err != nil {
t.Fatal(err)
}
defer c1.Close()
c2, err := net.ListenPacket("udp4", "224.0.0.0:1024") // wildcard address with reusable port
_, port, err := net.SplitHostPort(c1.LocalAddr().String())
if err != nil {
t.Fatal(err)
}
c2, err := net.ListenPacket("udp4", net.JoinHostPort("224.0.0.0", port)) // wildcard address with reusable port
if err != nil {
t.Fatal(err)
}
@@ -131,16 +134,29 @@ func TestUDPPerInterfaceSinglePacketConnWithSingleGroupListener(t *testing.T) {
if err != nil {
t.Fatal(err)
}
port := "0"
for i, ifi := range ift {
ip, ok := nettest.IsMulticastCapable("ip4", &ifi)
if !ok {
continue
}
c, err := net.ListenPacket("udp4", ip.String()+":"+"1024") // unicast address with non-reusable port
c, err := net.ListenPacket("udp4", net.JoinHostPort(ip.String(), port)) // unicast address with non-reusable port
if err != nil {
t.Fatal(err)
// The listen may fail when the serivce is
// already in use, but it's fine because the
// purpose of this is not to test the
// bookkeeping of IP control block inside the
// kernel.
t.Log(err)
continue
}
defer c.Close()
if port == "0" {
_, port, err = net.SplitHostPort(c.LocalAddr().String())
if err != nil {
t.Fatal(err)
}
}
p := ipv4.NewPacketConn(c)
if err := p.JoinGroup(&ifi, &gaddr); err != nil {
t.Fatal(err)

View File

@@ -61,7 +61,7 @@ func (c *packetHandler) writeTo(h *Header, p []byte, cm *ControlMessage) error {
}
m.Addr = dst
if err := c.SendMsg(&m, 0); err != nil {
return &net.OpError{Op: "write", Net: c.IPConn.LocalAddr().Network(), Source: c.IPConn.LocalAddr(), Err: err}
return &net.OpError{Op: "write", Net: c.IPConn.LocalAddr().Network(), Source: c.IPConn.LocalAddr(), Addr: opAddr(dst), Err: err}
}
return nil
}

View File

@@ -53,7 +53,7 @@ func (c *payloadHandler) writeTo(b []byte, cm *ControlMessage, dst net.Addr) (n
case *net.IPConn:
n, _, err = c.WriteMsgIP(b, oob, dst.(*net.IPAddr))
default:
return 0, &net.OpError{Op: "write", Net: c.LocalAddr().Network(), Source: c.LocalAddr(), Err: errInvalidConnType}
return 0, &net.OpError{Op: "write", Net: c.LocalAddr().Network(), Source: c.LocalAddr(), Addr: opAddr(dst), Err: errInvalidConnType}
}
return
}

View File

@@ -61,7 +61,7 @@ func (c *payloadHandler) writeTo(b []byte, cm *ControlMessage, dst net.Addr) (in
}
err := c.SendMsg(&m, 0)
if err != nil {
err = &net.OpError{Op: "write", Net: c.PacketConn.LocalAddr().Network(), Source: c.PacketConn.LocalAddr(), Err: err}
err = &net.OpError{Op: "write", Net: c.PacketConn.LocalAddr().Network(), Source: c.PacketConn.LocalAddr(), Addr: opAddr(dst), Err: err}
}
return m.N, err
}