go build error: undefined: unix.IFLA_XDP_FD
chn-lee-yumi opened this issue · 2 comments
chn-lee-yumi commented
code:
package main
import (
"log"
"github.com/jsimonetti/rtnetlink"
)
func main() {
// Dial a connection to the rtnetlink socket
conn, err := rtnetlink.Dial(nil)
if err != nil {
log.Fatal(err)
}
defer conn.Close()
// Request a list of interfaces
msg, err := conn.Link.List()
if err != nil {
log.Fatal(err)
}
log.Printf("%#v", msg)
}
build error:
➜ ServerMonitor go version
go version go1.16.6 darwin/amd64
➜ ServerMonitor GO111MODULE=off GOOS=linux GOARCH=amd64 go build
# github.com/jsimonetti/rtnetlink/internal/unix
../github.com/jsimonetti/rtnetlink/internal/unix/types_linux.go:63:32: undefined: unix.IFLA_XDP_FD
../github.com/jsimonetti/rtnetlink/internal/unix/types_linux.go:64:32: undefined: unix.IFLA_XDP_ATTACHED
../github.com/jsimonetti/rtnetlink/internal/unix/types_linux.go:65:32: undefined: unix.IFLA_XDP_FLAGS
../github.com/jsimonetti/rtnetlink/internal/unix/types_linux.go:66:32: undefined: unix.IFLA_XDP_PROG_ID
../github.com/jsimonetti/rtnetlink/internal/unix/types_linux.go:67:32: undefined: unix.IFLA_XDP_EXPECTED_FD
../github.com/jsimonetti/rtnetlink/internal/unix/types_linux.go:73:32: undefined: unix.XDP_FLAGS_REPLACE
../github.com/jsimonetti/rtnetlink/internal/unix/types_linux.go:75:32: undefined: unix.LWTUNNEL_ENCAP_MPLS
../github.com/jsimonetti/rtnetlink/internal/unix/types_linux.go:76:32: undefined: unix.MPLS_IPTUNNEL_DST
../github.com/jsimonetti/rtnetlink/internal/unix/types_linux.go:77:32: undefined: unix.MPLS_IPTUNNEL_TTL
chn-lee-yumi commented
I manually replaced these const by what I found in kernel's source code. It works fine.
https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/if_link.h#L1181
Maybe it's a bug in "golang.org/x/sys/unix" ?
mdlayher commented
This library builds correctly as of the latest git commit with Go 1.17 and modules enabled. Turning modules off is the likely problem here, so closing.