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

selftests: mptcp: use pm_nl endpoint ops

Use those newly added pm_nl endpoint ops helpers to replace all 'pm_nl_ctl'
commands with 'limits', 'add', 'del', 'flush', 'show' and 'set' arguments
in scripts mptcp_sockopt.sh and simult_flows.sh.

In pm_netlink.sh, add wrappers of there helpers to make the function names
shorter. Then use the wrappers to replace all 'pm_nl_ctl' 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 441c6be9
...@@ -58,15 +58,15 @@ init() ...@@ -58,15 +58,15 @@ init()
# let $ns2 reach any $ns1 address from any interface # let $ns2 reach any $ns1 address from any interface
ip -net "$ns2" route add default via 10.0.$i.1 dev ns2eth$i metric 10$i ip -net "$ns2" route add default via 10.0.$i.1 dev ns2eth$i metric 10$i
ip netns exec $ns1 ./pm_nl_ctl add 10.0.$i.1 flags signal mptcp_lib_pm_nl_add_endpoint "${ns1}" "10.0.${i}.1" flags signal
ip netns exec $ns1 ./pm_nl_ctl add dead:beef:$i::1 flags signal mptcp_lib_pm_nl_add_endpoint "${ns1}" "dead:beef:${i}::1" flags signal
ip netns exec $ns2 ./pm_nl_ctl add 10.0.$i.2 flags signal mptcp_lib_pm_nl_add_endpoint "${ns2}" "10.0.${i}.2" flags signal
ip netns exec $ns2 ./pm_nl_ctl add dead:beef:$i::2 flags signal mptcp_lib_pm_nl_add_endpoint "${ns2}" "dead:beef:${i}::2" flags signal
done done
ip netns exec $ns1 ./pm_nl_ctl limits 8 8 mptcp_lib_pm_nl_set_limits "${ns1}" 8 8
ip netns exec $ns2 ./pm_nl_ctl limits 8 8 mptcp_lib_pm_nl_set_limits "${ns2}" 8 8
add_mark_rules $ns1 1 add_mark_rules $ns1 1
add_mark_rules $ns2 2 add_mark_rules $ns2 2
......
...@@ -86,6 +86,36 @@ change_address() { ...@@ -86,6 +86,36 @@ change_address() {
fi fi
} }
set_limits()
{
mptcp_lib_pm_nl_set_limits "${ns1}" "${@}"
}
add_endpoint()
{
mptcp_lib_pm_nl_add_endpoint "${ns1}" "${@}"
}
del_endpoint()
{
mptcp_lib_pm_nl_del_endpoint "${ns1}" "${@}"
}
flush_endpoint()
{
mptcp_lib_pm_nl_flush_endpoint "${ns1}"
}
show_endpoints()
{
mptcp_lib_pm_nl_show_endpoints "${ns1}"
}
change_endpoint()
{
mptcp_lib_pm_nl_change_endpoint "${ns1}" "${@}"
}
check() check()
{ {
local cmd="$1" local cmd="$1"
...@@ -107,47 +137,47 @@ check() ...@@ -107,47 +137,47 @@ check()
fi fi
} }
check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "defaults addr list" check "show_endpoints" "" "defaults addr list"
default_limits="$(get_limits)" default_limits="$(get_limits)"
if mptcp_lib_expect_all_features; then if mptcp_lib_expect_all_features; then
check "get_limits" "$(format_limits 0 2)" "defaults limits" check "get_limits" "$(format_limits 0 2)" "defaults limits"
fi fi
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1 add_endpoint 10.0.1.1
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.2 flags subflow dev lo add_endpoint 10.0.1.2 flags subflow dev lo
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.3 flags signal,backup add_endpoint 10.0.1.3 flags signal,backup
check "get_endpoint 1" "$(format_endpoints "1,10.0.1.1")" "simple add/get addr" check "get_endpoint 1" "$(format_endpoints "1,10.0.1.1")" "simple add/get addr"
check "ip netns exec $ns1 ./pm_nl_ctl dump" \ check "show_endpoints" \
"$(format_endpoints "1,10.0.1.1" \ "$(format_endpoints "1,10.0.1.1" \
"2,10.0.1.2,subflow,lo" \ "2,10.0.1.2,subflow,lo" \
"3,10.0.1.3,signal backup")" "dump addrs" "3,10.0.1.3,signal backup")" "dump addrs"
ip netns exec $ns1 ./pm_nl_ctl del 2 del_endpoint 2
check "get_endpoint 2" "" "simple del addr" check "get_endpoint 2" "" "simple del addr"
check "ip netns exec $ns1 ./pm_nl_ctl dump" \ check "show_endpoints" \
"$(format_endpoints "1,10.0.1.1" \ "$(format_endpoints "1,10.0.1.1" \
"3,10.0.1.3,signal backup")" "dump addrs after del" "3,10.0.1.3,signal backup")" "dump addrs after del"
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.3 2>/dev/null add_endpoint 10.0.1.3 2>/dev/null
check "get_endpoint 4" "" "duplicate addr" check "get_endpoint 4" "" "duplicate addr"
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.4 flags signal add_endpoint 10.0.1.4 flags signal
check "get_endpoint 4" "$(format_endpoints "4,10.0.1.4,signal")" "id addr increment" check "get_endpoint 4" "$(format_endpoints "4,10.0.1.4,signal")" "id addr increment"
for i in $(seq 5 9); do for i in $(seq 5 9); do
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.$i flags signal >/dev/null 2>&1 add_endpoint "10.0.1.${i}" flags signal >/dev/null 2>&1
done done
check "get_endpoint 9" "$(format_endpoints "9,10.0.1.9,signal")" "hard addr limit" check "get_endpoint 9" "$(format_endpoints "9,10.0.1.9,signal")" "hard addr limit"
check "get_endpoint 10" "" "above hard addr limit" check "get_endpoint 10" "" "above hard addr limit"
ip netns exec $ns1 ./pm_nl_ctl del 9 del_endpoint 9
for i in $(seq 10 255); do for i in $(seq 10 255); do
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.9 id $i add_endpoint 10.0.0.9 id "${i}"
ip netns exec $ns1 ./pm_nl_ctl del $i del_endpoint "${i}"
done done
check "ip netns exec $ns1 ./pm_nl_ctl dump" \ check "show_endpoints" \
"$(format_endpoints "1,10.0.1.1" \ "$(format_endpoints "1,10.0.1.1" \
"3,10.0.1.3,signal backup" \ "3,10.0.1.3,signal backup" \
"4,10.0.1.4,signal" \ "4,10.0.1.4,signal" \
...@@ -156,28 +186,28 @@ check "ip netns exec $ns1 ./pm_nl_ctl dump" \ ...@@ -156,28 +186,28 @@ check "ip netns exec $ns1 ./pm_nl_ctl dump" \
"7,10.0.1.7,signal" \ "7,10.0.1.7,signal" \
"8,10.0.1.8,signal")" "id limit" "8,10.0.1.8,signal")" "id limit"
ip netns exec $ns1 ./pm_nl_ctl flush flush_endpoint
check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "flush addrs" check "show_endpoints" "" "flush addrs"
ip netns exec $ns1 ./pm_nl_ctl limits 9 1 2>/dev/null set_limits 9 1 2>/dev/null
check "get_limits" "${default_limits}" "rcv addrs above hard limit" check "get_limits" "${default_limits}" "rcv addrs above hard limit"
ip netns exec $ns1 ./pm_nl_ctl limits 1 9 2>/dev/null set_limits 1 9 2>/dev/null
check "get_limits" "${default_limits}" "subflows above hard limit" check "get_limits" "${default_limits}" "subflows above hard limit"
ip netns exec $ns1 ./pm_nl_ctl limits 8 8 set_limits 8 8
check "get_limits" "$(format_limits 8 8)" "set limits" check "get_limits" "$(format_limits 8 8)" "set limits"
ip netns exec $ns1 ./pm_nl_ctl flush flush_endpoint
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1 add_endpoint 10.0.1.1
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.2 add_endpoint 10.0.1.2
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.3 id 100 add_endpoint 10.0.1.3 id 100
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.4 add_endpoint 10.0.1.4
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.5 id 254 add_endpoint 10.0.1.5 id 254
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.6 add_endpoint 10.0.1.6
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.7 add_endpoint 10.0.1.7
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.8 add_endpoint 10.0.1.8
check "ip netns exec $ns1 ./pm_nl_ctl dump" \ check "show_endpoints" \
"$(format_endpoints "1,10.0.1.1" \ "$(format_endpoints "1,10.0.1.1" \
"2,10.0.1.2" \ "2,10.0.1.2" \
"3,10.0.1.7" \ "3,10.0.1.7" \
...@@ -187,16 +217,16 @@ check "ip netns exec $ns1 ./pm_nl_ctl dump" \ ...@@ -187,16 +217,16 @@ check "ip netns exec $ns1 ./pm_nl_ctl dump" \
"254,10.0.1.5" \ "254,10.0.1.5" \
"255,10.0.1.6")" "set ids" "255,10.0.1.6")" "set ids"
ip netns exec $ns1 ./pm_nl_ctl flush flush_endpoint
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.1 add_endpoint 10.0.0.1
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.2 id 254 add_endpoint 10.0.0.2 id 254
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.3 add_endpoint 10.0.0.3
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.4 add_endpoint 10.0.0.4
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.5 id 253 add_endpoint 10.0.0.5 id 253
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.6 add_endpoint 10.0.0.6
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.7 add_endpoint 10.0.0.7
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.8 add_endpoint 10.0.0.8
check "ip netns exec $ns1 ./pm_nl_ctl dump" \ check "show_endpoints" \
"$(format_endpoints "1,10.0.0.1" \ "$(format_endpoints "1,10.0.0.1" \
"2,10.0.0.4" \ "2,10.0.0.4" \
"3,10.0.0.6" \ "3,10.0.0.6" \
...@@ -206,28 +236,26 @@ check "ip netns exec $ns1 ./pm_nl_ctl dump" \ ...@@ -206,28 +236,26 @@ check "ip netns exec $ns1 ./pm_nl_ctl dump" \
"254,10.0.0.2" \ "254,10.0.0.2" \
"255,10.0.0.3")" "wrap-around ids" "255,10.0.0.3")" "wrap-around ids"
ip netns exec $ns1 ./pm_nl_ctl flush flush_endpoint
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1 flags subflow add_endpoint 10.0.1.1 flags subflow
change_address 10.0.1.1 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")" \ check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow backup")" \
"set flags (backup)" "set flags (backup)"
change_address 10.0.1.1 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")" \ check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow")" \
" (nobackup)" " (nobackup)"
# fullmesh support has been added later # fullmesh support has been added later
ip netns exec $ns1 ./pm_nl_ctl set id 1 flags fullmesh 2>/dev/null change_endpoint 1 fullmesh 2>/dev/null
if ip netns exec $ns1 ./pm_nl_ctl dump | grep -q "fullmesh" || if show_endpoints | grep -q "fullmesh" ||
mptcp_lib_expect_all_features; then mptcp_lib_expect_all_features; then
check "ip netns exec $ns1 ./pm_nl_ctl dump" \ check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow fullmesh")" \
"$(format_endpoints "1,10.0.1.1,subflow fullmesh")" \
" (fullmesh)" " (fullmesh)"
ip netns exec $ns1 ./pm_nl_ctl set id 1 flags nofullmesh change_endpoint 1 nofullmesh
check "ip netns exec $ns1 ./pm_nl_ctl dump" "$(format_endpoints "1,10.0.1.1,subflow")" \ check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow")" \
" (nofullmesh)" " (nofullmesh)"
ip netns exec $ns1 ./pm_nl_ctl set id 1 flags backup,fullmesh change_endpoint 1 backup,fullmesh
check "ip netns exec $ns1 ./pm_nl_ctl dump" \ check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow backup fullmesh")" \
"$(format_endpoints "1,10.0.1.1,subflow backup fullmesh")" \
" (backup,fullmesh)" " (backup,fullmesh)"
else else
for st in fullmesh nofullmesh backup,fullmesh; do for st in fullmesh nofullmesh backup,fullmesh; do
......
...@@ -85,8 +85,8 @@ setup() ...@@ -85,8 +85,8 @@ setup()
ip -net "$ns1" route add default via 10.0.2.2 metric 101 ip -net "$ns1" route add default via 10.0.2.2 metric 101
ip -net "$ns1" route add default via dead:beef:2::2 metric 101 ip -net "$ns1" route add default via dead:beef:2::2 metric 101
ip netns exec "$ns1" ./pm_nl_ctl limits 1 1 mptcp_lib_pm_nl_set_limits "${ns1}" 1 1
ip netns exec "$ns1" ./pm_nl_ctl add 10.0.2.1 dev ns1eth2 flags subflow mptcp_lib_pm_nl_add_endpoint "${ns1}" 10.0.2.1 dev ns1eth2 flags subflow
ip -net "$ns2" addr add 10.0.1.2/24 dev ns2eth1 ip -net "$ns2" addr add 10.0.1.2/24 dev ns2eth1
ip -net "$ns2" addr add dead:beef:1::2/64 dev ns2eth1 nodad ip -net "$ns2" addr add dead:beef:1::2/64 dev ns2eth1 nodad
...@@ -108,7 +108,7 @@ setup() ...@@ -108,7 +108,7 @@ setup()
ip -net "$ns3" route add default via 10.0.3.2 ip -net "$ns3" route add default via 10.0.3.2
ip -net "$ns3" route add default via dead:beef:3::2 ip -net "$ns3" route add default via dead:beef:3::2
ip netns exec "$ns3" ./pm_nl_ctl limits 1 1 mptcp_lib_pm_nl_set_limits "${ns3}" 1 1
# debug build can slow down measurably the test program # debug build can slow down measurably the test program
# we use quite tight time limit on the run-time, to ensure # we use quite tight time limit on the run-time, to ensure
......
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