Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/net/route: ParseRIB fail to parse utun up InterfaceMessage #71064

Open
ruokeqx opened this issue Dec 30, 2024 · 3 comments
Open

x/net/route: ParseRIB fail to parse utun up InterfaceMessage #71064

ruokeqx opened this issue Dec 30, 2024 · 3 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@ruokeqx
Copy link

ruokeqx commented Dec 30, 2024

Go version

go version go1.22.6 darwin/amd64

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/ruokeqx/Library/Caches/go-build'
GOENV='/Users/ruokeqx/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/ruokeqx/go/pkg/mod'
GOOS='darwin'
GOPATH='/Users/ruokeqx/go'
GOPROXY='https://goproxy.cn,direct'
GOROOT='/usr/local/opt/go1.22'
GOSUMDB='off'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/opt/go1.22/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.22.6'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/d8/c7cqtvp515v7tn7xmvv6v2m00000gn/T/go-build3070326303=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

try parse message from AF_ROUTE socket.

unix.Socket(unix.AF_ROUTE, unix.SOCK_RAW, unix.AF_UNSPEC)
msgs, err := route.ParseRIB(route.RIBTypeRoute, data[:n])

What did you see happen?

ParseRIB skip Interface message that indicate utun interface up

// data fetch from AF_ROUTE socket
data := []byte{112, 0, 5, 14, 0, 0, 0, 0, 81, 128, 0, 0, 28, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 220, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 237, 0, 107, 103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

since no RTA_IFP flag

func (w *wireFormat) parseInterfaceMessage(_ RIBType, b []byte) (Message, error) {
...
	if attrs&syscall.RTA_IFP == 0 {
		return nil, nil
	}
...
}

not sure if it is intended

What did you expect to see?

should return InterfaceMessage with Index and flags?

@dmitshur
Copy link
Contributor

CC @neild, @ianlancetaylor.

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 30, 2024
@dmitshur dmitshur added this to the Unreleased milestone Dec 30, 2024
@ianlancetaylor
Copy link
Member

Currently the code ensures that m.Name is set in the returned InterfaceMessage. If we permit a message for which RTA_IFP is not set, then the Name field won't be set. In the standard library's net package, that in turn will mean returning a value of type net.Interface for which the Name field is not set. How should programs handle an unnamed interface? Why is the name not being returned?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants