From cff73c4950c6bc0031e9896a87507029857c0737 Mon Sep 17 00:00:00 2001 From: Andrea Panattoni Date: Tue, 4 Jul 2023 14:33:26 +0200 Subject: [PATCH] Avoid logging `devlink` warning Devlink mode is not supported by every SR-IOV NIC model. Signed-off-by: Andrea Panattoni --- pkg/utils/utils.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 37888e4b1..49cf27a00 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -2,6 +2,7 @@ package utils import ( "bytes" + "errors" "fmt" "io/ioutil" "math/rand" @@ -720,10 +721,16 @@ func generateRandomGUID() net.HardwareAddr { func GetNicSriovMode(pciAddress string) (string, error) { glog.V(2).Infof("GetNicSriovMode(): device %s", pciAddress) + devLink, err := netlink.DevLinkGetDeviceByName("pci", pciAddress) if err != nil { + if errors.Is(err, syscall.ENODEV) { + // the device doesn't support devlink + return "", nil + } return "", err } + return devLink.Attrs.Eswitch.Mode, nil }