Skip to content

Commit

Permalink
selftests: forwarding: lib: Support NUM_NETIFS of 0
Browse files Browse the repository at this point in the history
So far the case of NUM_NETIFS of 0 has not been interesting. However if
one wishes to reuse the lib.sh routines in a setup of a separate
namespace, being able to import like this is handy.

Therefore replace the {1..$NUM_NETIFS} references, which cause iteration
over 1 and 0, with an explicit for loop like we do in setup_wait() and
tc_offload_check(), so that for NUM_NETIFS of 0 no iteration is done.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Petr Machata authored and David S. Miller committed Nov 20, 2018
1 parent 6f9a506 commit 601bc1c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/testing/selftests/net/forwarding/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ create_netif_veth()
{
local i

for i in $(eval echo {1..$NUM_NETIFS}); do
for ((i = 1; i <= NUM_NETIFS; ++i)); do
local j=$((i+1))

ip link show dev ${NETIFS[p$i]} &> /dev/null
Expand Down Expand Up @@ -135,7 +135,7 @@ if [[ "$NETIF_CREATE" = "yes" ]]; then
create_netif
fi

for i in $(eval echo {1..$NUM_NETIFS}); do
for ((i = 1; i <= NUM_NETIFS; ++i)); do
ip link show dev ${NETIFS[p$i]} &> /dev/null
if [[ $? -ne 0 ]]; then
echo "SKIP: could not find all required interfaces"
Expand Down

0 comments on commit 601bc1c

Please sign in to comment.