ADD_VF is invoked N times, each time $VF is overwritten.
The restore of the first N-1 VF devices is incorrect.  To fix it, keep
the original name in ORIG_<port> file, and use it for the restore.

Harden tear-down with stderr discarded and `|| true` so missing objects or races
during cleanup do not fail the suite under `set -e`.

Fixes: 289e9f6baa7c ("tests: Add a simple DPDK rte_flow test framework.")
Signed-off-by: Eli Britstein <[email protected]>
---
 tests/system-dpdk-offloads-macros.at | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/tests/system-dpdk-offloads-macros.at 
b/tests/system-dpdk-offloads-macros.at
index 2a4591ced..c6a9ed053 100644
--- a/tests/system-dpdk-offloads-macros.at
+++ b/tests/system-dpdk-offloads-macros.at
@@ -118,7 +118,7 @@ m4_define([ADD_VF],
       AT_CHECK([ip link set $VF down])
       dnl If a prior run left $1 as an altname, rename fails with "File 
exists".
       AT_CHECK([ip link property del dev $VF altname $1 2>/dev/null || true])
-      AT_CHECK([ip link set $VF name $1])
+      AT_CHECK([ip link set $VF name $1 && printf '%s\n' "$VF" > ORIG_$1])
       AT_CHECK([ip link set $1 netns $2])
       AT_CHECK([ovs-vsctl add-port $3 ovs-$1 -- \
                 set interface ovs-$1 external-ids:iface-id="$1" -- \
@@ -136,9 +136,15 @@ m4_define([ADD_VF],
       if test -n "$6"; then
         NS_CHECK_EXEC([$2], [ip route add default via $6])
       fi
-      on_exit "ip netns exec $2 ip link set $1 netns 1; \
-               ip link property del dev $1 altname $VF; \
-               ip link set $1 name $VF"
+      on_exit "orig=\$(cat ORIG_$1 2>/dev/null); \
+               rm -f ORIG_$1 2>/dev/null || true; \
+               ip netns exec $2 ip link set $1 netns 1 2>/dev/null || true; \
+               ip link property del dev \"\$orig\" altname $1 2>/dev/null || 
true; \
+               ip link property del dev $1 altname \"\$orig\" 2>/dev/null || 
true; \
+               ip link set $1 down 2>/dev/null || true; \
+               if test \"\$orig\"; then \
+                 ip link set $1 name \"\$orig\" 2>/dev/null || true; \
+               fi"
     ]
 )
 m4_define([ADD_VETH], [ADD_VF($@)])
-- 
2.34.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to