net: don't use syscall.NET_RT_IFLISTL on FreeBSD

The golang.org/x/net/route package can't parse the RIB returned
by NET_RT_IFLISTL. Use the route.RIBTypeInterface constant
instead, leaving the choice of syscall up to the route package.

Fixes #48553.

Change-Id: Ida4bd6e332c0dc6dc871d3a93cfb56c0fbc93e1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/353611
Trust: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Damien Neil 2021-10-01 17:45:09 -07:00
parent 07a7c6f904
commit a7fe161ccc

View File

@ -11,16 +11,11 @@ import (
)
func interfaceMessages(ifindex int) ([]route.Message, error) {
typ := route.RIBType(syscall.NET_RT_IFLISTL)
rib, err := route.FetchRIB(syscall.AF_UNSPEC, typ, ifindex)
if err != nil {
typ = route.RIBType(syscall.NET_RT_IFLIST)
rib, err = route.FetchRIB(syscall.AF_UNSPEC, typ, ifindex)
rib, err := route.FetchRIB(syscall.AF_UNSPEC, route.RIBTypeInterface, ifindex)
if err != nil {
return nil, err
}
}
return route.ParseRIB(typ, rib)
return route.ParseRIB(route.RIBTypeInterface, rib)
}
// interfaceMulticastAddrTable returns addresses for a specific