fix(vpp_device): pci address existence condition 81/34481/3
authorJuraj Linkeš <juraj.linkes@pantheon.tech>
Fri, 12 Nov 2021 13:34:52 +0000 (14:34 +0100)
committerPeter Mikus <pmikus@cisco.com>
Wed, 19 Jan 2022 12:08:34 +0000 (12:08 +0000)
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š <juraj.linkes@pantheon.tech>
resources/libraries/bash/function/device.sh

index 1ad113d..86d4820 100644 (file)
@@ -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
 }