Skip to contentSkip to conversation

selftests/net/lib: no need to record ns name if it already exist

PATCH Applied Hangbin Liu 3 participants 3 messages May 14, 2024 – May 16, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/net/lib: no need to record ns name if it already exist

There is no need to add the name to ns_list again if the netns already recoreded.

Fixes 25ae948b4478 ("selftests/net: add lib.sh")
---
 tools/testing/selftests/net/lib.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tools/testing/selftests/net/lib.sh +4 -2
index f9fe182dfbd4..56a9454b7ba3 100644
@@ -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"
 }
Signature · 1 line
2.43.0
#2 lore raw
In reply to Hangbin Liu
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:

Quoted 8 lines · On Tue, 14 May 2024 10:33:59 +0800 you wrote:

There is no need to add the name to ns_list again if the netns already recoreded.

Fixes 25ae948b4478 ("selftests/net: add lib.sh")
---
 tools/testing/selftests/net/lib.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Here is the summary with links:
- [net] selftests/net/lib: no need to record ns name if it already exist

    https://git.kernel.org/netdev/net/c/83e93942796d

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html