From 9744be3170135285c6d7017134e5ae70e75d9afb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Juraj=20Linke=C5=A1?= Date: Fri, 12 Nov 2021 14:34:52 +0100 Subject: [PATCH] fix(vpp_device): pci address existence condition MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The function get_pci_addr could check a different PCI_ADDR in case the netdev device directory doesn't exit. Move the check so that it always uses the proper PCI_ADDR and add a failure case when the netdev device directory doesn't exist. Change-Id: Ibadfea3fba34509cd3ea8f906ac5962c0f01dd17 Signed-off-by: Juraj Linkeš --- resources/libraries/bash/function/device.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/resources/libraries/bash/function/device.sh b/resources/libraries/bash/function/device.sh index 1ad113ddba..86d482068a 100644 --- a/resources/libraries/bash/function/device.sh +++ b/resources/libraries/bash/function/device.sh @@ -518,9 +518,11 @@ function get_pci_addr () { PCI_ADDR=$(basename $(readlink /sys/class/net/${NETDEV}/device)) || { die "Failed to get PCI address of linux network interface!" } - fi - if [ ! -d /sys/bus/pci/devices/${PCI_ADDR} ]; then - die "PCI device ${NETDEV} doesn't exist!" + if [ ! -d /sys/bus/pci/devices/${PCI_ADDR} ]; then + die "PCI device ${PCI_ADDR} doesn't exist!" + fi + else + die "Can't get device info of interface ${NETDEV}!" fi } -- 2.16.6