summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHangbin Liu <liuhangbin@gmail.com>2024-05-14 10:33:59 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-05-30 09:45:02 +0200
commit898212413f1ab59b2a9f6e407bb8d1e6782a748c (patch)
tree569688c54e0a0b5be09cc927f539957103564325
parentebe7716b077883666421e126b718966f4870dc2b (diff)
selftests/net/lib: no need to record ns name if it already exist
[ Upstream commit 83e93942796db58652288f0391ac00072401816f ] There is no need to add the name to ns_list again if the netns already recoreded. Fixes: 25ae948b4478 ("selftests/net: add lib.sh") Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--tools/testing/selftests/net/lib.sh6
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh
index f9fe182dfbd4..56a9454b7ba3 100644
--- a/tools/testing/selftests/net/lib.sh
+++ b/tools/testing/selftests/net/lib.sh
@@ -73,15 +73,17 @@ setup_ns()
local ns=""
local ns_name=""
local ns_list=""
+ local ns_exist=
for ns_name in "$@"; do
# Some test may setup/remove same netns multi times
if unset ${ns_name} 2> /dev/null; then
ns="${ns_name,,}-$(mktemp -u XXXXXX)"
eval readonly ${ns_name}="$ns"
+ ns_exist=false
else
eval ns='$'${ns_name}
cleanup_ns "$ns"
-
+ ns_exist=true
fi
if ! ip netns add "$ns"; then
@@ -90,7 +92,7 @@ setup_ns()
return $ksft_skip
fi
ip -n "$ns" link set lo up
- ns_list="$ns_list $ns"
+ ! $ns_exist && ns_list="$ns_list $ns"
done
NS_LIST="$NS_LIST $ns_list"
}