mdlayher / netlink

Package netlink provides low-level access to Linux netlink sockets (AF_NETLINK). MIT Licensed.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

netlink receive: no such file or directory

networkop opened this issue · comments

I can't seem to use this package with WSL2. I've tried running test examples from devlink and ethtool and getting the above error.
That being said, WSL does have some weird configuration, which could be the reason why I'm getting this error:

CONFIG_NETFILTER_NETLINK=y
# CONFIG_NETFILTER_NETLINK_ACCT is not set
CONFIG_NETFILTER_NETLINK_QUEUE=y
CONFIG_NETFILTER_NETLINK_LOG=y
# CONFIG_NETFILTER_NETLINK_OSF is not set
CONFIG_NF_CT_NETLINK=y
# CONFIG_NETFILTER_NETLINK_GLUE_CT is not set
CONFIG_NETLINK_DIAG=y
# CONFIG_ETHTOOL_NETLINK is not set
# CONFIG_THERMAL_NETLINK is not set
# CONFIG_QUOTA_NETLINK_INTERFACE is not set

Could the above be the issue? and if yes, is this something documented anywhere (outside of linux kernel source code)?

Here's an example code I tried running (ethtool example)

package main

import (
	"fmt"

	"github.com/mdlayher/ethtool"
)

func main() {
	c, err := ethtool.New()
	if err != nil {
		fmt.Println(err)

	}
	defer c.Close()

	ls, err := c.LinkStates()
	if err != nil {
		fmt.Println(err)

	}
	for _, l := range ls {
		fmt.Printf("%+v\n", l)
	}

}

and this results in:

netlink receive: no such file or directory
panic: runtime error: invalid memory address or nil pointer dereference
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x49e554]

goroutine 1 [running]:
github.com/mdlayher/ethtool.(*Client).Close(0x203000)
        /home/user/go/pkg/mod/github.com/mdlayher/ethtool@v0.0.0-20211028163843-288d040e9d60/client.go:250 +0x14
panic({0x4ae220, 0x56aa20})
        /home/user/.local/go/src/runtime/panic.go:1038 +0x215
github.com/mdlayher/ethtool.(*Client).LinkStates(0x4e26a0)
        /home/user/go/pkg/mod/github.com/mdlayher/ethtool@v0.0.0-20211028163843-288d040e9d60/client.go:143 +0x14
main.main()
        /home/user/test/main.go:17 +0xeb
exit status 2

Not really sure where to begin with this one. My guess is that WSL2 doesn't support those particular genetlink families. If you try listing the families, what does it show?

This is what I get when i do (genetlink.Conn) ListFamilies():

{ID:16 Version:2 Name:nlctrl Groups:[{ID:16 Name:notify}]}
{ID:19 Version:1 Name:acpi_event Groups:[{ID:2 Name:acpi_mc_group}]}
{ID:20 Version:1 Name:tcp_metrics Groups:[]}
{ID:21 Version:1 Name:wireguard Groups:[]}
{ID:22 Version:1 Name:team Groups:[{ID:3 Name:change_event}]}
{ID:23 Version:2 Name:NET_DM Groups:[{ID:1 Name:events}]}
{ID:24 Version:1 Name:IPVS Groups:[]}
{ID:25 Version:1 Name:SEG6 Groups:[]}
{ID:26 Version:1 Name:TASKSTATS Groups:[]}

Seems to be working as intended to me. Try out my taskstats or wgctrl-go libraries since the families appear to be supported.

I'm going to close this out, but feel free to follow up if something still seems amiss!