Commit 29aa32fe authored by Geliang Tang's avatar Geliang Tang Committed by David S. Miller

selftests: mptcp: export ip_mptcp to mptcp_lib

This patch exports ip_mptcp into mptcp_lib.sh as a public variable,
named MPTCP_LIB_IP_MPTCP. Add a helper mptcp_lib_set_ip_mptcp() to set
it, and a helper mptcp_lib_is_ip_mptcp() to test whether it is set. Use
these two helpers in mptcp_join.sh.

This patch is prepared for coming commits.
Signed-off-by: default avatarGeliang Tang <tanggeliang@kylinos.cn>
Reviewed-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9109853a
...@@ -31,7 +31,6 @@ timeout_poll=30 ...@@ -31,7 +31,6 @@ timeout_poll=30
timeout_test=$((timeout_poll * 2 + 1)) timeout_test=$((timeout_poll * 2 + 1))
capture=false capture=false
checksum=false checksum=false
ip_mptcp=0
check_invert=0 check_invert=0
validate_checksum=false validate_checksum=false
init=0 init=0
...@@ -610,7 +609,7 @@ pm_nl_set_limits() ...@@ -610,7 +609,7 @@ pm_nl_set_limits()
local addrs=$2 local addrs=$2
local subflows=$3 local subflows=$3
if [ $ip_mptcp -eq 1 ]; then if mptcp_lib_is_ip_mptcp; then
ip -n $ns mptcp limits set add_addr_accepted $addrs subflows $subflows ip -n $ns mptcp limits set add_addr_accepted $addrs subflows $subflows
else else
ip netns exec $ns ./pm_nl_ctl limits $addrs $subflows ip netns exec $ns ./pm_nl_ctl limits $addrs $subflows
...@@ -650,7 +649,7 @@ pm_nl_add_endpoint() ...@@ -650,7 +649,7 @@ pm_nl_add_endpoint()
nr=$((nr + 1)) nr=$((nr + 1))
done done
if [ $ip_mptcp -eq 1 ]; then if mptcp_lib_is_ip_mptcp; then
ip -n $ns mptcp endpoint add $addr ${_flags//","/" "} $dev $id $port ip -n $ns mptcp endpoint add $addr ${_flags//","/" "} $dev $id $port
else else
ip netns exec $ns ./pm_nl_ctl add $addr $flags $dev $id $port ip netns exec $ns ./pm_nl_ctl add $addr $flags $dev $id $port
...@@ -663,7 +662,7 @@ pm_nl_del_endpoint() ...@@ -663,7 +662,7 @@ pm_nl_del_endpoint()
local id=$2 local id=$2
local addr=$3 local addr=$3
if [ $ip_mptcp -eq 1 ]; then if mptcp_lib_is_ip_mptcp; then
[ $id -ne 0 ] && addr='' [ $id -ne 0 ] && addr=''
ip -n $ns mptcp endpoint delete id $id $addr ip -n $ns mptcp endpoint delete id $id $addr
else else
...@@ -675,7 +674,7 @@ pm_nl_flush_endpoint() ...@@ -675,7 +674,7 @@ pm_nl_flush_endpoint()
{ {
local ns=$1 local ns=$1
if [ $ip_mptcp -eq 1 ]; then if mptcp_lib_is_ip_mptcp; then
ip -n $ns mptcp endpoint flush ip -n $ns mptcp endpoint flush
else else
ip netns exec $ns ./pm_nl_ctl flush ip netns exec $ns ./pm_nl_ctl flush
...@@ -686,7 +685,7 @@ pm_nl_show_endpoints() ...@@ -686,7 +685,7 @@ pm_nl_show_endpoints()
{ {
local ns=$1 local ns=$1
if [ $ip_mptcp -eq 1 ]; then if mptcp_lib_is_ip_mptcp; then
ip -n $ns mptcp endpoint show ip -n $ns mptcp endpoint show
else else
ip netns exec $ns ./pm_nl_ctl dump ip netns exec $ns ./pm_nl_ctl dump
...@@ -699,7 +698,7 @@ pm_nl_change_endpoint() ...@@ -699,7 +698,7 @@ pm_nl_change_endpoint()
local id=$2 local id=$2
local flags=$3 local flags=$3
if [ $ip_mptcp -eq 1 ]; then if mptcp_lib_is_ip_mptcp; then
ip -n $ns mptcp endpoint change id $id ${flags//","/" "} ip -n $ns mptcp endpoint change id $id ${flags//","/" "}
else else
ip netns exec $ns ./pm_nl_ctl set id $id flags $flags ip netns exec $ns ./pm_nl_ctl set id $id flags $flags
...@@ -749,7 +748,7 @@ pm_nl_check_endpoint() ...@@ -749,7 +748,7 @@ pm_nl_check_endpoint()
return return
fi fi
if [ $ip_mptcp -eq 1 ]; then if mptcp_lib_is_ip_mptcp; then
# get line and trim trailing whitespace # get line and trim trailing whitespace
line=$(ip -n $ns mptcp endpoint show $id) line=$(ip -n $ns mptcp endpoint show $id)
line="${line% }" line="${line% }"
...@@ -3702,7 +3701,7 @@ while getopts "${all_tests_args}cCih" opt; do ...@@ -3702,7 +3701,7 @@ while getopts "${all_tests_args}cCih" opt; do
checksum=true checksum=true
;; ;;
i) i)
ip_mptcp=1 mptcp_lib_set_ip_mptcp
;; ;;
h) h)
usage usage
......
...@@ -23,6 +23,7 @@ MPTCP_LIB_SUBTESTS=() ...@@ -23,6 +23,7 @@ MPTCP_LIB_SUBTESTS=()
MPTCP_LIB_SUBTESTS_DUPLICATED=0 MPTCP_LIB_SUBTESTS_DUPLICATED=0
MPTCP_LIB_TEST_COUNTER=0 MPTCP_LIB_TEST_COUNTER=0
MPTCP_LIB_TEST_FORMAT="%02u %-50s" MPTCP_LIB_TEST_FORMAT="%02u %-50s"
MPTCP_LIB_IP_MPTCP=0
# only if supported (or forced) and not disabled, see no-color.org # only if supported (or forced) and not disabled, see no-color.org
if { [ -t 1 ] || [ "${SELFTESTS_MPTCP_LIB_COLOR_FORCE:-}" = "1" ]; } && if { [ -t 1 ] || [ "${SELFTESTS_MPTCP_LIB_COLOR_FORCE:-}" = "1" ]; } &&
...@@ -511,3 +512,11 @@ mptcp_lib_verify_listener_events() { ...@@ -511,3 +512,11 @@ mptcp_lib_verify_listener_events() {
mptcp_lib_check_expected "type" "family" "saddr" "sport" || rc="${?}" mptcp_lib_check_expected "type" "family" "saddr" "sport" || rc="${?}"
return "${rc}" return "${rc}"
} }
mptcp_lib_set_ip_mptcp() {
MPTCP_LIB_IP_MPTCP=1
}
mptcp_lib_is_ip_mptcp() {
[ "${MPTCP_LIB_IP_MPTCP}" = "1" ]
}
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