]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
selftests: forwarding: lib: Split out setup_wait_dev()
authorPetr Machata <petrm@mellanox.com>
Thu, 28 Jun 2018 16:56:20 +0000 (18:56 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sat, 30 Jun 2018 11:34:09 +0000 (20:34 +0900)
Split out of setup_wait() a function setup_wait_dev() that waits for a
single device. This gives tests the opportunity to wait for a selected
device after they tinkered with its upness.

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

index 1dfdf14894e29cb9e37c011c5065f3c99a8d4893..ac1df4860fbe98800db19695a7474c4611bfc124 100644 (file)
@@ -185,18 +185,25 @@ log_info()
        echo "INFO: $msg"
 }
 
+setup_wait_dev()
+{
+       local dev=$1; shift
+
+       while true; do
+               ip link show dev $dev up \
+                       | grep 'state UP' &> /dev/null
+               if [[ $? -ne 0 ]]; then
+                       sleep 1
+               else
+                       break
+               fi
+       done
+}
+
 setup_wait()
 {
        for i in $(eval echo {1..$NUM_NETIFS}); do
-               while true; do
-                       ip link show dev ${NETIFS[p$i]} up \
-                               | grep 'state UP' &> /dev/null
-                       if [[ $? -ne 0 ]]; then
-                               sleep 1
-                       else
-                               break
-                       fi
-               done
+               setup_wait_dev ${NETIFS[p$i]}
        done
 
        # Make sure links are ready.