File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed
tools/testing/selftests/net Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,20 @@ slowwait_for_counter()
125125 slowwait " $timeout " until_counter_is " >= $(( base + delta)) " " $@ "
126126}
127127
128+ remove_ns_list ()
129+ {
130+ local item=$1
131+ local ns
132+ local ns_list=(" ${NS_LIST[@]} " )
133+ NS_LIST=()
134+
135+ for ns in " ${ns_list[@]} " ; do
136+ if [ " ${ns} " != " ${item} " ]; then
137+ NS_LIST+=(" ${ns} " )
138+ fi
139+ done
140+ }
141+
128142cleanup_ns ()
129143{
130144 local ns=" "
@@ -136,6 +150,8 @@ cleanup_ns()
136150 if ! busywait $BUSYWAIT_TIMEOUT ip netns list \| grep -vq " ^$ns $" & > /dev/null; then
137151 echo " Warn: Failed to remove namespace $ns "
138152 ret=1
153+ else
154+ remove_ns_list " ${ns} "
139155 fi
140156 done
141157
@@ -154,17 +170,14 @@ setup_ns()
154170 local ns=" "
155171 local ns_name=" "
156172 local ns_list=()
157- local ns_exist=
158173 for ns_name in " $@ " ; do
159174 # Some test may setup/remove same netns multi times
160175 if unset ${ns_name} 2> /dev/null; then
161176 ns=" ${ns_name,,} -$( mktemp -u XXXXXX) "
162177 eval readonly ${ns_name} =" $ns "
163- ns_exist=false
164178 else
165179 eval ns=' $' ${ns_name}
166180 cleanup_ns " $ns "
167- ns_exist=true
168181 fi
169182
170183 if ! ip netns add " $ns " ; then
@@ -173,7 +186,7 @@ setup_ns()
173186 return $ksft_skip
174187 fi
175188 ip -n " $ns " link set lo up
176- ! $ns_exist && ns_list+=(" $ns " )
189+ ns_list+=(" $ns " )
177190 done
178191 NS_LIST+=(" ${ns_list[@]} " )
179192}
You can’t perform that action at this time.
0 commit comments