selftests: forwarding: devlink_lib: Support port-less topologies
authorPetr Machata <petrm@nvidia.com>
Wed, 30 Sep 2020 10:49:09 +0000 (12:49 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 30 Sep 2020 21:06:54 +0000 (14:06 -0700)
Some selftests may not need any actual ports. Technically those are not
forwarding selftests, but devlink_lib can still be handy. Fall back on
NETIF_NO_CABLE in those cases.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/net/forwarding/devlink_lib.sh

index cf4e5daf767b6e63bdc754f58f7e1fd3cf054c56..9c12c4fd3afc942699dc17f87ef0a6fd5a6ac9b9 100644 (file)
@@ -5,7 +5,7 @@
 # Defines
 
 if [[ ! -v DEVLINK_DEV ]]; then
-       DEVLINK_DEV=$(devlink port show "${NETIFS[p1]}" -j \
+       DEVLINK_DEV=$(devlink port show "${NETIFS[p1]:-$NETIF_NO_CABLE}" -j \
                             | jq -r '.port | keys[]' | cut -d/ -f-2)
        if [ -z "$DEVLINK_DEV" ]; then
                echo "SKIP: ${NETIFS[p1]} has no devlink device registered for it"