Closed zartbot closed 5 years ago
diff --git a/devices/misc.go b/devices/misc.go
index ee6b14e..e52afb6 100644
--- a/devices/misc.go
+++ b/devices/misc.go
@@ -40,12 +40,22 @@ func GetDeviceID(nicName string) (string, error) {
return "", err
}
// raw should be like /sys/devices/pci0002:00/0000:00:08.0/virtio2/net/ens8
+ // or /sys/devices/pci0000:00/0000:00:01.0/0000:03:00.2/net/ens4f2
raws := strings.Split(raw, "/")
if len(raws) < 5 {
return "", fmt.Errorf("path not correct")
}
- return raws[4], nil
+ // search and validate deviceID
+ for idx := len(raws) - 1; idx >= 0; idx-- {
+ v := strings.Split(raws[idx], ":")
+ if len(v) == 3 {
+ if len(v[0]) == 4 && len(v[1]) == 2 && len(v[2]) == 4 {
+ return raws[idx], nil
+ }
+ }
+ }
+ return "", fmt.Errorf("path not correct")
}
// IsModuleLoaded checks if the kernel has already loaded the driver or not.
I applied your patch untested. Reopen the issue if something is wrong with it.
GetDeviceID function is wrong on some platform
My platform Raw string is :
My Hardware and software version
dpdk-bind.py output...