mirror of
https://github.com/torvalds/linux
synced 2024-07-22 03:01:14 +00:00
Merge branch 'selftests-net-lib-small-fixes'
Matthieu Baerts says: ==================== selftests: net: lib: small fixes While looking at using 'lib.sh' for the MPTCP selftests [1], we found some small issues with 'lib.sh'. Here they are: - Patch 1: fix 'errexit' (set -e) support with busywait. 'errexit' is supported in some functions, not all. A fix for v6.8+. - Patch 2: avoid confusing error messages linked to the cleaning part when the netns setup fails. A fix for v6.8+. - Patch 3: set a variable as local to avoid accidentally changing the value of a another one with the same name on the caller side. A fix for v6.10-rc1+. Link: https://lore.kernel.org/mptcp/5f4615c3-0621-43c5-ad25-55747a4350ce@kernel.org/T/ [1] ==================== Link: https://lore.kernel.org/r/20240605-upstream-net-20240605-selftests-net-lib-fixes-v1-0-b3afadd368c9@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
27bc865408
|
@ -15,7 +15,7 @@ ksft_xfail=2
|
||||||
ksft_skip=4
|
ksft_skip=4
|
||||||
|
|
||||||
# namespace list created by setup_ns
|
# namespace list created by setup_ns
|
||||||
NS_LIST=""
|
NS_LIST=()
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# Helpers
|
# Helpers
|
||||||
|
@ -27,6 +27,7 @@ __ksft_status_merge()
|
||||||
local -A weights
|
local -A weights
|
||||||
local weight=0
|
local weight=0
|
||||||
|
|
||||||
|
local i
|
||||||
for i in "$@"; do
|
for i in "$@"; do
|
||||||
weights[$i]=$((weight++))
|
weights[$i]=$((weight++))
|
||||||
done
|
done
|
||||||
|
@ -67,9 +68,7 @@ loopy_wait()
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
local out
|
local out
|
||||||
out=$("$@")
|
if out=$("$@"); then
|
||||||
local ret=$?
|
|
||||||
if ((!ret)); then
|
|
||||||
echo -n "$out"
|
echo -n "$out"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
@ -139,6 +138,7 @@ cleanup_ns()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for ns in "$@"; do
|
for ns in "$@"; do
|
||||||
|
[ -z "${ns}" ] && continue
|
||||||
ip netns delete "${ns}" &> /dev/null
|
ip netns delete "${ns}" &> /dev/null
|
||||||
if ! busywait $BUSYWAIT_TIMEOUT ip netns list \| grep -vq "^$ns$" &> /dev/null; then
|
if ! busywait $BUSYWAIT_TIMEOUT ip netns list \| grep -vq "^$ns$" &> /dev/null; then
|
||||||
echo "Warn: Failed to remove namespace $ns"
|
echo "Warn: Failed to remove namespace $ns"
|
||||||
|
@ -152,7 +152,7 @@ cleanup_ns()
|
||||||
|
|
||||||
cleanup_all_ns()
|
cleanup_all_ns()
|
||||||
{
|
{
|
||||||
cleanup_ns $NS_LIST
|
cleanup_ns "${NS_LIST[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# setup netns with given names as prefix. e.g
|
# setup netns with given names as prefix. e.g
|
||||||
|
@ -161,7 +161,7 @@ setup_ns()
|
||||||
{
|
{
|
||||||
local ns=""
|
local ns=""
|
||||||
local ns_name=""
|
local ns_name=""
|
||||||
local ns_list=""
|
local ns_list=()
|
||||||
local ns_exist=
|
local ns_exist=
|
||||||
for ns_name in "$@"; do
|
for ns_name in "$@"; do
|
||||||
# Some test may setup/remove same netns multi times
|
# Some test may setup/remove same netns multi times
|
||||||
|
@ -177,13 +177,13 @@ setup_ns()
|
||||||
|
|
||||||
if ! ip netns add "$ns"; then
|
if ! ip netns add "$ns"; then
|
||||||
echo "Failed to create namespace $ns_name"
|
echo "Failed to create namespace $ns_name"
|
||||||
cleanup_ns "$ns_list"
|
cleanup_ns "${ns_list[@]}"
|
||||||
return $ksft_skip
|
return $ksft_skip
|
||||||
fi
|
fi
|
||||||
ip -n "$ns" link set lo up
|
ip -n "$ns" link set lo up
|
||||||
! $ns_exist && ns_list="$ns_list $ns"
|
! $ns_exist && ns_list+=("$ns")
|
||||||
done
|
done
|
||||||
NS_LIST="$NS_LIST $ns_list"
|
NS_LIST+=("${ns_list[@]}")
|
||||||
}
|
}
|
||||||
|
|
||||||
tc_rule_stats_get()
|
tc_rule_stats_get()
|
||||||
|
|
Loading…
Reference in a new issue