mirror of
https://github.com/golang/go
synced 2024-11-18 18:04:46 -07:00
net: don't return nil interface address on netbsd
On NetBSD routing sockaddrs for interface address contain sockaddr_dl. R=dave, rsc CC=golang-dev https://golang.org/cl/7085064
This commit is contained in:
parent
9114279c66
commit
12e7397ebb
@ -118,7 +118,9 @@ func interfaceAddrTable(ifindex int) ([]Addr, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ifat = append(ifat, ifa)
|
||||
if ifa != nil {
|
||||
ifat = append(ifat, ifa)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -157,6 +159,8 @@ func newAddr(m *syscall.InterfaceAddrMessage) (Addr, error) {
|
||||
ifa.IP[2], ifa.IP[3] = 0, 0
|
||||
}
|
||||
}
|
||||
default: // Sockaddrs contain syscall.SockaddrDatalink on NetBSD
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return ifa, nil
|
||||
|
@ -75,9 +75,13 @@ func testInterfaceMulticastAddrs(t *testing.T, ifi *Interface) {
|
||||
|
||||
func testAddrs(t *testing.T, ifat []Addr) {
|
||||
for _, ifa := range ifat {
|
||||
switch ifa.(type) {
|
||||
switch v := ifa.(type) {
|
||||
case *IPAddr, *IPNet:
|
||||
t.Logf("\tinterface address %q", ifa.String())
|
||||
if v == nil {
|
||||
t.Errorf("\tunexpected value: %v", ifa)
|
||||
} else {
|
||||
t.Logf("\tinterface address %q", ifa.String())
|
||||
}
|
||||
default:
|
||||
t.Errorf("\tunexpected type: %T", ifa)
|
||||
}
|
||||
@ -86,9 +90,13 @@ func testAddrs(t *testing.T, ifat []Addr) {
|
||||
|
||||
func testMulticastAddrs(t *testing.T, ifmat []Addr) {
|
||||
for _, ifma := range ifmat {
|
||||
switch ifma.(type) {
|
||||
switch v := ifma.(type) {
|
||||
case *IPAddr:
|
||||
t.Logf("\tjoined group address %q", ifma.String())
|
||||
if v == nil {
|
||||
t.Errorf("\tunexpected value: %v", ifma)
|
||||
} else {
|
||||
t.Logf("\tjoined group address %q", ifma.String())
|
||||
}
|
||||
default:
|
||||
t.Errorf("\tunexpected type: %T", ifma)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user