Closed
Description
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?
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
gabyhelp commentedon Dec 30, 2024
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
dmitshur commentedon Dec 30, 2024
CC @neild, @ianlancetaylor.
ianlancetaylor commentedon Dec 30, 2024
Currently the code ensures that
m.Name
is set in the returnedInterfaceMessage
. If we permit a message for whichRTA_IFP
is not set, then theName
field won't be set. In the standard library's net package, that in turn will mean returning a value of typenet.Interface
for which theName
field is not set. How should programs handle an unnamed interface? Why is the name not being returned?gabyhelp commentedon Jan 2, 2025
We've identified some possible problems with your issue report. Please review
these findings and fix any that you think are appropriate to fix.
I'm just a bot; you probably know better than I do whether these findings really need fixing.
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
ruokeqx commentedon Jan 8, 2025
Hi, this message can be easily reproduced in my mbp(macOS 15.2).
go run main.go
sudo ifconfig utun0 mtu 1500 up
BTW, i have test for many times in my mbp, all message from NET_RT_IFLIST with RTM_IFINFO type has RTA_IFP, not guarantee in all platform.
Maybe filter work should after getting interfaceMessages in standard library? ParseRIB itself just return basic message
ianlancetaylor commentedon Jan 8, 2025
What does the ifconfig program print for the interface? Does it give it a name?
ruokeqx commentedon Jan 9, 2025
ifconfig print nothing, it didn't give interface a name. utun0 exists when the system starts, it already has a name.
gopherbot commentedon Jan 9, 2025
Change https://go.dev/cl/641855 mentions this issue:
net: permit Interface with no Name
net: permit Interface with no Name
[-]x/net/route: ParseRIB fail to parse utun up InterfaceMessage[/-][+]net, x/net/route: ParseRIB fail to parse utun up InterfaceMessage[/+]gopherbot commentedon Feb 4, 2025
Change https://go.dev/cl/646675 mentions this issue:
net: ignore unnamed interfaces in some cases on DragonFly
net: ignore unnamed interfaces on DragonFly