golang / go

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

x/net/route: parseInterfaceMessage broken on Dragonfly #46674

Open falsifian opened 3 years ago

falsifian commented 3 years ago

Note: I think I know how to fix this, and hope to have a patch ready soon. I'm filing this bug first to organize my thoughts and in case it's helpful.

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

Git commit f21be2fdc.

falsifian angel-dfly go $ bin/go version
go version go1.16 dragonfly/amd64

Does this issue reproduce with the latest release?

I haven't tried, but it almost certainly will, since no Dragonfly implementation of parseInterfaceAddrMessage is there.

What operating system and processor architecture are you using (go env)?

go env Output
falsifian angel-dfly go $ bin/go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/falsifian/.cache/go-build"
GOENV="/home/falsifian/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="dragonfly"
GOINSECURE=""
GOMODCACHE="/home/falsifian/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="dragonfly"
GOPATH="/home/falsifian/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/falsifian/src/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/falsifian/src/go/pkg/tool/dragonfly_amd64"
GOVCS=""
GOVERSION="go1.16"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1287776679=/tmp/go-build -gno-record-gcc-switches"

What did you do?

route.ParseRIB can't parse messages of type RTM_IFINFO, and omits them instead.

For example, a call to net.InterfaceByName("tun0") (in the net package) returns an error, even if tun0 exists.

The list returned by route.ParseRIB omits all the routing messages of type RTM_IFINFO, which in turn is because the library is trying to use the generic parseInterfaceMessage implementation in interface_classic.go, which doesn't work since DragonflyBSD's RTM_VERSION got bumped to 7 in commit 43a37315. Related: #34368.

I guess the solution will be to implement a Dragonfly-specific parseInterfaceMessage; this is already done for FreeBSD and OpenBSD.

gopherbot commented 3 years ago

Change https://golang.org/cl/328331 mentions this issue: x/net: Fix interface message parsing for dfly RTM_VERSION 7.