Skip to content

Commit 19db745

Browse files
committed
net: relax TestInterfaces and TestInterfaceAddrs for BSD variants
Fixes #15249. Change-Id: I91fc3d6a2df294b21a67d085da6fe661827a850e Reviewed-on: https://go-review.googlesource.com/22079 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 77d3749 commit 19db745

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/net/interface_test.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,16 @@ func testInterfaceMulticastAddrs(t *testing.T, ifi *Interface) (nmaf4, nmaf6 int
183183
}
184184

185185
func testAddrs(t *testing.T, ifat []Addr) (naf4, naf6 int) {
186+
// Note: BSD variants allow assigning any IPv4/IPv6 address
187+
// prefix to IP interface. For example,
188+
// - 0.0.0.0/0 through 255.255.255.255/32
189+
// - ::/0 through ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128
190+
// In other words, there is no tightly-coupled combination of
191+
// interface address prefixes and connected routes.
186192
for _, ifa := range ifat {
187193
switch ifa := ifa.(type) {
188194
case *IPNet:
189-
if ifa == nil || ifa.IP == nil || ifa.IP.IsUnspecified() || ifa.IP.IsMulticast() || ifa.Mask == nil {
195+
if ifa == nil || ifa.IP == nil || ifa.IP.IsMulticast() || ifa.Mask == nil {
190196
t.Errorf("unexpected value: %#v", ifa)
191197
continue
192198
}
@@ -219,7 +225,7 @@ func testAddrs(t *testing.T, ifat []Addr) (naf4, naf6 int) {
219225
}
220226
t.Logf("interface address %q", ifa.String())
221227
case *IPAddr:
222-
if ifa == nil || ifa.IP == nil || ifa.IP.IsUnspecified() || ifa.IP.IsMulticast() {
228+
if ifa == nil || ifa.IP == nil || ifa.IP.IsMulticast() {
223229
t.Errorf("unexpected value: %#v", ifa)
224230
continue
225231
}

0 commit comments

Comments
 (0)