selftests: mptcp: simplify pm_nl_change_endpoint
This patch simplified pm_nl_change_endpoint(), using id-based address lookups only. And dropped the fragile way of parsing 'addr' and 'id' from the output of pm_nl_show_endpoints(). Signed-off-by: Geliang Tang <geliang.tang@suse.com> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
d17b968b98
commit
bccefb7624
1 changed files with 8 additions and 29 deletions
|
@ -240,16 +240,6 @@ is_v6()
|
||||||
[ -z "${1##*:*}" ]
|
[ -z "${1##*:*}" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
is_addr()
|
|
||||||
{
|
|
||||||
[ -z "${1##*[.:]*}" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
is_number()
|
|
||||||
{
|
|
||||||
[[ $1 == ?(-)+([0-9]) ]]
|
|
||||||
}
|
|
||||||
|
|
||||||
# $1: ns, $2: port
|
# $1: ns, $2: port
|
||||||
wait_local_port_listen()
|
wait_local_port_listen()
|
||||||
{
|
{
|
||||||
|
@ -379,16 +369,13 @@ pm_nl_show_endpoints()
|
||||||
pm_nl_change_endpoint()
|
pm_nl_change_endpoint()
|
||||||
{
|
{
|
||||||
local ns=$1
|
local ns=$1
|
||||||
local flags=$2
|
local id=$2
|
||||||
local id=$3
|
local flags=$3
|
||||||
local addr=$4
|
|
||||||
local port=""
|
|
||||||
|
|
||||||
if [ $ip_mptcp -eq 1 ]; then
|
if [ $ip_mptcp -eq 1 ]; then
|
||||||
ip -n $ns mptcp endpoint change id $id ${flags//","/" "}
|
ip -n $ns mptcp endpoint change id $id ${flags//","/" "}
|
||||||
else
|
else
|
||||||
if [ $5 -ne 0 ]; then port="port $5"; fi
|
ip netns exec $ns ./pm_nl_ctl set id $id flags $flags
|
||||||
ip netns exec $ns ./pm_nl_ctl set $addr flags $flags $port
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -591,24 +578,16 @@ do_transfer()
|
||||||
for netns in "$ns1" "$ns2"; do
|
for netns in "$ns1" "$ns2"; do
|
||||||
pm_nl_show_endpoints $netns | while read line; do
|
pm_nl_show_endpoints $netns | while read line; do
|
||||||
local arr=($line)
|
local arr=($line)
|
||||||
local addr
|
local nr=0
|
||||||
local port=0
|
|
||||||
local id
|
local id
|
||||||
|
|
||||||
for i in ${arr[@]}; do
|
for i in ${arr[@]}; do
|
||||||
if is_addr $i; then
|
if [ $i = "id" ]; then
|
||||||
addr=$i
|
id=${arr[$nr+1]}
|
||||||
elif is_number $i; then
|
|
||||||
# The minimum expected port number is 10000
|
|
||||||
if [ $i -gt 10000 ]; then
|
|
||||||
port=$i
|
|
||||||
# The maximum id number is 255
|
|
||||||
elif [ $i -lt 255 ]; then
|
|
||||||
id=$i
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
let nr+=1
|
||||||
done
|
done
|
||||||
pm_nl_change_endpoint $netns $sflags $id $addr $port
|
pm_nl_change_endpoint $netns $id $sflags
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue