From ecd35d36783c51dd6c45df7291c39e548a41d796 Mon Sep 17 00:00:00 2001 From: Qiu Jian Date: Thu, 23 Jun 2022 13:31:39 +0800 Subject: [PATCH] fix: fail to detect host physical nics --- pkg/util/sysutils/nics.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/util/sysutils/nics.go b/pkg/util/sysutils/nics.go index df3072d90a..6d3fa98982 100644 --- a/pkg/util/sysutils/nics.go +++ b/pkg/util/sysutils/nics.go @@ -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"))