Merge pull request #14513 from swordqiu/hotfix/qj-host-detect-physical-nics

fix: fail to detect host physical nics
This commit is contained in:
Zexi Li
2022-06-23 16:58:09 +08:00
committed by GitHub
+4 -1
View File
@@ -42,7 +42,10 @@ func Nics() ([]*types.SNicDevInfo, error) {
nics := make([]*types.SNicDevInfo, 0)
for _, nic := range nicDevs {
netPath := filepath.Join(sysNetPath, nic.Name())
if _, err := os.Stat(filepath.Join(netPath, "device")); os.IsNotExist(err) {
// make sure this is a real NIC device
if fi, err := os.Stat(filepath.Join(netPath, "device")); err != nil || fi == nil {
continue
} else if (fi.Mode() & os.ModeSymlink) == 0 {
continue
}
speedStr := GetSysConfig(filepath.Join(netPath, "speed"))