:p
atchew
Login
Patches for "userspace pm remove id 0 subflow & address" v10. Geliang Tang (2): Squash to "selftests: mptcp: userspace pm remove id 0 subflow" selftests: mptcp: add chk_subflows_total helper tools/testing/selftests/net/mptcp/mptcp_join.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.35.3
Please update the commit log: ''' This patch adds a selftest for userpsace PM to remove id 0 subflow. Use userspace_pm_add_sf() to add a subflow, and pass initial ip address to userspace_pm_rm_sf() to remove id 0 subflow. When closing the initial subflow in __mptcp_close_ssk(), dispose_it is false, then tcp_disconnect is invoked. This will send a MP_RST to close a subflow on the peer too. So chk_rst_nr() is added in this test, and chk_all_subflows after closing the initial subflow is '1 1', not '2 1'. ''' Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- .../testing/selftests/net/mptcp/mptcp_join.sh | 33 +------------------ 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index XXXXXXX..XXXXXXX 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -XXX,XX +XXX,XX @@ chk_mptcp_info() local cnt2 local dump_stats - print_check "mptcp_info ${info1:0:14}=$exp1:$exp2" + print_check "mptcp_info ${info1:0:8}=$exp1:$exp2" cnt1=$(ss -N $ns1 -inmHM | mptcp_lib_get_info_value "$info1" "$info1") cnt2=$(ss -N $ns2 -inmHM | mptcp_lib_get_info_value "$info2" "$info2") @@ -XXX,XX +XXX,XX @@ chk_mptcp_info() fi } -# $1: subflows in ns1 ; $2: subflows in ns2 -# number of all subflows, including the initial subflow. -chk_subflows_total() -{ - local cnt1 - local cnt2 - local info="subflows_total" - - if [ $(ss -N $ns1 -inmHM | mptcp_lib_get_info_value $info $info) ]; then - chk_mptcp_info $info $1 $info $2 - return - fi - - print_check "$info $1:$2" - - cnt1=$(ss -N $ns1 -ti | grep -c tcp-ulp-mptcp) - cnt2=$(ss -N $ns2 -ti | grep -c tcp-ulp-mptcp) - - if [ "$1" != "$cnt1" ] || [ "$2" != "$cnt2" ]; then - fail_test "got subflows $cnt1:$cnt2 expected $1:$2" - dump_stats=1 - else - print_ok - fi - - if [ "$dump_stats" = 1 ]; then - ss -N $ns1 -ti - ss -N $ns2 -ti - fi -} - chk_link_usage() { local ns=$1 -- 2.35.3
This patch adds a new helper chk_subflows_total(), in it use the newly added counter mptcpi_subflows_total to get the "correct" amount of subflows, including the initial one. To be compatible with old 'ss' version without this counter, get the total subflows using this 'ss' command: ss -ti | grep -c tcp-ulp-mptcp. Note: This patch should be inserted between the commit mptcp: add mptcpi_subflows_total counter and the commit selftests: mptcp: add evts_get_info helper Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- .../testing/selftests/net/mptcp/mptcp_join.sh | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index XXXXXXX..XXXXXXX 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -XXX,XX +XXX,XX @@ chk_mptcp_info() local cnt2 local dump_stats - print_check "mptcp_info ${info1:0:8}=$exp1:$exp2" + print_check "mptcp_info ${info1:0:15}=$exp1:$exp2" cnt1=$(ss -N $ns1 -inmHM | mptcp_lib_get_info_value "$info1" "$info1") cnt2=$(ss -N $ns2 -inmHM | mptcp_lib_get_info_value "$info2" "$info2") @@ -XXX,XX +XXX,XX @@ chk_mptcp_info() fi } +# $1: subflows in ns1 ; $2: subflows in ns2 +# number of all subflows, including the initial subflow. +chk_subflows_total() +{ + local cnt1 + local cnt2 + local info="subflows_total" + + if [ $(ss -N $ns1 -inmHM | mptcp_lib_get_info_value $info $info) ]; then + chk_mptcp_info $info $1 $info $2 + return + fi + + print_check "$info $1:$2" + + cnt1=$(ss -N $ns1 -ti | grep -c tcp-ulp-mptcp) + cnt2=$(ss -N $ns2 -ti | grep -c tcp-ulp-mptcp) + + if [ "$1" != "$cnt1" ] || [ "$2" != "$cnt2" ]; then + fail_test "got subflows $cnt1:$cnt2 expected $1:$2" + dump_stats=1 + else + print_ok + fi + + if [ "$dump_stats" = 1 ]; then + ss -N $ns1 -ti + ss -N $ns2 -ti + fi +} + chk_link_usage() { local ns=$1 @@ -XXX,XX +XXX,XX @@ userspace_tests() chk_join_nr 1 1 1 chk_add_nr 1 1 chk_mptcp_info subflows 1 subflows 1 + chk_subflows_total 2 2 chk_mptcp_info add_addr_signal 1 add_addr_accepted 1 userspace_pm_rm_addr $ns1 10 userspace_pm_rm_sf $ns1 "::ffff:10.0.2.1" $SUB_ESTABLISHED chk_rm_nr 1 1 invert chk_mptcp_info subflows 0 subflows 0 + chk_subflows_total 1 1 mptcp_lib_evts_kill wait $tests_pid fi @@ -XXX,XX +XXX,XX @@ userspace_tests() userspace_pm_add_sf $ns2 10.0.3.2 20 chk_join_nr 1 1 1 chk_mptcp_info subflows 1 subflows 1 + chk_subflows_total 2 2 userspace_pm_rm_addr $ns2 20 userspace_pm_rm_sf $ns2 10.0.3.2 $SUB_ESTABLISHED chk_rm_nr 1 1 chk_mptcp_info subflows 0 subflows 0 + chk_subflows_total 1 1 mptcp_lib_evts_kill wait $tests_pid fi -- 2.35.3
v4: - add evts_get_info and chk_subflows helpers. - split the selftests patch into three. v3: - address Matt's comments in v2. v2: - fix CI errors. This patchset addresses #379 and #391, add the abilities to remove id 0 subflow and address for userspace PM. And a selftest. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/379 Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/391 Geliang Tang (6): selftests: mptcp: add evts_get_info helper selftests: mptcp: userspace pm remove id 0 subflow mptcp: userspace pm allow creating id 0 subflow selftests: mptcp: userspace pm create id 0 subflow mptcp: userspace pm remove id 0 address selftests: mptcp: userspace pm remove id 0 address net/mptcp/pm_userspace.c | 48 ++++-- .../testing/selftests/net/mptcp/mptcp_join.sh | 145 +++++++++++++++--- 2 files changed, 166 insertions(+), 27 deletions(-) -- 2.35.3
This patch adds a selftest for userpsace PM to remove id 0 subflow. A new helper userspace_pm_rm_id_0_subflow_ns2() is added, in it use ./pm_nl_ctl dsf lip 10.0.1.2 lport $sp \ rip 10.0.1.1 rport $dp token $tk to remove id 0 subflow. Add a new helper +chk_subflows(), in it use 'ss' command ss -ti | grep -c tcp-ulp-mptcp to get the "correct" amount of subflows, including the initial subflow. Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- .../testing/selftests/net/mptcp/mptcp_join.sh | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index XXXXXXX..XXXXXXX 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -XXX,XX +XXX,XX @@ userspace_pm_rm_sf_addr_ns2() wait_rm_sf $ns2 1 } +userspace_pm_rm_id_0_subflow_ns2() +{ + local tk da dp sp + + tk=$(evts_get_info token "$evts_ns2") + da=$(evts_get_info daddr4 "$evts_ns2") + dp=$(evts_get_info dport "$evts_ns2") + sp=$(evts_get_info sport "$evts_ns2") + ip netns exec $ns2 ./pm_nl_ctl dsf lip 10.0.1.2 lport $sp \ + rip $da rport $dp token $tk + wait_rm_sf $ns2 1 +} + +# $1: subflows in ns1 ; $2: subflows in ns2 +chk_subflows() +{ + local cnt1 + local cnt2 + + print_check "subflows $1:$2" + + cnt1=$(ss -N $ns1 -ti | grep -c tcp-ulp-mptcp) + cnt2=$(ss -N $ns2 -ti | grep -c tcp-ulp-mptcp) + + if [ "$1" != "$cnt1" ] || [ "$2" != "$cnt2" ]; then + fail_test "got subflows $cnt1:$cnt2 expected $1:$2" + dump_stats=1 + else + print_ok + fi + + if [ "$dump_stats" = 1 ]; then + ss -N $ns1 -ti + ss -N $ns2 -ti + fi +} + userspace_tests() { # userspace pm type prevents add_addr @@ -XXX,XX +XXX,XX @@ userspace_tests() kill_events_pids wait $tests_pid fi + + # userspace pm remove id 0 subflow + if reset_with_events "userspace pm remove id 0 subflow" && + continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + set_userspace_pm $ns2 + pm_nl_set_limits $ns1 0 1 + speed=10 \ + run_tests $ns1 $ns2 10.0.1.1 & + local tests_pid=$! + wait_mpj $ns2 + userspace_pm_add_sf 10.0.3.2 20 + chk_join_nr 1 1 1 + chk_mptcp_info subflows 1 subflows 1 + chk_subflows 2 2 + userspace_pm_rm_id_0_subflow_ns2 + chk_rm_nr 0 1 + chk_mptcp_info subflows 1 subflows 1 + chk_subflows 1 1 + kill_events_pids + wait $tests_pid + fi } endpoint_tests() -- 2.35.3
This patch drops id 0 limitation in mptcp_nl_cmd_sf_create() to allow creating additional subflows with the local addr ID 0. There is no reason not to allow additional subflows from this local address: we should be able to create new subflows from the initial endpoint. This limitation was breaking fullmesh support from userspace. Fixes: 702c2f646d42 ("mptcp: netlink: allow userspace-driven subflow establishment") Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/391 Suggested-by: Matthieu Baerts <matthieu.baerts@tessares.net> Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- net/mptcp/pm_userspace.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index XXXXXXX..XXXXXXX 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -XXX,XX +XXX,XX @@ int mptcp_nl_cmd_sf_create(struct sk_buff *skb, struct genl_info *info) goto create_err; } - if (addr_l.id == 0) { - NL_SET_ERR_MSG_ATTR(info->extack, laddr, "missing local addr id"); - err = -EINVAL; - goto create_err; - } - err = mptcp_pm_parse_addr(raddr, info, &addr_r); if (err < 0) { NL_SET_ERR_MSG_ATTR(info->extack, raddr, "error parsing remote addr"); -- 2.35.3
This patch adds a selftest to create id 0 subflow. Using ./pm_nl_ctl csf lip 10.0.3.2 lid 0 \ rip $da rport $dp token $tk command to create id 0 subflow. Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- .../testing/selftests/net/mptcp/mptcp_join.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index XXXXXXX..XXXXXXX 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -XXX,XX +XXX,XX @@ userspace_tests() wait $tests_pid fi + # userspace pm create id 0 subflow + if reset_with_events "userspace pm create id 0 subflow" && + continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + set_userspace_pm $ns2 + pm_nl_set_limits $ns1 0 1 + speed=slow \ + run_tests $ns1 $ns2 10.0.1.1 & + local tests_pid=$! + wait_mpj $ns2 + chk_mptcp_info subflows 0 subflows 0 + chk_subflows 1 1 + userspace_pm_add_sf 10.0.3.2 0 + chk_join_nr 1 1 1 + chk_mptcp_info subflows 1 subflows 1 + chk_subflows 2 2 + kill_events_pids + wait $tests_pid + fi + # userspace pm remove id 0 subflow if reset_with_events "userspace pm remove id 0 subflow" && continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then -- 2.35.3
This patch adds the ability to send RM_ADDR for local ID 0. Put id 0 into a removing list, pass it to mptcp_pm_remove_addr() to remove id 0 address. There is no reason not to allow the userspace to remove the initial address (ID 0). This special case was not taken into account not letting the userspace to delete all addresses as announced. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/379 Fixes: d9a4594edabf ("mptcp: netlink: Add MPTCP_PM_CMD_REMOVE") Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- net/mptcp/pm_userspace.c | 42 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index XXXXXXX..XXXXXXX 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -XXX,XX +XXX,XX @@ int mptcp_nl_cmd_remove(struct sk_buff *skb, struct genl_info *info) if (!mptcp_pm_is_userspace(msk)) { GENL_SET_ERR_MSG(info, "invalid request; userspace PM not selected"); - goto remove_err; + goto out; + } + + if (id_val == 0) { + struct mptcp_rm_list list = { .nr = 0 }; + struct mptcp_subflow_context *subflow; + bool has_id_0 = false; + + if (!READ_ONCE(msk->first)) { + GENL_SET_ERR_MSG(info, "no subflow in conn_list"); + goto out; + } + + spin_lock_bh(&msk->pm.lock); + mptcp_for_each_subflow(msk, subflow) { + if (subflow->remote_id == 0) { + has_id_0 = true; + break; + } + } + spin_unlock_bh(&msk->pm.lock); + + if (!has_id_0) { + GENL_SET_ERR_MSG(info, "address with id 0 not found"); + goto out; + } + + list.ids[list.nr++] = 0; + + lock_sock((struct sock *)msk); + spin_lock_bh(&msk->pm.lock); + mptcp_pm_remove_addr(msk, &list); + spin_unlock_bh(&msk->pm.lock); + release_sock((struct sock *)msk); + + err = 0; + goto out; } lock_sock((struct sock *)msk); @@ -XXX,XX +XXX,XX @@ int mptcp_nl_cmd_remove(struct sk_buff *skb, struct genl_info *info) if (!match) { GENL_SET_ERR_MSG(info, "address with specified id not found"); release_sock((struct sock *)msk); - goto remove_err; + goto out; } list_move(&match->list, &free_list); @@ -XXX,XX +XXX,XX @@ int mptcp_nl_cmd_remove(struct sk_buff *skb, struct genl_info *info) } err = 0; - remove_err: +out: sock_put((struct sock *)msk); return err; } -- 2.35.3
This patch adds a selftest for userpsace PM to remove id 0 address. A new helper userspace_pm_rm_id_0_address_ns2() is added, in it use ./pm_nl_ctl rem token $tk id 0 to remove id 0 address. Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- .../testing/selftests/net/mptcp/mptcp_join.sh | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index XXXXXXX..XXXXXXX 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -XXX,XX +XXX,XX @@ userspace_pm_rm_id_0_subflow_ns2() wait_rm_sf $ns2 1 } +userspace_pm_rm_id_0_address_ns2() +{ + local tk=$(evts_get_info token "$evts_ns2") + + ip netns exec $ns2 ./pm_nl_ctl rem token $tk id 0 + wait_rm_addr $ns2 1 +} + # $1: subflows in ns1 ; $2: subflows in ns2 chk_subflows() { @@ -XXX,XX +XXX,XX @@ userspace_tests() kill_events_pids wait $tests_pid fi + + # userspace pm remove id 0 address + if reset_with_events "userspace pm remove id 0 address" && + continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + set_userspace_pm $ns2 + pm_nl_set_limits $ns1 0 1 + speed=10 \ + run_tests $ns1 $ns2 10.0.1.1 & + local tests_pid=$! + wait_mpj $ns2 + userspace_pm_add_sf 10.0.3.2 20 + chk_join_nr 1 1 1 + chk_mptcp_info subflows 1 subflows 1 + chk_subflows 2 2 + userspace_pm_rm_id_0_address_ns2 + chk_rm_nr 1 0 + chk_mptcp_info subflows 1 subflows 1 + chk_subflows 1 1 + kill_events_pids + wait $tests_pid + fi } endpoint_tests() -- 2.35.3