Commit 6e51d914 authored by David S. Miller's avatar David S. Miller

Merge branch 'mptcp-selftests'

Matthieu Baerts says:

====================
selftests: mptcp: cleanups and 'ip mptcp' support

Here are some patches from Geliang, doing different cleanups, and
supporting 'ip mptcp' in more MPTCP selftests.

Patch 1 checks that TC is available in selftests requiring it.

Patch 2 adds 'ms' units in TC commands, to avoid confusions.

Patches 3-9 are some prerequisites for patch 10: some export code from
mptcp_join.sh to mptcp_lib.sh, to be re-used in pm_netlink.sh,
mptcp_sockopt.sh and simult_flows.sh ; and others add helpers to
pm_netlink.sh to easily support both 'ip mptcp' and 'pm_nl_ctl' tools to
interact with the in-kernel MPTCP path-manager.

Patch 10 adds a '-i' parameter in mptcp_sockopt.sh, pm_netlink.sh, and
simult_flows.sh to use 'ip mptcp' tool instead of 'pm_nl_ctl'.

Patch 11 fixes some ShellCheck warnings in pm_netlink.sh, in order to
drop a ShellCheck's 'disable' instruction.
====================
Signed-off-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents d2c3a7eb 6eaeda12
......@@ -147,7 +147,7 @@ cleanup()
mptcp_lib_check_mptcp
mptcp_lib_check_kallsyms
mptcp_lib_check_tools ip
mptcp_lib_check_tools ip tc
sin=$(mktemp)
sout=$(mktemp)
......
......@@ -31,7 +31,6 @@ timeout_poll=30
timeout_test=$((timeout_poll * 2 + 1))
capture=false
checksum=false
ip_mptcp=0
check_invert=0
validate_checksum=false
init=0
......@@ -125,8 +124,8 @@ init_shapers()
{
local i
for i in $(seq 1 4); do
tc -n $ns1 qdisc add dev ns1eth$i root netem rate 20mbit delay 1
tc -n $ns2 qdisc add dev ns2eth$i root netem rate 20mbit delay 1
tc -n $ns1 qdisc add dev ns1eth$i root netem rate 20mbit delay 1ms
tc -n $ns2 qdisc add dev ns2eth$i root netem rate 20mbit delay 1ms
done
}
......@@ -142,7 +141,7 @@ init() {
mptcp_lib_check_mptcp
mptcp_lib_check_kallsyms
mptcp_lib_check_tools ip ss "${iptables}" "${ip6tables}"
mptcp_lib_check_tools ip tc ss "${iptables}" "${ip6tables}"
sin=$(mktemp)
sout=$(mktemp)
......@@ -606,173 +605,65 @@ kill_events_pids()
pm_nl_set_limits()
{
local ns=$1
local addrs=$2
local subflows=$3
if [ $ip_mptcp -eq 1 ]; 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 _flags
local port _port
local dev _dev
local id _id
local nr=2
local p
for p in "${@}"
do
if [ $p = "flags" ]; then
eval _flags=\$"$nr"
[ -n "$_flags" ]; flags="flags $_flags"
fi
if [ $p = "dev" ]; then
eval _dev=\$"$nr"
[ -n "$_dev" ]; dev="dev $_dev"
fi
if [ $p = "id" ]; then
eval _id=\$"$nr"
[ -n "$_id" ]; id="id $_id"
fi
if [ $p = "port" ]; then
eval _port=\$"$nr"
[ -n "$_port" ]; port="port $_port"
fi
nr=$((nr + 1))
done
if [ $ip_mptcp -eq 1 ]; then
ip -n $ns mptcp endpoint add $addr ${_flags//","/" "} $dev $id $port
else
ip netns exec $ns ./pm_nl_ctl add $addr $flags $dev $id $port
fi
mptcp_lib_pm_nl_add_endpoint "${@}"
}
pm_nl_del_endpoint()
{
local ns=$1
local id=$2
local addr=$3
if [ $ip_mptcp -eq 1 ]; then
[ $id -ne 0 ] && addr=''
ip -n $ns mptcp endpoint delete id $id $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 [ $ip_mptcp -eq 1 ]; 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 [ $ip_mptcp -eq 1 ]; 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 [ $ip_mptcp -eq 1 ]; 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()
{
local line expected_line
local msg="$1"
local ns=$2
local addr=$3
local _flags=""
local flags
local _port
local port
local dev
local _id
local id
local flags dev id port
print_check "${msg}"
shift 3
while [ -n "$1" ]; do
if [ $1 = "flags" ]; then
_flags=$2
[ -n "$_flags" ]; flags="flags $_flags"
shift
elif [ $1 = "dev" ]; then
[ -n "$2" ]; dev="dev $2"
case "${1}" in
"flags" | "dev" | "id" | "port")
eval "${1}"="${2}"
shift
elif [ $1 = "id" ]; then
_id=$2
[ -n "$_id" ]; id="id $_id"
shift
elif [ $1 = "port" ]; then
_port=$2
[ -n "$_port" ]; port=" port $_port"
shift
fi
;;
*)
;;
esac
shift
done
if [ -z "$id" ]; then
if [ -z "${id}" ]; then
test_fail "bad test - missing endpoint id"
return
fi
if [ $ip_mptcp -eq 1 ]; then
# get line and trim trailing whitespace
line=$(ip -n $ns mptcp endpoint show $id)
line="${line% }"
# the dump order is: address id flags port dev
[ -n "$addr" ] && expected_line="$addr"
expected_line+=" $id"
[ -n "$_flags" ] && expected_line+=" ${_flags//","/" "}"
[ -n "$dev" ] && expected_line+=" $dev"
[ -n "$port" ] && expected_line+=" $port"
else
line=$(ip netns exec $ns ./pm_nl_ctl get $_id)
# the dump order is: id flags dev address port
expected_line="$id"
[ -n "$flags" ] && expected_line+=" $flags"
[ -n "$dev" ] && expected_line+=" $dev"
[ -n "$addr" ] && expected_line+=" $addr"
[ -n "$_port" ] && expected_line+=" $_port"
fi
if [ "$line" = "$expected_line" ]; then
print_ok
else
fail_test "expected '$expected_line' found '$line'"
fi
check_output "mptcp_lib_pm_nl_get_endpoint ${ns} ${id}" \
"$(mptcp_lib_pm_nl_format_endpoints \
"${id},${addr},${flags//","/" "},${dev},${port}")"
}
pm_nl_set_endpoint()
......@@ -3212,7 +3103,7 @@ fail_tests()
# multiple subflows
if reset_with_fail "MP_FAIL MP_RST" 2; then
tc -n $ns2 qdisc add dev ns2eth1 root netem rate 1mbit delay 5
tc -n $ns2 qdisc add dev ns2eth1 root netem rate 1mbit delay 5ms
pm_nl_set_limits $ns1 0 1
pm_nl_set_limits $ns2 0 1
pm_nl_add_endpoint $ns2 10.0.2.2 dev ns2eth2 flags subflow
......@@ -3702,7 +3593,7 @@ while getopts "${all_tests_args}cCih" opt; do
checksum=true
;;
i)
ip_mptcp=1
mptcp_lib_set_ip_mptcp
;;
h)
usage
......
......@@ -23,6 +23,7 @@ MPTCP_LIB_SUBTESTS=()
MPTCP_LIB_SUBTESTS_DUPLICATED=0
MPTCP_LIB_TEST_COUNTER=0
MPTCP_LIB_TEST_FORMAT="%02u %-50s"
MPTCP_LIB_IP_MPTCP=0
# only if supported (or forced) and not disabled, see no-color.org
if { [ -t 1 ] || [ "${SELFTESTS_MPTCP_LIB_COLOR_FORCE:-}" = "1" ]; } &&
......@@ -384,6 +385,12 @@ mptcp_lib_check_tools() {
exit ${KSFT_SKIP}
fi
;;
"tc")
if ! tc -help &> /dev/null; then
mptcp_lib_pr_skip "Could not run test without tc tool"
exit ${KSFT_SKIP}
fi
;;
"ss")
if ! ss -h | grep -q MPTCP; then
mptcp_lib_pr_skip "ss tool does not support MPTCP"
......@@ -505,3 +512,131 @@ mptcp_lib_verify_listener_events() {
mptcp_lib_check_expected "type" "family" "saddr" "sport" || rc="${?}"
return "${rc}"
}
mptcp_lib_set_ip_mptcp() {
MPTCP_LIB_IP_MPTCP=1
}
mptcp_lib_is_ip_mptcp() {
[ "${MPTCP_LIB_IP_MPTCP}" = "1" ]
}
# format: <id>,<ip>,<flags>,<dev>
mptcp_lib_pm_nl_format_endpoints() {
local entry id ip flags dev port
for entry in "${@}"; do
IFS=, read -r id ip flags dev port <<< "${entry}"
if mptcp_lib_is_ip_mptcp; then
echo -n "${ip}"
[ -n "${port}" ] && echo -n " port ${port}"
echo -n " id ${id}"
[ -n "${flags}" ] && echo -n " ${flags}"
[ -n "${dev}" ] && echo -n " dev ${dev}"
echo " " # always a space at the end
else
echo -n "id ${id}"
echo -n " flags ${flags//" "/","}"
[ -n "${dev}" ] && echo -n " dev ${dev}"
echo -n " ${ip}"
[ -n "${port}" ] && echo -n " ${port}"
echo ""
fi
done
}
mptcp_lib_pm_nl_get_endpoint() {
local ns=${1}
local id=${2}
if mptcp_lib_is_ip_mptcp; then
ip -n "${ns}" mptcp endpoint show id "${id}"
else
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
}
......@@ -22,6 +22,28 @@ ns1=""
ns2=""
ns_sbox=""
usage() {
echo "Usage: $0 [ -i ] [ -h ]"
echo -e "\t-i: use 'ip mptcp' instead of 'pm_nl_ctl'"
echo -e "\t-h: help"
}
while getopts "hi" option;do
case "$option" in
"h")
usage "$0"
exit ${KSFT_PASS}
;;
"i")
mptcp_lib_set_ip_mptcp
;;
"?")
usage "$0"
exit ${KSFT_FAIL}
;;
esac
done
add_mark_rules()
{
local ns=$1
......@@ -58,15 +80,15 @@ init()
# 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 netns exec $ns1 ./pm_nl_ctl add 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}" "10.0.${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
ip netns exec $ns2 ./pm_nl_ctl add dead:beef:$i::2 flags signal
mptcp_lib_pm_nl_add_endpoint "${ns2}" "10.0.${i}.2" flags signal
mptcp_lib_pm_nl_add_endpoint "${ns2}" "dead:beef:${i}::2" flags signal
done
ip netns exec $ns1 ./pm_nl_ctl limits 8 8
ip netns exec $ns2 ./pm_nl_ctl limits 8 8
mptcp_lib_pm_nl_set_limits "${ns1}" 8 8
mptcp_lib_pm_nl_set_limits "${ns2}" 8 8
add_mark_rules $ns1 1
add_mark_rules $ns2 2
......
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Double quotes to prevent globbing and word splitting is recommended in new
# code but we accept it, especially because there were too many before having
# address all other issues detected by shellcheck.
#shellcheck disable=SC2086
. "$(dirname "${0}")/mptcp_lib.sh"
ret=0
usage() {
echo "Usage: $0 [ -h ]"
echo "Usage: $0 [ -i ] [ -h ]"
echo -e "\t-i: use 'ip mptcp' instead of 'pm_nl_ctl'"
echo -e "\t-h: help"
}
optstring=h
optstring=hi
while getopts "$optstring" option;do
case "$option" in
"h")
usage $0
usage "$0"
exit ${KSFT_PASS}
;;
"i")
mptcp_lib_set_ip_mptcp
;;
"?")
usage $0
usage "$0"
exit ${KSFT_FAIL}
;;
esac
......@@ -35,7 +35,7 @@ err=$(mktemp)
#shellcheck disable=SC2317
cleanup()
{
rm -f $err
rm -f "${err}"
mptcp_lib_ns_exit "${ns1}"
}
......@@ -46,6 +46,76 @@ trap cleanup EXIT
mptcp_lib_ns_init ns1
format_limits() {
local accept="${1}"
local subflows="${2}"
if mptcp_lib_is_ip_mptcp; then
# with a space at the end
printf "add_addr_accepted %d subflows %d \n" "${accept}" "${subflows}"
else
printf "accept %d\nsubflows %d\n" "${accept}" "${subflows}"
fi
}
get_limits() {
if mptcp_lib_is_ip_mptcp; then
ip -n "${ns1}" mptcp limits
else
ip netns exec "${ns1}" ./pm_nl_ctl limits
fi
}
format_endpoints() {
mptcp_lib_pm_nl_format_endpoints "${@}"
}
get_endpoint() {
# shellcheck disable=SC2317 # invoked indirectly
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
}
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()
{
local cmd="$1"
......@@ -67,125 +137,126 @@ check()
fi
}
check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "defaults addr list"
check "show_endpoints" "" "defaults addr list"
default_limits="$(ip netns exec $ns1 ./pm_nl_ctl limits)"
default_limits="$(get_limits)"
if mptcp_lib_expect_all_features; then
check "ip netns exec $ns1 ./pm_nl_ctl limits" "accept 0
subflows 2" "defaults limits"
check "get_limits" "$(format_limits 0 2)" "defaults limits"
fi
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.2 flags subflow dev lo
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.3 flags signal,backup
check "ip netns exec $ns1 ./pm_nl_ctl get 1" "id 1 flags 10.0.1.1" "simple add/get addr"
add_endpoint 10.0.1.1
add_endpoint 10.0.1.2 flags subflow dev lo
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 "ip netns exec $ns1 ./pm_nl_ctl dump" \
"id 1 flags 10.0.1.1
id 2 flags subflow dev lo 10.0.1.2
id 3 flags signal,backup 10.0.1.3" "dump addrs"
check "show_endpoints" \
"$(format_endpoints "1,10.0.1.1" \
"2,10.0.1.2,subflow,lo" \
"3,10.0.1.3,signal backup")" "dump addrs"
ip netns exec $ns1 ./pm_nl_ctl del 2
check "ip netns exec $ns1 ./pm_nl_ctl get 2" "" "simple del addr"
check "ip netns exec $ns1 ./pm_nl_ctl dump" \
"id 1 flags 10.0.1.1
id 3 flags signal,backup 10.0.1.3" "dump addrs after del"
del_endpoint 2
check "get_endpoint 2" "" "simple del addr"
check "show_endpoints" \
"$(format_endpoints "1,10.0.1.1" \
"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
check "ip netns exec $ns1 ./pm_nl_ctl get 4" "" "duplicate addr"
add_endpoint 10.0.1.3 2>/dev/null
check "get_endpoint 4" "" "duplicate addr"
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.4 flags signal
check "ip netns exec $ns1 ./pm_nl_ctl get 4" "id 4 flags signal 10.0.1.4" "id addr increment"
add_endpoint 10.0.1.4 flags signal
check "get_endpoint 4" "$(format_endpoints "4,10.0.1.4,signal")" "id addr increment"
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
check "ip netns exec $ns1 ./pm_nl_ctl get 9" "id 9 flags signal 10.0.1.9" "hard addr limit"
check "ip netns exec $ns1 ./pm_nl_ctl get 10" "" "above 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"
ip netns exec $ns1 ./pm_nl_ctl del 9
del_endpoint 9
for i in $(seq 10 255); do
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.9 id $i
ip netns exec $ns1 ./pm_nl_ctl del $i
add_endpoint 10.0.0.9 id "${i}"
del_endpoint "${i}"
done
check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags 10.0.1.1
id 3 flags signal,backup 10.0.1.3
id 4 flags signal 10.0.1.4
id 5 flags signal 10.0.1.5
id 6 flags signal 10.0.1.6
id 7 flags signal 10.0.1.7
id 8 flags signal 10.0.1.8" "id limit"
ip netns exec $ns1 ./pm_nl_ctl flush
check "ip netns exec $ns1 ./pm_nl_ctl dump" "" "flush addrs"
ip netns exec $ns1 ./pm_nl_ctl limits 9 1 2>/dev/null
check "ip netns exec $ns1 ./pm_nl_ctl limits" "$default_limits" "rcv addrs above hard limit"
ip netns exec $ns1 ./pm_nl_ctl limits 1 9 2>/dev/null
check "ip netns exec $ns1 ./pm_nl_ctl limits" "$default_limits" "subflows above hard limit"
ip netns exec $ns1 ./pm_nl_ctl limits 8 8
check "ip netns exec $ns1 ./pm_nl_ctl limits" "accept 8
subflows 8" "set limits"
ip netns exec $ns1 ./pm_nl_ctl flush
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.1
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.2
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.3 id 100
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.4
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.5 id 254
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.6
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.7
ip netns exec $ns1 ./pm_nl_ctl add 10.0.1.8
check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags 10.0.1.1
id 2 flags 10.0.1.2
id 3 flags 10.0.1.7
id 4 flags 10.0.1.8
id 100 flags 10.0.1.3
id 101 flags 10.0.1.4
id 254 flags 10.0.1.5
id 255 flags 10.0.1.6" "set ids"
ip netns exec $ns1 ./pm_nl_ctl flush
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.1
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.2 id 254
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.3
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.4
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.5 id 253
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.6
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.7
ip netns exec $ns1 ./pm_nl_ctl add 10.0.0.8
check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags 10.0.0.1
id 2 flags 10.0.0.4
id 3 flags 10.0.0.6
id 4 flags 10.0.0.7
id 5 flags 10.0.0.8
id 253 flags 10.0.0.5
id 254 flags 10.0.0.2
id 255 flags 10.0.0.3" "wrap-around ids"
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
check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \
subflow,backup 10.0.1.1" "set flags (backup)"
ip netns exec $ns1 ./pm_nl_ctl set 10.0.1.1 flags nobackup
check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \
subflow 10.0.1.1" " (nobackup)"
check "show_endpoints" \
"$(format_endpoints "1,10.0.1.1" \
"3,10.0.1.3,signal backup" \
"4,10.0.1.4,signal" \
"5,10.0.1.5,signal" \
"6,10.0.1.6,signal" \
"7,10.0.1.7,signal" \
"8,10.0.1.8,signal")" "id limit"
flush_endpoint
check "show_endpoints" "" "flush addrs"
set_limits 9 1 2>/dev/null
check "get_limits" "${default_limits}" "rcv addrs above hard limit"
set_limits 1 9 2>/dev/null
check "get_limits" "${default_limits}" "subflows above hard limit"
set_limits 8 8
check "get_limits" "$(format_limits 8 8)" "set limits"
flush_endpoint
add_endpoint 10.0.1.1
add_endpoint 10.0.1.2
add_endpoint 10.0.1.3 id 100
add_endpoint 10.0.1.4
add_endpoint 10.0.1.5 id 254
add_endpoint 10.0.1.6
add_endpoint 10.0.1.7
add_endpoint 10.0.1.8
check "show_endpoints" \
"$(format_endpoints "1,10.0.1.1" \
"2,10.0.1.2" \
"3,10.0.1.7" \
"4,10.0.1.8" \
"100,10.0.1.3" \
"101,10.0.1.4" \
"254,10.0.1.5" \
"255,10.0.1.6")" "set ids"
flush_endpoint
add_endpoint 10.0.0.1
add_endpoint 10.0.0.2 id 254
add_endpoint 10.0.0.3
add_endpoint 10.0.0.4
add_endpoint 10.0.0.5 id 253
add_endpoint 10.0.0.6
add_endpoint 10.0.0.7
add_endpoint 10.0.0.8
check "show_endpoints" \
"$(format_endpoints "1,10.0.0.1" \
"2,10.0.0.4" \
"3,10.0.0.6" \
"4,10.0.0.7" \
"5,10.0.0.8" \
"253,10.0.0.5" \
"254,10.0.0.2" \
"255,10.0.0.3")" "wrap-around ids"
flush_endpoint
add_endpoint 10.0.1.1 flags subflow
change_address 10.0.1.1 backup
check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow backup")" \
"set flags (backup)"
change_address 10.0.1.1 nobackup
check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow")" \
" (nobackup)"
# fullmesh support has been added later
ip netns exec $ns1 ./pm_nl_ctl set id 1 flags fullmesh 2>/dev/null
if ip netns exec $ns1 ./pm_nl_ctl dump | grep -q "fullmesh" ||
change_endpoint 1 fullmesh 2>/dev/null
if show_endpoints | grep -q "fullmesh" ||
mptcp_lib_expect_all_features; then
check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \
subflow,fullmesh 10.0.1.1" " (fullmesh)"
ip netns exec $ns1 ./pm_nl_ctl set id 1 flags nofullmesh
check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \
subflow 10.0.1.1" " (nofullmesh)"
ip netns exec $ns1 ./pm_nl_ctl set id 1 flags backup,fullmesh
check "ip netns exec $ns1 ./pm_nl_ctl dump" "id 1 flags \
subflow,backup,fullmesh 10.0.1.1" " (backup,fullmesh)"
check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow fullmesh")" \
" (fullmesh)"
change_endpoint 1 nofullmesh
check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow")" \
" (nofullmesh)"
change_endpoint 1 backup,fullmesh
check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow backup fullmesh")" \
" (backup,fullmesh)"
else
for st in fullmesh nofullmesh backup,fullmesh; do
st=" (${st})"
......
......@@ -27,10 +27,11 @@ capout=""
size=0
usage() {
echo "Usage: $0 [ -b ] [ -c ] [ -d ]"
echo "Usage: $0 [ -b ] [ -c ] [ -d ] [ -i]"
echo -e "\t-b: bail out after first error, otherwise runs al testcases"
echo -e "\t-c: capture packets for each test using tcpdump (default: no capture)"
echo -e "\t-d: debug this script"
echo -e "\t-i: use 'ip mptcp' instead of 'pm_nl_ctl'"
}
# This function is used in the cleanup trap
......@@ -45,7 +46,7 @@ cleanup()
}
mptcp_lib_check_mptcp
mptcp_lib_check_tools ip
mptcp_lib_check_tools ip tc
# "$ns1" ns2 ns3
# ns1eth1 ns2eth1 ns2eth3 ns3eth1
......@@ -85,8 +86,8 @@ setup()
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 netns exec "$ns1" ./pm_nl_ctl limits 1 1
ip netns exec "$ns1" ./pm_nl_ctl add 10.0.2.1 dev ns1eth2 flags subflow
mptcp_lib_pm_nl_set_limits "${ns1}" 1 1
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 dead:beef:1::2/64 dev ns2eth1 nodad
......@@ -108,7 +109,7 @@ setup()
ip -net "$ns3" route add default via 10.0.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
# we use quite tight time limit on the run-time, to ensure
......@@ -216,8 +217,8 @@ run_test()
shift 4
local msg=$*
[ $delay1 -gt 0 ] && delay1="delay $delay1" || delay1=""
[ $delay2 -gt 0 ] && delay2="delay $delay2" || delay2=""
[ $delay1 -gt 0 ] && delay1="delay ${delay1}ms" || delay1=""
[ $delay2 -gt 0 ] && delay2="delay ${delay2}ms" || delay2=""
for dev in ns1eth1 ns1eth2; do
tc -n $ns1 qdisc del dev $dev root >/dev/null 2>&1
......@@ -259,7 +260,7 @@ run_test()
fi
}
while getopts "bcdh" option;do
while getopts "bcdhi" option;do
case "$option" in
"h")
usage $0
......@@ -274,6 +275,9 @@ while getopts "bcdh" option;do
"d")
set -x
;;
"i")
mptcp_lib_set_ip_mptcp
;;
"?")
usage $0
exit ${KSFT_FAIL}
......
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