2 # SPDX-License-Identifier: GPL-2.0
4 # Double quotes to prevent globbing and word splitting is recommended in new
5 # code but we accept it.
6 #shellcheck disable=SC2086
8 # Some variables are used below but indirectly, see check_expected_one()
9 #shellcheck disable=SC2034
11 . "$(dirname "${0}")/mptcp_lib.sh"
14 mptcp_lib_check_kallsyms
16 if ! mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then
17 echo "userspace pm tests are not supported by the kernel: SKIP"
21 if ! ip -Version &> /dev/null; then
22 echo "SKIP: Cannot not run test without ip tool"
26 ANNOUNCED=6 # MPTCP_EVENT_ANNOUNCED
27 REMOVED=7 # MPTCP_EVENT_REMOVED
28 SUB_ESTABLISHED=10 # MPTCP_EVENT_SUB_ESTABLISHED
29 SUB_CLOSED=11 # MPTCP_EVENT_SUB_CLOSED
30 LISTENER_CREATED=15 #MPTCP_EVENT_LISTENER_CREATED
31 LISTENER_CLOSED=16 #MPTCP_EVENT_LISTENER_CLOSED
54 client_addr_id=${RANDOM:0:2}
55 server_addr_id=${RANDOM:0:2}
58 rndh=$(printf %x "$sec")-$(mktemp -u XXXXXX)
65 stdbuf -o0 -e0 printf "${@}"
70 _printf "INFO: %s\n" "${1}"
78 _printf "%-68s" "${test_name}"
83 _printf "[%s]\n" "${1}"
89 mptcp_lib_result_pass "${test_name}"
95 mptcp_lib_result_skip "${test_name}"
104 if [ -n "${1}" ]; then
105 _printf "\t%s\n" "${1}"
108 mptcp_lib_result_fail "${test_name}"
111 # This function is used in the cleanup trap
112 #shellcheck disable=SC2317
115 print_title "Cleanup"
117 # Terminate the MPTCP connection and related processes
119 for pid in $client4_pid $server4_pid $client6_pid $server6_pid\
120 $server_evts_pid $client_evts_pid
122 mptcp_lib_kill_wait $pid
126 for netns in "$ns1" "$ns2" ;do
127 ip netns del "$netns"
130 rm -rf $file $client_evts $server_evts
137 # Create and configure network namespaces for testing
138 for i in "$ns1" "$ns2" ;do
139 ip netns add "$i" || exit 1
140 ip -net "$i" link set lo up
141 ip netns exec "$i" sysctl -q net.mptcp.enabled=1
142 ip netns exec "$i" sysctl -q net.mptcp.pm_type=1
148 ip link add ns1eth2 netns "$ns1" type veth peer name ns2eth1 netns "$ns2"
150 # Add IPv4/v6 addresses to the namespaces
151 ip -net "$ns1" addr add 10.0.1.1/24 dev ns1eth2
152 ip -net "$ns1" addr add 10.0.2.1/24 dev ns1eth2
153 ip -net "$ns1" addr add dead:beef:1::1/64 dev ns1eth2 nodad
154 ip -net "$ns1" addr add dead:beef:2::1/64 dev ns1eth2 nodad
155 ip -net "$ns1" link set ns1eth2 up
157 ip -net "$ns2" addr add 10.0.1.2/24 dev ns2eth1
158 ip -net "$ns2" addr add 10.0.2.2/24 dev ns2eth1
159 ip -net "$ns2" addr add dead:beef:1::2/64 dev ns2eth1 nodad
160 ip -net "$ns2" addr add dead:beef:2::2/64 dev ns2eth1 nodad
161 ip -net "$ns2" link set ns2eth1 up
164 print_test "Created network namespaces ns1, ns2"
169 if [ -z "$file" ]; then
172 mptcp_lib_make_file "$file" 2 1
175 local app_port=$app4_port
176 local connect_addr="10.0.1.1"
177 local listen_addr="0.0.0.0"
178 if [ "$is_v6" = "v6" ]
180 connect_addr="dead:beef:1::1"
187 # Capture netlink events over the two network namespaces running
188 # the MPTCP client and server
189 if [ -z "$client_evts" ]; then
190 client_evts=$(mktemp)
193 if [ $client_evts_pid -ne 0 ]; then
194 mptcp_lib_kill_wait $client_evts_pid
196 ip netns exec "$ns2" ./pm_nl_ctl events >> "$client_evts" 2>&1 &
198 if [ -z "$server_evts" ]; then
199 server_evts=$(mktemp)
202 if [ $server_evts_pid -ne 0 ]; then
203 mptcp_lib_kill_wait $server_evts_pid
205 ip netns exec "$ns1" ./pm_nl_ctl events >> "$server_evts" 2>&1 &
210 ip netns exec "$ns1" \
211 ./mptcp_connect -s MPTCP -w 300 -p $app_port -l $listen_addr > /dev/null 2>&1 &
215 # Run the client, transfer $file and stay connected to the server
217 ip netns exec "$ns2" \
218 ./mptcp_connect -s MPTCP -w 300 -m sendfile -p $app_port $connect_addr\
219 2>&1 > /dev/null < "$file" &
223 # Capture client/server attributes from MPTCP connection netlink events
227 local client_serverside
229 local server_serverside
231 client_token=$(mptcp_lib_evts_get_info token "$client_evts")
232 client_port=$(mptcp_lib_evts_get_info sport "$client_evts")
233 client_serverside=$(mptcp_lib_evts_get_info server_side "$client_evts")
234 server_token=$(mptcp_lib_evts_get_info token "$server_evts")
235 server_serverside=$(mptcp_lib_evts_get_info server_side "$server_evts")
237 print_test "Established IP${is_v6} MPTCP Connection ns2 => ns1"
238 if [ "$client_token" != "" ] && [ "$server_token" != "" ] && [ "$client_serverside" = 0 ] &&
239 [ "$server_serverside" = 1 ]
243 test_fail "Expected tokens (c:${client_token} - s:${server_token}) and server (c:${client_serverside} - s:${server_serverside})"
244 mptcp_lib_result_print_all_tap
248 if [ "$is_v6" = "v6" ]
250 client6_token=$client_token
251 server6_token=$server_token
252 client6_port=$client_port
253 client6_pid=$client_pid
254 server6_pid=$server_pid
256 client4_token=$client_token
257 server4_token=$server_token
258 client4_port=$client_port
259 client4_pid=$client_pid
260 server4_pid=$server_pid
264 # $1: var name ; $2: prev ret
269 local prev_ret="${2}"
271 if [ "${!var}" = "${!exp}" ]
276 if [ "${prev_ret}" = "0" ]
281 _printf "\tExpected value for '%s': '%s', got '%s'.\n" \
282 "${var}" "${!exp}" "${!var}"
286 # $@: all var names to check
294 check_expected_one "${var}" "${rc}" || rc=1
306 verify_announce_event()
321 type=$(mptcp_lib_evts_get_info type "$evt" $e_type)
322 token=$(mptcp_lib_evts_get_info token "$evt" $e_type)
323 if [ "$e_af" = "v6" ]
325 addr=$(mptcp_lib_evts_get_info daddr6 "$evt" $e_type)
327 addr=$(mptcp_lib_evts_get_info daddr4 "$evt" $e_type)
329 dport=$(mptcp_lib_evts_get_info dport "$evt" $e_type)
330 id=$(mptcp_lib_evts_get_info rem_id "$evt" $e_type)
332 check_expected "type" "token" "addr" "dport" "id"
337 print_title "Announce tests"
339 # Capture events on the network namespace running the server
342 # ADD_ADDR using an invalid token should result in no action
343 local invalid_token=$(( client4_token - 1))
344 ip netns exec "$ns2" ./pm_nl_ctl ann 10.0.2.2 token $invalid_token id\
345 $client_addr_id dev ns2eth1 > /dev/null 2>&1
348 type=$(mptcp_lib_evts_get_info type "$server_evts")
349 print_test "ADD_ADDR 10.0.2.2 (ns2) => ns1, invalid token"
354 test_fail "type defined: ${type}"
357 # ADD_ADDR from the client to server machine reusing the subflow port
359 ip netns exec "$ns2"\
360 ./pm_nl_ctl ann 10.0.2.2 token "$client4_token" id $client_addr_id dev\
362 print_test "ADD_ADDR id:${client_addr_id} 10.0.2.2 (ns2) => ns1, reuse port"
364 verify_announce_event $server_evts $ANNOUNCED $server4_token "10.0.2.2" $client_addr_id \
367 # ADD_ADDR6 from the client to server machine reusing the subflow port
369 ip netns exec "$ns2" ./pm_nl_ctl ann\
370 dead:beef:2::2 token "$client6_token" id $client_addr_id dev ns2eth1
371 print_test "ADD_ADDR6 id:${client_addr_id} dead:beef:2::2 (ns2) => ns1, reuse port"
373 verify_announce_event "$server_evts" "$ANNOUNCED" "$server6_token" "dead:beef:2::2"\
374 "$client_addr_id" "$client6_port" "v6"
376 # ADD_ADDR from the client to server machine using a new port
378 client_addr_id=$((client_addr_id+1))
379 ip netns exec "$ns2" ./pm_nl_ctl ann 10.0.2.2 token "$client4_token" id\
380 $client_addr_id dev ns2eth1 port $new4_port
381 print_test "ADD_ADDR id:${client_addr_id} 10.0.2.2 (ns2) => ns1, new port"
383 verify_announce_event "$server_evts" "$ANNOUNCED" "$server4_token" "10.0.2.2"\
384 "$client_addr_id" "$new4_port"
386 # Capture events on the network namespace running the client
389 # ADD_ADDR from the server to client machine reusing the subflow port
390 ip netns exec "$ns1" ./pm_nl_ctl ann 10.0.2.1 token "$server4_token" id\
391 $server_addr_id dev ns1eth2
392 print_test "ADD_ADDR id:${server_addr_id} 10.0.2.1 (ns1) => ns2, reuse port"
394 verify_announce_event "$client_evts" "$ANNOUNCED" "$client4_token" "10.0.2.1"\
395 "$server_addr_id" "$app4_port"
397 # ADD_ADDR6 from the server to client machine reusing the subflow port
399 ip netns exec "$ns1" ./pm_nl_ctl ann dead:beef:2::1 token "$server6_token" id\
400 $server_addr_id dev ns1eth2
401 print_test "ADD_ADDR6 id:${server_addr_id} dead:beef:2::1 (ns1) => ns2, reuse port"
403 verify_announce_event "$client_evts" "$ANNOUNCED" "$client6_token" "dead:beef:2::1"\
404 "$server_addr_id" "$app6_port" "v6"
406 # ADD_ADDR from the server to client machine using a new port
408 server_addr_id=$((server_addr_id+1))
409 ip netns exec "$ns1" ./pm_nl_ctl ann 10.0.2.1 token "$server4_token" id\
410 $server_addr_id dev ns1eth2 port $new4_port
411 print_test "ADD_ADDR id:${server_addr_id} 10.0.2.1 (ns1) => ns2, new port"
413 verify_announce_event "$client_evts" "$ANNOUNCED" "$client4_token" "10.0.2.1"\
414 "$server_addr_id" "$new4_port"
417 verify_remove_event()
427 type=$(mptcp_lib_evts_get_info type "$evt" $e_type)
428 token=$(mptcp_lib_evts_get_info token "$evt" $e_type)
429 id=$(mptcp_lib_evts_get_info rem_id "$evt" $e_type)
431 check_expected "type" "token" "id"
436 print_title "Remove tests"
438 # Capture events on the network namespace running the server
441 # RM_ADDR using an invalid token should result in no action
442 local invalid_token=$(( client4_token - 1 ))
443 ip netns exec "$ns2" ./pm_nl_ctl rem token $invalid_token id\
444 $client_addr_id > /dev/null 2>&1
445 print_test "RM_ADDR id:${client_addr_id} ns2 => ns1, invalid token"
447 type=$(mptcp_lib_evts_get_info type "$server_evts")
455 # RM_ADDR using an invalid addr id should result in no action
456 local invalid_id=$(( client_addr_id + 1 ))
457 ip netns exec "$ns2" ./pm_nl_ctl rem token "$client4_token" id\
458 $invalid_id > /dev/null 2>&1
459 print_test "RM_ADDR id:${invalid_id} ns2 => ns1, invalid id"
460 type=$(mptcp_lib_evts_get_info type "$server_evts")
468 # RM_ADDR from the client to server machine
470 ip netns exec "$ns2" ./pm_nl_ctl rem token "$client4_token" id\
472 print_test "RM_ADDR id:${client_addr_id} ns2 => ns1"
474 verify_remove_event "$server_evts" "$REMOVED" "$server4_token" "$client_addr_id"
476 # RM_ADDR from the client to server machine
478 client_addr_id=$(( client_addr_id - 1 ))
479 ip netns exec "$ns2" ./pm_nl_ctl rem token "$client4_token" id\
481 print_test "RM_ADDR id:${client_addr_id} ns2 => ns1"
483 verify_remove_event "$server_evts" "$REMOVED" "$server4_token" "$client_addr_id"
485 # RM_ADDR6 from the client to server machine
487 ip netns exec "$ns2" ./pm_nl_ctl rem token "$client6_token" id\
489 print_test "RM_ADDR6 id:${client_addr_id} ns2 => ns1"
491 verify_remove_event "$server_evts" "$REMOVED" "$server6_token" "$client_addr_id"
493 # Capture events on the network namespace running the client
496 # RM_ADDR from the server to client machine
497 ip netns exec "$ns1" ./pm_nl_ctl rem token "$server4_token" id\
499 print_test "RM_ADDR id:${server_addr_id} ns1 => ns2"
501 verify_remove_event "$client_evts" "$REMOVED" "$client4_token" "$server_addr_id"
503 # RM_ADDR from the server to client machine
505 server_addr_id=$(( server_addr_id - 1 ))
506 ip netns exec "$ns1" ./pm_nl_ctl rem token "$server4_token" id\
508 print_test "RM_ADDR id:${server_addr_id} ns1 => ns2"
510 verify_remove_event "$client_evts" "$REMOVED" "$client4_token" "$server_addr_id"
512 # RM_ADDR6 from the server to client machine
514 ip netns exec "$ns1" ./pm_nl_ctl rem token "$server6_token" id\
516 print_test "RM_ADDR6 id:${server_addr_id} ns1 => ns2"
518 verify_remove_event "$client_evts" "$REMOVED" "$client6_token" "$server_addr_id"
521 verify_subflow_events()
545 info="${e_saddr} (${e_from}) => ${e_daddr}:${e_dport} (${e_to})"
547 if [ "$e_type" = "$SUB_ESTABLISHED" ]
549 if [ "$e_family" = "$AF_INET6" ]
551 print_test "CREATE_SUBFLOW6 ${info}"
553 print_test "CREATE_SUBFLOW ${info}"
556 if [ "$e_family" = "$AF_INET6" ]
558 print_test "DESTROY_SUBFLOW6 ${info}"
560 print_test "DESTROY_SUBFLOW ${info}"
564 type=$(mptcp_lib_evts_get_info type "$evt" $e_type)
565 token=$(mptcp_lib_evts_get_info token "$evt" $e_type)
566 family=$(mptcp_lib_evts_get_info family "$evt" $e_type)
567 dport=$(mptcp_lib_evts_get_info dport "$evt" $e_type)
568 locid=$(mptcp_lib_evts_get_info loc_id "$evt" $e_type)
569 remid=$(mptcp_lib_evts_get_info rem_id "$evt" $e_type)
570 if [ "$family" = "$AF_INET6" ]
572 saddr=$(mptcp_lib_evts_get_info saddr6 "$evt" $e_type)
573 daddr=$(mptcp_lib_evts_get_info daddr6 "$evt" $e_type)
575 saddr=$(mptcp_lib_evts_get_info saddr4 "$evt" $e_type)
576 daddr=$(mptcp_lib_evts_get_info daddr4 "$evt" $e_type)
579 check_expected "type" "token" "daddr" "dport" "family" "saddr" "locid" "remid"
584 print_title "Subflows v4 or v6 only tests"
586 # Capture events on the network namespace running the server
589 # Attempt to add a listener at 10.0.2.2:<subflow-port>
590 ip netns exec "$ns2" ./pm_nl_ctl listen 10.0.2.2\
592 local listener_pid=$!
594 # ADD_ADDR from client to server machine reusing the subflow port
595 ip netns exec "$ns2" ./pm_nl_ctl ann 10.0.2.2 token "$client4_token" id\
599 # CREATE_SUBFLOW from server to client machine
601 ip netns exec "$ns1" ./pm_nl_ctl csf lip 10.0.2.1 lid 23 rip 10.0.2.2\
602 rport "$client4_port" token "$server4_token"
604 verify_subflow_events $server_evts $SUB_ESTABLISHED $server4_token $AF_INET "10.0.2.1" \
605 "10.0.2.2" "$client4_port" "23" "$client_addr_id" "ns1" "ns2"
607 # Delete the listener from the client ns, if one was created
608 mptcp_lib_kill_wait $listener_pid
611 sport=$(mptcp_lib_evts_get_info sport "$server_evts" $SUB_ESTABLISHED)
613 # DESTROY_SUBFLOW from server to client machine
615 ip netns exec "$ns1" ./pm_nl_ctl dsf lip 10.0.2.1 lport "$sport" rip 10.0.2.2 rport\
616 "$client4_port" token "$server4_token"
618 verify_subflow_events "$server_evts" "$SUB_CLOSED" "$server4_token" "$AF_INET" "10.0.2.1"\
619 "10.0.2.2" "$client4_port" "23" "$client_addr_id" "ns1" "ns2"
621 # RM_ADDR from client to server machine
622 ip netns exec "$ns2" ./pm_nl_ctl rem id $client_addr_id token\
626 # Attempt to add a listener at dead:beef:2::2:<subflow-port>
627 ip netns exec "$ns2" ./pm_nl_ctl listen dead:beef:2::2\
631 # ADD_ADDR6 from client to server machine reusing the subflow port
633 ip netns exec "$ns2" ./pm_nl_ctl ann dead:beef:2::2 token "$client6_token" id\
637 # CREATE_SUBFLOW6 from server to client machine
639 ip netns exec "$ns1" ./pm_nl_ctl csf lip dead:beef:2::1 lid 23 rip\
640 dead:beef:2::2 rport "$client6_port" token "$server6_token"
642 verify_subflow_events "$server_evts" "$SUB_ESTABLISHED" "$server6_token" "$AF_INET6"\
643 "dead:beef:2::1" "dead:beef:2::2" "$client6_port" "23"\
644 "$client_addr_id" "ns1" "ns2"
646 # Delete the listener from the client ns, if one was created
647 mptcp_lib_kill_wait $listener_pid
649 sport=$(mptcp_lib_evts_get_info sport "$server_evts" $SUB_ESTABLISHED)
651 # DESTROY_SUBFLOW6 from server to client machine
653 ip netns exec "$ns1" ./pm_nl_ctl dsf lip dead:beef:2::1 lport "$sport" rip\
654 dead:beef:2::2 rport "$client6_port" token "$server6_token"
656 verify_subflow_events "$server_evts" "$SUB_CLOSED" "$server6_token" "$AF_INET6"\
657 "dead:beef:2::1" "dead:beef:2::2" "$client6_port" "23"\
658 "$client_addr_id" "ns1" "ns2"
660 # RM_ADDR from client to server machine
661 ip netns exec "$ns2" ./pm_nl_ctl rem id $client_addr_id token\
665 # Attempt to add a listener at 10.0.2.2:<new-port>
666 ip netns exec "$ns2" ./pm_nl_ctl listen 10.0.2.2\
670 # ADD_ADDR from client to server machine using a new port
672 ip netns exec "$ns2" ./pm_nl_ctl ann 10.0.2.2 token "$client4_token" id\
673 $client_addr_id port $new4_port
676 # CREATE_SUBFLOW from server to client machine
678 ip netns exec "$ns1" ./pm_nl_ctl csf lip 10.0.2.1 lid 23 rip 10.0.2.2 rport\
679 $new4_port token "$server4_token"
681 verify_subflow_events "$server_evts" "$SUB_ESTABLISHED" "$server4_token" "$AF_INET"\
682 "10.0.2.1" "10.0.2.2" "$new4_port" "23"\
683 "$client_addr_id" "ns1" "ns2"
685 # Delete the listener from the client ns, if one was created
686 mptcp_lib_kill_wait $listener_pid
688 sport=$(mptcp_lib_evts_get_info sport "$server_evts" $SUB_ESTABLISHED)
690 # DESTROY_SUBFLOW from server to client machine
692 ip netns exec "$ns1" ./pm_nl_ctl dsf lip 10.0.2.1 lport "$sport" rip 10.0.2.2 rport\
693 $new4_port token "$server4_token"
695 verify_subflow_events "$server_evts" "$SUB_CLOSED" "$server4_token" "$AF_INET" "10.0.2.1"\
696 "10.0.2.2" "$new4_port" "23" "$client_addr_id" "ns1" "ns2"
698 # RM_ADDR from client to server machine
699 ip netns exec "$ns2" ./pm_nl_ctl rem id $client_addr_id token\
702 # Capture events on the network namespace running the client
705 # Attempt to add a listener at 10.0.2.1:<subflow-port>
706 ip netns exec "$ns1" ./pm_nl_ctl listen 10.0.2.1\
710 # ADD_ADDR from server to client machine reusing the subflow port
711 ip netns exec "$ns1" ./pm_nl_ctl ann 10.0.2.1 token "$server4_token" id\
715 # CREATE_SUBFLOW from client to server machine
717 ip netns exec "$ns2" ./pm_nl_ctl csf lip 10.0.2.2 lid 23 rip 10.0.2.1 rport\
718 $app4_port token "$client4_token"
720 verify_subflow_events $client_evts $SUB_ESTABLISHED $client4_token $AF_INET "10.0.2.2"\
721 "10.0.2.1" "$app4_port" "23" "$server_addr_id" "ns2" "ns1"
723 # Delete the listener from the server ns, if one was created
724 mptcp_lib_kill_wait $listener_pid
726 sport=$(mptcp_lib_evts_get_info sport "$client_evts" $SUB_ESTABLISHED)
728 # DESTROY_SUBFLOW from client to server machine
730 ip netns exec "$ns2" ./pm_nl_ctl dsf lip 10.0.2.2 lport "$sport" rip 10.0.2.1 rport\
731 $app4_port token "$client4_token"
733 verify_subflow_events "$client_evts" "$SUB_CLOSED" "$client4_token" "$AF_INET" "10.0.2.2"\
734 "10.0.2.1" "$app4_port" "23" "$server_addr_id" "ns2" "ns1"
736 # RM_ADDR from server to client machine
737 ip netns exec "$ns1" ./pm_nl_ctl rem id $server_addr_id token\
741 # Attempt to add a listener at dead:beef:2::1:<subflow-port>
742 ip netns exec "$ns1" ./pm_nl_ctl listen dead:beef:2::1\
746 # ADD_ADDR6 from server to client machine reusing the subflow port
748 ip netns exec "$ns1" ./pm_nl_ctl ann dead:beef:2::1 token "$server6_token" id\
752 # CREATE_SUBFLOW6 from client to server machine
754 ip netns exec "$ns2" ./pm_nl_ctl csf lip dead:beef:2::2 lid 23 rip\
755 dead:beef:2::1 rport $app6_port token "$client6_token"
757 verify_subflow_events "$client_evts" "$SUB_ESTABLISHED" "$client6_token"\
758 "$AF_INET6" "dead:beef:2::2"\
759 "dead:beef:2::1" "$app6_port" "23"\
760 "$server_addr_id" "ns2" "ns1"
762 # Delete the listener from the server ns, if one was created
763 mptcp_lib_kill_wait $listener_pid
765 sport=$(mptcp_lib_evts_get_info sport "$client_evts" $SUB_ESTABLISHED)
767 # DESTROY_SUBFLOW6 from client to server machine
769 ip netns exec "$ns2" ./pm_nl_ctl dsf lip dead:beef:2::2 lport "$sport" rip\
770 dead:beef:2::1 rport $app6_port token "$client6_token"
772 verify_subflow_events $client_evts $SUB_CLOSED $client6_token $AF_INET6 "dead:beef:2::2"\
773 "dead:beef:2::1" "$app6_port" "23" "$server_addr_id" "ns2" "ns1"
775 # RM_ADDR6 from server to client machine
776 ip netns exec "$ns1" ./pm_nl_ctl rem id $server_addr_id token\
780 # Attempt to add a listener at 10.0.2.1:<new-port>
781 ip netns exec "$ns1" ./pm_nl_ctl listen 10.0.2.1\
785 # ADD_ADDR from server to client machine using a new port
787 ip netns exec "$ns1" ./pm_nl_ctl ann 10.0.2.1 token "$server4_token" id\
788 $server_addr_id port $new4_port
791 # CREATE_SUBFLOW from client to server machine
793 ip netns exec "$ns2" ./pm_nl_ctl csf lip 10.0.2.2 lid 23 rip 10.0.2.1 rport\
794 $new4_port token "$client4_token"
796 verify_subflow_events "$client_evts" "$SUB_ESTABLISHED" "$client4_token" "$AF_INET"\
797 "10.0.2.2" "10.0.2.1" "$new4_port" "23" "$server_addr_id" "ns2" "ns1"
799 # Delete the listener from the server ns, if one was created
800 mptcp_lib_kill_wait $listener_pid
802 sport=$(mptcp_lib_evts_get_info sport "$client_evts" $SUB_ESTABLISHED)
804 # DESTROY_SUBFLOW from client to server machine
806 ip netns exec "$ns2" ./pm_nl_ctl dsf lip 10.0.2.2 lport "$sport" rip 10.0.2.1 rport\
807 $new4_port token "$client4_token"
809 verify_subflow_events "$client_evts" "$SUB_CLOSED" "$client4_token" "$AF_INET" "10.0.2.2"\
810 "10.0.2.1" "$new4_port" "23" "$server_addr_id" "ns2" "ns1"
812 # RM_ADDR from server to client machine
813 ip netns exec "$ns1" ./pm_nl_ctl rem id $server_addr_id token\
817 test_subflows_v4_v6_mix()
819 print_title "Subflows v4 and v6 mix tests"
821 # Attempt to add a listener at 10.0.2.1:<subflow-port>
822 ip netns exec "$ns1" ./pm_nl_ctl listen 10.0.2.1\
824 local listener_pid=$!
826 # ADD_ADDR4 from server to client machine reusing the subflow port on
827 # the established v6 connection
829 ip netns exec "$ns1" ./pm_nl_ctl ann 10.0.2.1 token "$server6_token" id\
830 $server_addr_id dev ns1eth2
831 print_test "ADD_ADDR4 id:${server_addr_id} 10.0.2.1 (ns1) => ns2, reuse port"
833 verify_announce_event "$client_evts" "$ANNOUNCED" "$client6_token" "10.0.2.1"\
834 "$server_addr_id" "$app6_port"
836 # CREATE_SUBFLOW from client to server machine
838 ip netns exec "$ns2" ./pm_nl_ctl csf lip 10.0.2.2 lid 23 rip 10.0.2.1 rport\
839 $app6_port token "$client6_token"
841 verify_subflow_events "$client_evts" "$SUB_ESTABLISHED" "$client6_token"\
842 "$AF_INET" "10.0.2.2" "10.0.2.1" "$app6_port" "23"\
843 "$server_addr_id" "ns2" "ns1"
845 # Delete the listener from the server ns, if one was created
846 mptcp_lib_kill_wait $listener_pid
848 sport=$(mptcp_lib_evts_get_info sport "$client_evts" $SUB_ESTABLISHED)
850 # DESTROY_SUBFLOW from client to server machine
852 ip netns exec "$ns2" ./pm_nl_ctl dsf lip 10.0.2.2 lport "$sport" rip 10.0.2.1 rport\
853 $app6_port token "$client6_token"
855 verify_subflow_events "$client_evts" "$SUB_CLOSED" "$client6_token" \
856 "$AF_INET" "10.0.2.2" "10.0.2.1" "$app6_port" "23"\
857 "$server_addr_id" "ns2" "ns1"
859 # RM_ADDR from server to client machine
860 ip netns exec "$ns1" ./pm_nl_ctl rem id $server_addr_id token\
867 print_title "Prio tests"
871 # Send MP_PRIO signal from client to server machine
872 ip netns exec "$ns2" ./pm_nl_ctl set 10.0.1.2 port "$client4_port" flags backup token "$client4_token" rip 10.0.1.1 rport "$app4_port"
876 print_test "MP_PRIO TX"
877 count=$(mptcp_lib_get_counter "$ns2" "MPTcpExtMPPrioTx")
878 if [ -z "$count" ]; then
880 elif [ $count != 1 ]; then
881 test_fail "Count != 1: ${count}"
887 print_test "MP_PRIO RX"
888 count=$(mptcp_lib_get_counter "$ns1" "MPTcpExtMPPrioRx")
889 if [ -z "$count" ]; then
891 elif [ $count != 1 ]; then
892 test_fail "Count != 1: ${count}"
898 verify_listener_events()
910 if [ $e_type = $LISTENER_CREATED ]; then
911 print_test "CREATE_LISTENER $e_saddr:$e_sport"
912 elif [ $e_type = $LISTENER_CLOSED ]; then
913 print_test "CLOSE_LISTENER $e_saddr:$e_sport"
916 type=$(mptcp_lib_evts_get_info type $evt $e_type)
917 family=$(mptcp_lib_evts_get_info family $evt $e_type)
918 sport=$(mptcp_lib_evts_get_info sport $evt $e_type)
919 if [ $family ] && [ $family = $AF_INET6 ]; then
920 saddr=$(mptcp_lib_evts_get_info saddr6 $evt $e_type)
922 saddr=$(mptcp_lib_evts_get_info saddr4 $evt $e_type)
925 check_expected "type" "family" "saddr" "sport"
930 print_title "Listener tests"
932 if ! mptcp_lib_kallsyms_has "mptcp_event_pm_listener$"; then
933 print_test "LISTENER events"
938 # Capture events on the network namespace running the client
941 # Attempt to add a listener at 10.0.2.2:<subflow-port>
942 ip netns exec $ns2 ./pm_nl_ctl listen 10.0.2.2\
944 local listener_pid=$!
947 verify_listener_events $client_evts $LISTENER_CREATED $AF_INET 10.0.2.2 $client4_port
949 # ADD_ADDR from client to server machine reusing the subflow port
950 ip netns exec $ns2 ./pm_nl_ctl ann 10.0.2.2 token $client4_token id\
954 # CREATE_SUBFLOW from server to client machine
955 ip netns exec $ns1 ./pm_nl_ctl csf lip 10.0.2.1 lid 23 rip 10.0.2.2\
956 rport $client4_port token $server4_token
959 # Delete the listener from the client ns, if one was created
960 mptcp_lib_kill_wait $listener_pid
963 verify_listener_events $client_evts $LISTENER_CLOSED $AF_INET 10.0.2.2 $client4_port
966 print_title "Make connections"
973 test_subflows_v4_v6_mix
977 mptcp_lib_result_print_all_tap