Commit 441c6be9 authored by Geliang Tang's avatar Geliang Tang Committed by David S. Miller

selftests: mptcp: export pm_nl endpoint ops

This patch exports six endpoint operation helpers with pm_nl_ prefix,
pm_nl_set_limits(), pm_nl_add_endpoint(), pm_nl_del_endpoint(),
pm_nl_flush_endpoint(), pm_nl_show_endpoints() and pm_nl_change_endpoint()
into mptcp_lib.sh as public functions, and renamed each of them with a
mptcp_lib_ prefix. Then these old pm_nl_ prefix helpers in mptcp_join.sh
can be wrappers of mptcp_lib_ prefix ones.
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 571d7966
......@@ -605,92 +605,32 @@ kill_events_pids()
pm_nl_set_limits()
{
local ns=$1
local addrs=$2
local subflows=$3
if mptcp_lib_is_ip_mptcp; then
ip -n $ns mptcp limits set add_addr_accepted $addrs subflows $subflows
else
ip netns exec $ns ./pm_nl_ctl limits $addrs $subflows
fi
mptcp_lib_pm_nl_set_limits "${@}"
}
pm_nl_add_endpoint()
{
local ns=$1
local addr=$2
local flags dev id port
local nr=2
local p
for p in "${@}"
do
case "${p}" in
"flags" | "dev" | "id" | "port")
eval "${p}"=\$"${nr}"
;;
esac
nr=$((nr + 1))
done
if mptcp_lib_is_ip_mptcp; then
ip -n "${ns}" mptcp endpoint add "${addr}" ${flags//","/" "} \
${dev:+dev "${dev}"} ${id:+id "${id}"} ${port:+port "${port}"}
else
ip netns exec "${ns}" ./pm_nl_ctl add "${addr}" ${flags:+flags "${flags}"} \
${dev:+dev "${dev}"} ${id:+id "${id}"} ${port:+port "${port}"}
fi
mptcp_lib_pm_nl_add_endpoint "${@}"
}
pm_nl_del_endpoint()
{
local ns=$1
local id=$2
local addr=$3
if mptcp_lib_is_ip_mptcp; then
[ $id -ne 0 ] && addr=''
ip -n $ns mptcp endpoint delete id $id ${addr:+"${addr}"}
else
ip netns exec $ns ./pm_nl_ctl del $id $addr
fi
mptcp_lib_pm_nl_del_endpoint "${@}"
}
pm_nl_flush_endpoint()
{
local ns=$1
if mptcp_lib_is_ip_mptcp; then
ip -n $ns mptcp endpoint flush
else
ip netns exec $ns ./pm_nl_ctl flush
fi
mptcp_lib_pm_nl_flush_endpoint "${@}"
}
pm_nl_show_endpoints()
{
local ns=$1
if mptcp_lib_is_ip_mptcp; then
ip -n $ns mptcp endpoint show
else
ip netns exec $ns ./pm_nl_ctl dump
fi
mptcp_lib_pm_nl_show_endpoints "${@}"
}
pm_nl_change_endpoint()
{
local ns=$1
local id=$2
local flags=$3
if mptcp_lib_is_ip_mptcp; then
ip -n $ns mptcp endpoint change id $id ${flags//","/" "}
else
ip netns exec $ns ./pm_nl_ctl set id $id flags $flags
fi
mptcp_lib_pm_nl_change_endpoint "${@}"
}
pm_nl_check_endpoint()
......
......@@ -555,3 +555,88 @@ mptcp_lib_pm_nl_get_endpoint() {
ip netns exec "${ns}" ./pm_nl_ctl get "${id}"
fi
}
mptcp_lib_pm_nl_set_limits() {
local ns=${1}
local addrs=${2}
local subflows=${3}
if mptcp_lib_is_ip_mptcp; then
ip -n "${ns}" mptcp limits set add_addr_accepted "${addrs}" subflows "${subflows}"
else
ip netns exec "${ns}" ./pm_nl_ctl limits "${addrs}" "${subflows}"
fi
}
mptcp_lib_pm_nl_add_endpoint() {
local ns=${1}
local addr=${2}
local flags dev id port
local nr=2
local p
for p in "${@}"; do
case "${p}" in
"flags" | "dev" | "id" | "port")
eval "${p}"=\$"${nr}"
;;
esac
nr=$((nr + 1))
done
if mptcp_lib_is_ip_mptcp; then
# shellcheck disable=SC2086 # blanks in flags, no double quote
ip -n "${ns}" mptcp endpoint add "${addr}" ${flags//","/" "} \
${dev:+dev "${dev}"} ${id:+id "${id}"} ${port:+port "${port}"}
else
ip netns exec "${ns}" ./pm_nl_ctl add "${addr}" ${flags:+flags "${flags}"} \
${dev:+dev "${dev}"} ${id:+id "${id}"} ${port:+port "${port}"}
fi
}
mptcp_lib_pm_nl_del_endpoint() {
local ns=${1}
local id=${2}
local addr=${3}
if mptcp_lib_is_ip_mptcp; then
[ "${id}" -ne 0 ] && addr=''
ip -n "${ns}" mptcp endpoint delete id "${id}" ${addr:+"${addr}"}
else
ip netns exec "${ns}" ./pm_nl_ctl del "${id}" "${addr}"
fi
}
mptcp_lib_pm_nl_flush_endpoint() {
local ns=${1}
if mptcp_lib_is_ip_mptcp; then
ip -n "${ns}" mptcp endpoint flush
else
ip netns exec "${ns}" ./pm_nl_ctl flush
fi
}
mptcp_lib_pm_nl_show_endpoints() {
local ns=${1}
if mptcp_lib_is_ip_mptcp; then
ip -n "${ns}" mptcp endpoint show
else
ip netns exec "${ns}" ./pm_nl_ctl dump
fi
}
mptcp_lib_pm_nl_change_endpoint() {
local ns=${1}
local id=${2}
local flags=${3}
if mptcp_lib_is_ip_mptcp; then
# shellcheck disable=SC2086 # blanks in flags, no double quote
ip -n "${ns}" mptcp endpoint change id "${id}" ${flags//","/" "}
else
ip netns exec "${ns}" ./pm_nl_ctl set id "${id}" flags "${flags}"
fi
}
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