]> Cypherpunks repositories - gostls13.git/commitdiff
net: don't use syscall.NET_RT_IFLISTL on FreeBSD
authorDamien Neil <dneil@google.com>
Sat, 2 Oct 2021 00:45:09 +0000 (17:45 -0700)
committerDamien Neil <dneil@google.com>
Sat, 2 Oct 2021 16:05:55 +0000 (16:05 +0000)
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>

src/net/interface_freebsd.go

index 2b51fcb632a3f7add6cb1a0ece5b920899263e4d..8536bd3cf6482bbd46a9934497c1c0705fd3d8bf 100644 (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)
+       rib, err := route.FetchRIB(syscall.AF_UNSPEC, route.RIBTypeInterface, ifindex)
        if err != nil {
-               typ = route.RIBType(syscall.NET_RT_IFLIST)
-               rib, err = route.FetchRIB(syscall.AF_UNSPEC, typ, ifindex)
-               if err != nil {
-                       return nil, err
-               }
+               return nil, err
        }
-       return route.ParseRIB(typ, rib)
+       return route.ParseRIB(route.RIBTypeInterface, rib)
 }
 
 // interfaceMulticastAddrTable returns addresses for a specific