From 76cc2101c2b540ba0d8d22271713cedc42897adc Mon Sep 17 00:00:00 2001 From: Milan Lenco Date: Fri, 17 Mar 2023 14:59:43 +0100 Subject: [PATCH] Fix getIfNameListForLLOrIfname The function is supposed to accept either a port logical label or an interface name. Uplink probing refactoring broke this function and it stopped recognizing interface name as the input argument. This matters when device model contains port whose interface name and logical label differ from each other. Signed-off-by: Milan Lenco --- pkg/pillar/cmd/zedrouter/networkinstance.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/pillar/cmd/zedrouter/networkinstance.go b/pkg/pillar/cmd/zedrouter/networkinstance.go index 1dfd471d0d..176c73de74 100644 --- a/pkg/pillar/cmd/zedrouter/networkinstance.go +++ b/pkg/pillar/cmd/zedrouter/networkinstance.go @@ -1359,20 +1359,20 @@ func getIfNameListForLLOrIfname( for _, port := range ports { ifNameList = append(ifNameList, port.IfName) } + if len(ifNameList) == 0 { + // llOrIfname is perhaps not a logical label but already an interface name. + if ctx.deviceNetworkStatus.GetPortByIfName(llOrIfname) != nil { + ifNameList = append(ifNameList, llOrIfname) + } + } log.Functionf("ifNameList: %+v", ifNameList) filteredList := make([]string, 0) for _, ifName := range ifNameList { // It is perfectly normal for DNS to list ports which do not actually // exist (and have error reported). - dnsPort := ctx.deviceNetworkStatus.GetPortByIfName(ifName) - if dnsPort != nil { - if _, exists, _ := ctx.networkMonitor.GetInterfaceIndex(ifName); exists { - filteredList = append(filteredList, ifName) - } - } else { - log.Functionf("DeviceNetworkStatus not found for ifName(%s)", - ifName) + if _, exists, _ := ctx.networkMonitor.GetInterfaceIndex(ifName); exists { + filteredList = append(filteredList, ifName) } } if len(filteredList) > 0 {