2 # SPDX-License-Identifier: GPL-2.0
4 rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
9 timeout_test=$((timeout_poll * 2 + 1))
14 # mptcp_connect in join mode will sleep a bit before completing,
18 ip netns pids "${ns}" | xargs --no-run-if-empty kill -SIGUSR1 &>/dev/null
23 ip netns pids "${ns}" | xargs --no-run-if-empty kill -SIGKILL &>/dev/null
28 ip -Version > /dev/null 2>&1
30 echo "SKIP: Could not run test without ip tool"
35 echo "SKIP: ss tool does not support MPTCP"
47 nr=$(ss -inmHMN $ns | $condition)
50 if [ $nr != $expected ]; then
51 echo "[ fail ] expected $expected found $nr"
56 test_cnt=$((test_cnt+1))
61 __chk_nr "grep -c token:" $*
66 __chk_nr "grep -c fallback" $*
69 chk_msk_remote_key_nr()
71 __chk_nr "grep -c remote_key" $*
75 wait_local_port_listen()
77 local listener_ns="${1}"
82 port_hex="$(printf "%04X" "${port}")"
83 for i in $(seq 10); do
84 ip netns exec "${listener_ns}" cat /proc/net/tcp | \
85 awk "BEGIN {rc=1} {if (\$2 ~ /:${port_hex}\$/ && \$4 ~ /0A/) {rc=0; exit}} END {exit rc}" &&
93 local listener_ns="${1}"
98 port_hex="$(printf "%04X" "${port}")"
99 for i in $(seq 10); do
100 ip netns exec ${listener_ns} grep -q " 0100007F:${port_hex} " /proc/net/tcp && break
107 ip -n $ns link set dev lo up
110 timeout ${timeout_test} \
112 ./mptcp_connect -p 10000 -l -t ${timeout_poll} \
114 wait_local_port_listen $ns 10000
115 chk_msk_nr 0 "no msk on netns creation"
118 timeout ${timeout_test} \
120 ./mptcp_connect -p 10000 -r 0 -t ${timeout_poll} \
121 127.0.0.1 >/dev/null &
122 wait_connected $ns 10000
123 chk_msk_nr 2 "after MPC handshake "
124 chk_msk_remote_key_nr 2 "....chk remote_key"
125 chk_msk_fallback_nr 0 "....chk no fallback"
130 timeout ${timeout_test} \
132 ./mptcp_connect -p 10001 -l -s TCP -t ${timeout_poll} \
134 wait_local_port_listen $ns 10001
136 timeout ${timeout_test} \
138 ./mptcp_connect -p 10001 -r 0 -t ${timeout_poll} \
139 127.0.0.1 >/dev/null &
140 wait_connected $ns 10001
141 chk_msk_fallback_nr 1 "check fallback"
145 for I in `seq 1 $NR_CLIENTS`; do
147 timeout ${timeout_test} \
149 ./mptcp_connect -p $((I+10001)) -l -w 10 \
150 -t ${timeout_poll} 0.0.0.0 >/dev/null &
152 wait_local_port_listen $ns $((NR_CLIENTS + 10001))
154 for I in `seq 1 $NR_CLIENTS`; do
156 timeout ${timeout_test} \
158 ./mptcp_connect -p $((I+10001)) -w 10 \
159 -t ${timeout_poll} 127.0.0.1 >/dev/null &
163 chk_msk_nr $((NR_CLIENTS*2)) "many msk socket present"