mirror of
https://github.com/vishvananda/netlink
synced 2025-01-23 07:54:09 +00:00
332a6983d9
This patch adds very basic support for getting information about devlink devices which are typically PCI devices which exposes Networking switch or legacy devices. This information includes bus name, device name and eswitch modes. This is done through devlink family of commands via generic netlink sockets provided by Linux kernel. DevlinkDevice represents a devlink device which is identified by bus name and device name (unlike interface index for netdevices). It contains the DevlinkDevAttrs device attributes. Currently only eswitch attributes are queried. In future more attributes such as port, shared buffer, traffic class will be added. Signed-off-by: Parav Pandit <parav@mellanox.com>
35 lines
632 B
Go
35 lines
632 B
Go
// +build linux
|
|
|
|
package netlink
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func setupDevlinkKModule(t *testing.T, name string) {
|
|
skipUnlessRoot(t)
|
|
file, err := ioutil.ReadFile("/proc/modules")
|
|
if err != nil {
|
|
t.Fatal("Failed to open /proc/modules", err)
|
|
}
|
|
for _, line := range strings.Split(string(file), "\n") {
|
|
n := strings.Split(line, " ")[0]
|
|
if n == name {
|
|
return
|
|
}
|
|
|
|
}
|
|
t.Skipf("Test requires kmodule %q.", name)
|
|
}
|
|
|
|
func TestDevLinkGetDeviceList(t *testing.T) {
|
|
minKernelRequired(t, 4, 12)
|
|
setUpNetlinkTestWithKModule(t, "devlink")
|
|
_, err := DevLinkGetDeviceList()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|