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

selftests: mptcp: netlink: add change_address helper

The output formats of 'ip mptcp' commands are much different from that
of 'pm_nl_ctl' commands.

A new 'change_address' helper is added here, to change the flag of an
address. This is a bit similar to mptcp_join.sh's pm_nl_change_endpoint().

Usage:
	Address ID - pm_nl_change_endpoint $ns id $id $flags
	IP address - change_address $ns $addr $flags

Use this new helper in pm_netlink.sh to replace all 'pm_nl_ctl set'
commands.
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 0d16ed0c
......@@ -75,6 +75,17 @@ get_endpoint() {
mptcp_lib_pm_nl_get_endpoint "${ns1}" "${@}"
}
change_address() {
local addr=${1}
local flags=${2}
if mptcp_lib_is_ip_mptcp; then
ip -n "${ns1}" mptcp endpoint change "${addr}" "${flags}"
else
ip netns exec "${ns1}" ./pm_nl_ctl set "${addr}" flags "${flags}"
fi
}
check()
{
local cmd="$1"
......@@ -197,10 +208,10 @@ check "ip netns exec $ns1 ./pm_nl_ctl dump" \
ip netns exec $ns1 ./pm_nl_ctl flush
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1 flags subflow
ip netns exec $ns1 ./pm_nl_ctl set 10.0.1.1 flags backup
change_address 10.0.1.1 backup
check "ip netns exec $ns1 ./pm_nl_ctl dump" "$(format_endpoints "1,10.0.1.1,subflow backup")" \
"set flags (backup)"
ip netns exec $ns1 ./pm_nl_ctl set 10.0.1.1 flags nobackup
change_address 10.0.1.1 nobackup
check "ip netns exec $ns1 ./pm_nl_ctl dump" "$(format_endpoints "1,10.0.1.1,subflow")" \
" (nobackup)"
......
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