mirror of https://github.com/golang/go.git
net: fix parsing of interfaces on plan9 without associated devices
Fixes #72060 Updates #39908 Change-Id: I7d5bda1654753acebc8aa9937d010b41c5722b36 Reviewed-on: https://go-review.googlesource.com/c/go/+/654055 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Russ Cox <rsc@golang.org> Auto-Submit: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
bda9f85e5c
commit
0312e31ed1
|
|
@ -57,6 +57,17 @@ func readInterface(i int) (*Interface, error) {
|
|||
}
|
||||
|
||||
fields := getFields(line)
|
||||
|
||||
// If the interface has no device file then we see two spaces between "device" and
|
||||
// "maxtu" and and getFields treats the two spaces as one delimiter.
|
||||
// Insert a gap for the missing device name.
|
||||
// See https://go.dev/issue/72060.
|
||||
if stringslite.HasPrefix(line, "device maxtu ") {
|
||||
fields = append(fields, "")
|
||||
copy(fields[2:], fields[1:])
|
||||
fields[1] = ""
|
||||
}
|
||||
|
||||
if len(fields) < 4 {
|
||||
return nil, errors.New("invalid interface status file: " + ifcstat)
|
||||
}
|
||||
|
|
@ -163,7 +174,7 @@ func interfaceAddrTable(ifi *Interface) ([]Addr, error) {
|
|||
for line, ok := statusf.readLine(); ok; line, ok = statusf.readLine() {
|
||||
fields := getFields(line)
|
||||
if len(fields) < 1 {
|
||||
return nil, errors.New("cannot parse IP address for interface: " + status)
|
||||
continue
|
||||
}
|
||||
addr := fields[0]
|
||||
ip := ParseIP(addr)
|
||||
|
|
|
|||
Loading…
Reference in New Issue