golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.99k stars 17.54k forks source link

net: Interfaces() fails on Plan 9 if there is a packet interface #39908

Closed fhs closed 4 years ago

fhs commented 4 years ago

What version of Go are you using (go version)?

$ go version
go version devel +master Thu Jun 25 19:13:01 EDT 2020 plan9/amd64

What did you do?

What did you expect to see?

nil error

What did you see instead?

Error returned:

route ip+net: open pkt2/addr: 'pkt2' file not found

The code is assuming pkt2 is a path to a network device (e.g. /net/ether0) and tries to open pkt2/addr to read in the Interface.HardwareAddr: https://github.com/golang/go/blob/c875503cf79f82b7d2dbec85667f330f72ec4557/src/net/interface_plan9.go#L71-L76 It does skip this for the loopback interface (/dev/null device), but it should also skip for packet interfaces. Maybe it should just skip anything without a /net/ prefix.

@gopherbot add labels OS-Plan9, NeedsFix

fhs commented 4 years ago

Tests are also failing:

cpu% cd src/net
cpu% go test -short
--- FAIL: TestInterfaces (0.00s)
    interface_test.go:56: route ip+net: open pkt2/addr: 'pkt2' './home/big/go/src/net/pkt2' does not exist
--- FAIL: TestInterfaceAddrs (0.00s)
    interface_test.go:87: route ip+net: open pkt2/addr: 'pkt2' './home/big/go/src/net/pkt2' does not exist
--- FAIL: TestInterfaceUnicastAddrs (0.00s)
    interface_test.go:106: route ip+net: open pkt2/addr: 'pkt2' './home/big/go/src/net/pkt2' does not exist
--- FAIL: TestInterfaceMulticastAddrs (0.00s)
    interface_test.go:133: route ip+net: open pkt2/addr: 'pkt2' './home/big/go/src/net/pkt2' does not exist
FAIL
exit status: 'net.test 11992: 1'
FAIL    net 40.497s
gopherbot commented 4 years ago

Change https://golang.org/cl/240259 mentions this issue: net: handle more interface types without a hardware address on Plan 9