From nobody Sat Oct 11 05:56:21 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E41F723B61A for ; Thu, 9 Oct 2025 17:33:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760031217; cv=none; b=SvMD1KCpzZwdy70opMloFC5aIBGaLlo/dgYVV5LI70KqbB9UfeWdh3XiQZegetIu4ijwlbV3KFWy1P2KUJDL7F/bn6rqyLT1glF/48BFuqnKVE4dSeq3TkIBjjhazaWVZBtoTao8p/EbA3EpcRykv2xxipnCfGhO3oXK+s/E+ek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760031217; c=relaxed/simple; bh=4SR60wNa0lg543fvKyJACtQSqreohiulh7LcVAyNZ7A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qqArfsMN6ejLmjLxb+mMigphsx1WlEh5Czj7ised9Bda/I9tq9Vlk5GRjtmKbrYykVn5q5ypDevio1fTNS7Z55RhLNBF/V5RB8HmVJ14ELytavbqnFsZXquPGHfbGuRDydzh3fe1IgnDlrlS49ozIYqFV9zNTTMCZmj/0eKt/cY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RODxGMPG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RODxGMPG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CE22C4CEF9; Thu, 9 Oct 2025 17:33:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760031216; bh=4SR60wNa0lg543fvKyJACtQSqreohiulh7LcVAyNZ7A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=RODxGMPGGx1boPDRJCw9W1mts8PVpRgmRf0Tgkk3AYnzMQqXwckDrSFSD/83mU+mL thh9Y9rFwQR4uK7U2O+Vm4m9xLiBNa0dvp0fPo58OnjngDL8w/7C+OK1ljyr2bodHO kL6e19jB6m1PFBxSZpU9oV0CDN3JrND1O6WvDLqQU2i8L8dcs6SB2jCqr1BvUA/WQS 125blqNuVFkjpfpKIYFsQcDDXC/IyycMa9NxAZreLaxl0Q3wa+6vCSNpQCtrMub1AZ i6Zt9hodOdEIDyMqj2p7jxkUtfTa7eUFH0cKSl7Ob6aAcYAkYymb+f9m4qIyPQ+Uyc A4Q3iIk25iNKA== From: "Matthieu Baerts (NGI0)" Date: Thu, 09 Oct 2025 19:33:24 +0200 Subject: [PATCH mptcp-next 1/2] selftests: mptcp: join: do_transfer: reduce code dup Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251009-bind-extra-listen-v1-1-5ad2077d77a9@kernel.org> References: <20251009-bind-extra-listen-v1-0-5ad2077d77a9@kernel.org> In-Reply-To: <20251009-bind-extra-listen-v1-0-5ad2077d77a9@kernel.org> To: MPTCP Upstream Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1671; i=matttbe@kernel.org; h=from:subject:message-id; bh=4SR60wNa0lg543fvKyJACtQSqreohiulh7LcVAyNZ7A=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGDKef3yjc/n04ti+xF2XLl/7e3/fetniCZ5W9wuNfY9Nb muaV65g0FHKwiDGxSArpsgi3RaZP/N5FW+Jl58FzBxWJpAhDFycAjARHQmG/6FvrnM4ZCS+vyQz xaxgyZUDcx5cvmrdrL+ZsTT85tbWs0sZGR7sWq9UtkjPZXuJ88vXJrseTGn7eMJkGRNvz+U7og4 3z3MAAA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 The same extra long command is present twice, with one small different: the var for the stdin file is different. Use a new dedicated var in one command to avoid this code duplication. Signed-off-by: Matthieu Baerts (NGI0) Reviewed-by: Geliang Tang --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index c90d8e8b95cb..c5169020a515 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -951,6 +951,7 @@ do_transfer() local FAILING_LINKS=3D${FAILING_LINKS:-""} local fastclose=3D${fastclose:-""} local speed=3D${speed:-"fast"} + local in=3D"${sin}" port=3D$(get_port) =20 :> "$cout" @@ -999,16 +1000,12 @@ do_transfer() =20 extra_srv_args=3D"$extra_args $extra_srv_args" if [ "$test_linkfail" -gt 1 ];then - timeout ${timeout_test} \ - ip netns exec ${listener_ns} \ - ./mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \ - $extra_srv_args "::" < "$sinfail" > "$sout" & - else - timeout ${timeout_test} \ - ip netns exec ${listener_ns} \ - ./mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \ - $extra_srv_args "::" < "$sin" > "$sout" & + in=3D"${sinfail}" fi + timeout ${timeout_test} \ + ip netns exec ${listener_ns} \ + ./mptcp_connect -t ${timeout_poll} -l -p ${port} -s ${srv_proto} \ + ${extra_srv_args} "::" < "${in}" > "${sout}" & local spid=3D$! =20 mptcp_lib_wait_local_port_listen "${listener_ns}" "${port}" --=20 2.51.0 From nobody Sat Oct 11 05:56:21 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD13B245010 for ; Thu, 9 Oct 2025 17:33:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760031218; cv=none; b=R74t7llw+6OQDdbrl5A1j09mo9QTzFKJ/HXsgP/hLOqFfI5vM3cDuebu9MRBBqUrNmXQnfea7uUPhusk2YuZuhGX7c3u1B/2Q1OMOBmy5nLgOBCNJch8W//NQ+2Vw3SjccOWS3yRzXRWVop+kqTax38O0VHj3rSStzVrRdy9vQg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760031218; c=relaxed/simple; bh=mtXLXWezyXEtqcq61FhSCdT+WbcpKuPUjnlmst1ZoUc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AXR3Pv2V+tHSawDAwsvJDx7l4yukY53jGezNKCXPGYpRiHjyViCfEqhidUmrcr1gtxAqQ5ZpiLqRVpCoIW5X3MFOuQ5Jt8X0eZEXlmF4/CJMYLuMq9M51iEVS2EuHEDUti/gtFNkZ0CmwNZIStgQzgOsrvkELkkp33rHA92N8Ts= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XMPck5Yj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XMPck5Yj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03508C4CEF8; Thu, 9 Oct 2025 17:33:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760031217; bh=mtXLXWezyXEtqcq61FhSCdT+WbcpKuPUjnlmst1ZoUc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XMPck5YjtdhxKGeUiKst1IFnhoYeFfmJQRYYhVycL11Pe8wDKeQ6UPm41chbPqANw yF9D0K4OaADkvN6WtlCCIbIkcPUkwXRmIVHZJ3wl5ERkCDMT898QOcuiNCfKO5TRMX bOWBc5JjZpiWwUp1WfQfL5pcuD0UXLeWLo55X+AGZrqwD3W9pIU3FQ85spaL/uPQGX 6mN9XgwXLLer5vric69sse5myPKxmXN3qFql+sYfZ1fSsk3NWnVgD2Yb2GudH5WmQe +71Crrwa9HI757L8JkP2LBLR9wpHTo7BRGPAZ3kc6F44GOrgQ82mC2zbILbPDkT6fB WHkd6xncGCXfg== From: "Matthieu Baerts (NGI0)" Date: Thu, 09 Oct 2025 19:33:25 +0200 Subject: [PATCH mptcp-next 2/2] selftests: mptcp: join: validate extra bind cases Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251009-bind-extra-listen-v1-2-5ad2077d77a9@kernel.org> References: <20251009-bind-extra-listen-v1-0-5ad2077d77a9@kernel.org> In-Reply-To: <20251009-bind-extra-listen-v1-0-5ad2077d77a9@kernel.org> To: MPTCP Upstream Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=8759; i=matttbe@kernel.org; h=from:subject:message-id; bh=mtXLXWezyXEtqcq61FhSCdT+WbcpKuPUjnlmst1ZoUc=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGDKef3ynK7dwQZbJ1nsaG+dON9S9k3/1uIGnlMHFhZfmu uZnuF7J7ihlYRDjYpAVU2SRbovMn/m8irfEy88CZg4rE8gQBi5OAZhItRojw+rwmFsOPqe2nf8b +IV/3gVTt7f7yx12XI1OUX89jX2vrwzD/8QXPtFp7/ao7sqf/oDTLCq6RefdrLArn56pHHnGvDr bhgEA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 By design, an MPTCP connection will not accept extra subflows where no MPTCP listening sockets can accept such requests. In other words, it means that if the 'server' listens on a specific address / device, it cannot accept MP_JOIN sent to a different address / device. Except if there is another MPTCP listening socket accepting them. This is what the new tests are validating: - Forcing a bind on the main v4/v6 address, and checking that MP_JOIN to announced addresses are not accepted. - Also forcing a bind on the main v4/v6 address, but before, another listening socket is created to accept additional subflows. Note that 'mptcpize run nc -l' -- or something else only doing: socket(MPTCP), bind(), listen(0) -- would be enough, but here mptcp_connect is reused not to depend on another tool just for that. - Same as the previous one, but using v6 link-local addresses: this is a bit particular because it is required to specify the outgoing network interface when connecting to a link-local address announced by the other peer. When using the routing rules, this doesn't work (the outgoing interface is not known) ; but it does work with a 'laminar' endpoint having a specified interface. Note that extra small modifications are needed for these tests to work: - mptcp_connect's check_getpeername_connect() check should strip the specified interface when comparing addresses. - With IPv6 link-local addresses, it is required to wait for them to be ready (no longer in 'tentative' mode) before using them, otherwise the bind() will not be allowed. Link: https://github.com/multipath-tcp/mptcp_net-next/issues/591 Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_connect.c | 10 +- tools/testing/selftests/net/mptcp/mptcp_join.sh | 153 ++++++++++++++++++= +++- 2 files changed, 161 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/test= ing/selftests/net/mptcp/mptcp_connect.c index b148cadb96d0..c030b08a7195 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.c +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c @@ -1064,6 +1064,8 @@ static void check_getpeername_connect(int fd) socklen_t salen =3D sizeof(ss); char a[INET6_ADDRSTRLEN]; char b[INET6_ADDRSTRLEN]; + const char *iface; + size_t len; =20 if (getpeername(fd, (struct sockaddr *)&ss, &salen) < 0) { perror("getpeername"); @@ -1073,7 +1075,13 @@ static void check_getpeername_connect(int fd) xgetnameinfo((struct sockaddr *)&ss, salen, a, sizeof(a), b, sizeof(b)); =20 - if (strcmp(cfg_host, a) || strcmp(cfg_port, b)) + iface =3D strchr(cfg_host, '%'); + if (iface) + len =3D iface - cfg_host; + else + len =3D strlen(cfg_host) + 1; + + if (strncmp(cfg_host, a, len) || strcmp(cfg_port, b)) fprintf(stderr, "%s: %s vs %s, %s vs %s\n", __func__, cfg_host, a, cfg_port, b); } diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index c5169020a515..e323f81cdc02 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -62,6 +62,7 @@ unset sflags unset fastclose unset fullmesh unset speed +unset bind_addr unset join_syn_rej unset join_csum_ns1 unset join_csum_ns2 @@ -645,6 +646,27 @@ wait_mpj() done } =20 +wait_ll_ready() +{ + local ns=3D"${1}" + + local i + for i in $(seq 50); do + ip -n "${ns}" -6 addr show scope link | grep "inet6 fe80" | + grep -qw "tentative" || break + sleep 0.1 + done +} + +get_ll_addr() +{ + local ns=3D"${1}" + local iface=3D"${2}" + + ip -n "${ns}" -6 addr show dev "${iface}" scope link | + grep "inet6 fe80" | sed 's#.*\(fe80::.*\)/.*#\1#' +} + kill_events_pids() { mptcp_lib_kill_wait $evts_ns1_pid @@ -952,6 +974,7 @@ do_transfer() local fastclose=3D${fastclose:-""} local speed=3D${speed:-"fast"} local in=3D"${sin}" + local bind_addr=3D${bind_addr:-"::"} port=3D$(get_port) =20 :> "$cout" @@ -1005,7 +1028,7 @@ do_transfer() timeout ${timeout_test} \ ip netns exec ${listener_ns} \ ./mptcp_connect -t ${timeout_poll} -l -p ${port} -s ${srv_proto} \ - ${extra_srv_args} "::" < "${in}" > "${sout}" & + ${extra_srv_args} "${bind_addr}" < "${in}" > "${sout}" & local spid=3D$! =20 mptcp_lib_wait_local_port_listen "${listener_ns}" "${port}" @@ -3230,6 +3253,133 @@ add_addr_ports_tests() fi } =20 +bind_tests() +{ + # bind to one address should not allow extra subflows to other addresses + if reset "bind main address v4, no join v4"; then + pm_nl_set_limits $ns1 0 2 + pm_nl_set_limits $ns2 2 2 + pm_nl_add_endpoint $ns1 10.0.2.1 flags signal + bind_addr=3D"10.0.1.1" \ + run_tests $ns1 $ns2 10.0.1.1 + join_syn_tx=3D1 \ + chk_join_nr 0 0 0 + chk_add_nr 1 1 + fi + + # bind to one address should not allow extra subflows to other addresses + if reset "bind main address v6, no join v6"; then + pm_nl_set_limits $ns1 0 2 + pm_nl_set_limits $ns2 2 2 + pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal + bind_addr=3D"dead:beef:1::1" \ + run_tests $ns1 $ns2 dead:beef:1::1 + join_syn_tx=3D1 \ + chk_join_nr 0 0 0 + chk_add_nr 1 1 + fi + + # multiple binds to allow extra subflows to other addresses + if reset "multiple bind to allow joins v4"; then + local extra_bind + + pm_nl_set_limits $ns1 0 2 + pm_nl_set_limits $ns2 2 2 + pm_nl_add_endpoint $ns1 10.0.2.1 flags signal + + # Launching another app listening on a different address + # Note: it could be a totally different app, e.g. nc, socat, ... + ip netns exec ${ns1} ./mptcp_connect -l -p "$(get_port)" \ + -s MPTCP 10.0.2.1 & + extra_bind=3D$! + + bind_addr=3D"10.0.1.1" \ + run_tests $ns1 $ns2 10.0.1.1 + chk_join_nr 1 1 1 + chk_add_nr 1 1 + + kill ${extra_bind} + fi + + # multiple binds to allow extra subflows to other addresses + if reset "multiple bind to allow joins v6"; then + local extra_bind + + pm_nl_set_limits $ns1 0 2 + pm_nl_set_limits $ns2 2 2 + pm_nl_add_endpoint $ns1 dead:beef:2::1 flags signal + + # Launching another app listening on a different address + # Note: it could be a totally different app, e.g. nc, socat, ... + ip netns exec ${ns1} ./mptcp_connect -l -p "$(get_port)" \ + -s MPTCP dead:beef:2::1 & + extra_bind=3D$! + + bind_addr=3D"dead:beef:1::1" \ + run_tests $ns1 $ns2 dead:beef:1::1 + chk_join_nr 1 1 1 + chk_add_nr 1 1 + + kill ${extra_bind} + fi + + # multiple binds to allow extra subflows to other addresses: v6 LL case + if reset "multiple bind to allow joins v6 link-local routing"; then + local extra_bind ns1ll1 ns1ll2 + + ns1ll1=3D"$(get_ll_addr $ns1 ns1eth1)" + ns1ll2=3D"$(get_ll_addr $ns1 ns1eth2)" + + pm_nl_set_limits $ns1 0 2 + pm_nl_set_limits $ns2 2 2 + pm_nl_add_endpoint $ns1 "${ns1ll2}" flags signal + + wait_ll_ready $ns1 # to be able to bind + wait_ll_ready $ns2 # also needed to bind on the client side + ip netns exec ${ns1} ./mptcp_connect -l -p "$(get_port)" \ + -s MPTCP "${ns1ll2}%ns1eth2" & + extra_bind=3D$! + + bind_addr=3D"${ns1ll1}%ns1eth1" \ + run_tests $ns1 $ns2 "${ns1ll1}%ns2eth1" + # it is not possible to connect to the announced LL addr without + # specifying the outgoing interface. + join_connect_err=3D1 \ + chk_join_nr 0 0 0 + chk_add_nr 1 1 + + kill ${extra_bind} + fi + + # multiple binds to allow extra subflows to v6 LL addresses: laminar + if reset "multiple bind to allow joins v6 link-local laminar" && + continue_if mptcp_lib_kallsyms_has "mptcp_pm_get_endp_laminar_max$"; t= hen + local extra_bind ns1ll1 ns1ll2 ns2ll2 + + ns1ll1=3D"$(get_ll_addr $ns1 ns1eth1)" + ns1ll2=3D"$(get_ll_addr $ns1 ns1eth2)" + ns2ll2=3D"$(get_ll_addr $ns2 ns2eth2)" + + pm_nl_set_limits $ns1 0 2 + pm_nl_set_limits $ns2 2 2 + pm_nl_add_endpoint $ns1 "${ns1ll2}" flags signal + pm_nl_add_endpoint $ns2 "${ns2ll2}" flags laminar dev ns2eth2 + + wait_ll_ready $ns1 # to be able to bind + wait_ll_ready $ns2 # also needed to bind on the client side + ip netns exec ${ns1} ./mptcp_connect -l -p "$(get_port)" \ + -s MPTCP "${ns1ll2}%ns1eth2" & + extra_bind=3D$! + + bind_addr=3D"${ns1ll1}%ns1eth1" \ + run_tests $ns1 $ns2 "${ns1ll1}%ns2eth1" + chk_join_nr 1 1 1 + chk_add_nr 1 1 + + kill ${extra_bind} + fi +} + syncookies_tests() { # single subflow, syncookies @@ -4184,6 +4334,7 @@ all_tests_sorted=3D( M@mixed_tests b@backup_tests p@add_addr_ports_tests + B@bind_tests k@syncookies_tests S@checksum_tests d@deny_join_id0_tests --=20 2.51.0