[PATCH RESEND mptcp-next v3 5/6] selftests: mptcp: add wrapper for setting flags

Geliang Tang posted 6 patches 4 years ago
There is a newer version of this series
[PATCH RESEND mptcp-next v3 5/6] selftests: mptcp: add wrapper for setting flags
Posted by Geliang Tang 4 years ago
This patch implemented a new function named pm_nl_set_endpoint(), wraped
the PM netlink commands 'ip mptcp' and 'pm_nl_ctl' in it, and used a new
argument 'ip_mptcp' to choose which one to use to set the flags of the PM
endpoint.

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

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 .../testing/selftests/net/mptcp/mptcp_join.sh | 25 ++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 66f430d6300f..512dc92a5646 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -371,6 +371,20 @@ pm_nl_show_endpoints()
 	fi
 }
 
+pm_nl_change_endpoint()
+{
+	local ns=$1
+	local addr=$2
+	local id=$3
+	local sflags=$4
+
+	if [ $ip_mptcp -eq 1 ]; then
+		ip -n $ns mptcp endpoint change id $id $sflags
+	else
+		ip netns exec $ns ./pm_nl_ctl set $addr flags $sflags
+	fi
+}
+
 do_transfer()
 {
 	listener_ns="$1"
@@ -571,13 +585,22 @@ do_transfer()
 			pm_nl_show_endpoints $netns | while read line; do
 				local arr=($line)
 				local addr
+				local nr=0
+				local id
 
 				for addr in ${arr[@]}; do
 					if is_addr $addr; then
 						break
 					fi
 				done
-				ip netns exec $netns ./pm_nl_ctl set $addr flags $sflags
+
+				for i in ${arr[@]}; do
+					if [ $i = "id" ]; then
+						id=${arr[$nr+1]}
+					fi
+					let nr+=1
+				done
+				pm_nl_change_endpoint $netns $addr $id $sflags
 			done
 		done
 	fi
-- 
2.31.1