Commit dda61b3d authored by Geliang Tang's avatar Geliang Tang Committed by Jakub Kicinski

selftests: mptcp: add wrapper for showing addrs

This patch implemented a new function named pm_nl_show_endpoints(), wrapped
the PM netlink commands 'ip mptcp endpoint show' and 'pm_nl_ctl dump' in
it, used a new argument 'ip_mptcp' to choose which one to use to show all
the PM endpoints.

Used this wrapper in do_transfer() instead of using the pm_nl_ctl commands
directly.

The original 'pos+=5' in the remoing tests only works for the output of
'pm_nl_ctl show':

  id 1 flags subflow 10.0.1.1

It doesn't work for the output of 'ip mptcp endpoint show':

  10.0.1.1 id 1 subflow

So implemented a more flexible approach to get the address ID from the PM
dump output to fit for both commands.
Signed-off-by: default avatarGeliang Tang <geliang.tang@suse.com>
Signed-off-by: default avatarMat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 34aa6e3b
...@@ -365,6 +365,17 @@ pm_nl_flush_endpoint() ...@@ -365,6 +365,17 @@ pm_nl_flush_endpoint()
fi fi
} }
pm_nl_show_endpoints()
{
local ns=$1
if [ $ip_mptcp -eq 1 ]; then
ip -n $ns mptcp endpoint show
else
ip netns exec $ns ./pm_nl_ctl dump
fi
}
do_transfer() do_transfer()
{ {
listener_ns="$1" listener_ns="$1"
...@@ -472,20 +483,25 @@ do_transfer() ...@@ -472,20 +483,25 @@ do_transfer()
elif [ $addr_nr_ns1 -lt 0 ]; then elif [ $addr_nr_ns1 -lt 0 ]; then
let rm_nr_ns1=-addr_nr_ns1 let rm_nr_ns1=-addr_nr_ns1
if [ $rm_nr_ns1 -lt 8 ]; then if [ $rm_nr_ns1 -lt 8 ]; then
counter=1 counter=0
pos=1 pm_nl_show_endpoints ${listener_ns} | while read line; do
dump=(`ip netns exec ${listener_ns} ./pm_nl_ctl dump`) local arr=($line)
if [ ${#dump[@]} -gt 0 ]; then local nr=0
while [ $counter -le $rm_nr_ns1 ]
do for i in ${arr[@]}; do
id=${dump[$pos]} if [ $i = "id" ]; then
rm_addr=$(rm_addr_count ${connector_ns}) if [ $counter -eq $rm_nr_ns1 ]; then
pm_nl_del_endpoint ${listener_ns} $id break
wait_rm_addr ${connector_ns} ${rm_addr} fi
let counter+=1 id=${arr[$nr+1]}
let pos+=5 rm_addr=$(rm_addr_count ${connector_ns})
pm_nl_del_endpoint ${listener_ns} $id
wait_rm_addr ${connector_ns} ${rm_addr}
let counter+=1
fi
let nr+=1
done done
fi done
elif [ $rm_nr_ns1 -eq 8 ]; then elif [ $rm_nr_ns1 -eq 8 ]; then
pm_nl_flush_endpoint ${listener_ns} pm_nl_flush_endpoint ${listener_ns}
elif [ $rm_nr_ns1 -eq 9 ]; then elif [ $rm_nr_ns1 -eq 9 ]; then
...@@ -520,21 +536,27 @@ do_transfer() ...@@ -520,21 +536,27 @@ do_transfer()
elif [ $addr_nr_ns2 -lt 0 ]; then elif [ $addr_nr_ns2 -lt 0 ]; then
let rm_nr_ns2=-addr_nr_ns2 let rm_nr_ns2=-addr_nr_ns2
if [ $rm_nr_ns2 -lt 8 ]; then if [ $rm_nr_ns2 -lt 8 ]; then
counter=1 counter=0
pos=1 pm_nl_show_endpoints ${connector_ns} | while read line; do
dump=(`ip netns exec ${connector_ns} ./pm_nl_ctl dump`) local arr=($line)
if [ ${#dump[@]} -gt 0 ]; then local nr=0
while [ $counter -le $rm_nr_ns2 ]
do for i in ${arr[@]}; do
# rm_addr are serialized, allow the previous one to complete if [ $i = "id" ]; then
id=${dump[$pos]} if [ $counter -eq $rm_nr_ns2 ]; then
rm_addr=$(rm_addr_count ${listener_ns}) break
pm_nl_del_endpoint ${connector_ns} $id fi
wait_rm_addr ${listener_ns} ${rm_addr} # rm_addr are serialized, allow the previous one to
let counter+=1 # complete
let pos+=5 id=${arr[$nr+1]}
rm_addr=$(rm_addr_count ${listener_ns})
pm_nl_del_endpoint ${connector_ns} $id
wait_rm_addr ${listener_ns} ${rm_addr}
let counter+=1
fi
let nr+=1
done done
fi done
elif [ $rm_nr_ns2 -eq 8 ]; then elif [ $rm_nr_ns2 -eq 8 ]; then
pm_nl_flush_endpoint ${connector_ns} pm_nl_flush_endpoint ${connector_ns}
elif [ $rm_nr_ns2 -eq 9 ]; then elif [ $rm_nr_ns2 -eq 9 ]; then
...@@ -551,7 +573,7 @@ do_transfer() ...@@ -551,7 +573,7 @@ do_transfer()
if [ ! -z $sflags ]; then if [ ! -z $sflags ]; then
sleep 1 sleep 1
for netns in "$ns1" "$ns2"; do for netns in "$ns1" "$ns2"; do
ip netns exec $netns ./pm_nl_ctl dump | while read line; do pm_nl_show_endpoints $netns | while read line; do
local arr=($line) local arr=($line)
local addr local addr
local port=0 local port=0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment