:p
atchew
Login
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
v5: - update userspace_pm_add_addr/sf helpers. - add userspace_pm_rm_addr/sf helpers. - remove id 0 subflow or address will send MP_RST, add chk_rst_nr for them. - add two selftests cleanups using for-loop. 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 (9): selftests: mptcp: update userspace pm add helpers selftests: mptcp: update userspace pm rm helpers 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 selftests: mptcp: simplify checksum_tests selftests: mptcp: simplify deny_join_id0_tests net/mptcp/pm_userspace.c | 40 ++- .../testing/selftests/net/mptcp/mptcp_join.sh | 329 +++++++++++------- 2 files changed, 230 insertions(+), 139 deletions(-) -- 2.35.3
This patch adds a new helper evts_get_info(), using 'sed' command to parse the value of the given keyword in the output of 'pm_nl_ctl events' command, to make the userpsace pm selftests more readable. Then add a new argument namespace to userspace_pm_add_addr() and userspace_pm_add_sf() to make these two helper more versatile. Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- .../testing/selftests/net/mptcp/mptcp_join.sh | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 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 @@ fail_tests() fi } +# $1: info name ; $2: ns ; $3: event type +evts_get_info() +{ + sed -n '/^type:'${3:-1}',/p' "${2}" | + sed -n 's/.*\('${1}':\)\([0-9a-f:.]*\).*$/\2/p;q' +} + +# $1: ns ; $2: addr ; $3: id userspace_pm_add_addr() { - local addr=$1 - local id=$2 + local evts=$evts_ns1 local tk - tk=$(grep "type:1," "$evts_ns1" | - sed -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q') - ip netns exec $ns1 ./pm_nl_ctl ann $addr token $tk id $id + [ "$1" == "$ns2" ] && evts=$evts_ns2 + tk=$(evts_get_info token "$evts") + + ip netns exec $1 ./pm_nl_ctl ann $2 token $tk id $3 sleep 1 } @@ -XXX,XX +XXX,XX @@ userspace_pm_rm_sf_addr_ns1() wait_rm_sf $ns1 1 } +# $1: ns ; $2: addr ; $3: id userspace_pm_add_sf() { - local addr=$1 - local id=$2 + local evts=$evts_ns1 local tk da dp - tk=$(sed -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q' "$evts_ns2") - da=$(sed -n 's/.*\(daddr4:\)\([0-9.]*\).*$/\2/p;q' "$evts_ns2") - dp=$(sed -n 's/.*\(dport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts_ns2") - ip netns exec $ns2 ./pm_nl_ctl csf lip $addr lid $id \ + [ "$1" == "$ns2" ] && evts=$evts_ns2 + tk=$(evts_get_info token "$evts") + da=$(evts_get_info daddr4 "$evts") + dp=$(evts_get_info dport "$evts") + + ip netns exec $1 ./pm_nl_ctl csf lip $2 lid $3 \ rip $da rport $dp token $tk sleep 1 } @@ -XXX,XX +XXX,XX @@ userspace_tests() run_tests $ns1 $ns2 10.0.1.1 & local tests_pid=$! wait_mpj $ns1 - userspace_pm_add_addr 10.0.2.1 10 + userspace_pm_add_addr $ns1 10.0.2.1 10 chk_join_nr 1 1 1 chk_add_nr 1 1 chk_mptcp_info subflows 1 subflows 1 @@ -XXX,XX +XXX,XX @@ userspace_tests() run_tests $ns1 $ns2 10.0.1.1 & local tests_pid=$! wait_mpj $ns2 - userspace_pm_add_sf 10.0.3.2 20 + userspace_pm_add_sf $ns2 10.0.3.2 20 chk_join_nr 1 1 1 chk_mptcp_info subflows 1 subflows 1 userspace_pm_rm_sf_addr_ns2 10.0.3.2 20 -- 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. Pass id 0 to the helper userspace_pm_add_sf() to create id 0 subflow. chk_mptcp_info shows one subflow but chk_all_subflows shows two subflows in each namespace. 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_all_subflows 1 1 + userspace_pm_add_sf $ns2 10.0.3.2 0 + chk_join_nr 1 1 1 + chk_mptcp_info subflows 1 subflows 1 + chk_all_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. Check whether id 0 address is removed, if not, 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 | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) 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_announce(struct sk_buff *skb, struct genl_info *info) return err; } +static int mptcp_userspace_remove_id_zero_address(struct mptcp_sock *msk, + struct genl_info *info) +{ + struct mptcp_rm_list list = { .nr = 0 }; + struct mptcp_subflow_context *subflow; + bool has_id_0 = false; + int err = -EINVAL; + + lock_sock((struct sock *)msk); + spin_lock_bh(&msk->pm.lock); + mptcp_for_each_subflow(msk, subflow) { + if (subflow->remote_id == 0) { + has_id_0 = true; + break; + } + } + if (!has_id_0) { + GENL_SET_ERR_MSG(info, "address with id 0 not found"); + goto out; + } + + list.ids[list.nr++] = 0; + mptcp_pm_remove_addr(msk, &list); + err = 0; +out: + spin_unlock_bh(&msk->pm.lock); + release_sock((struct sock *)msk); + sock_put((struct sock *)msk); + return err; +} + int mptcp_nl_cmd_remove(struct sk_buff *skb, struct genl_info *info) { struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN]; @@ -XXX,XX +XXX,XX @@ int mptcp_nl_cmd_remove(struct sk_buff *skb, struct genl_info *info) goto remove_err; } + if (id_val == 0) + return mptcp_userspace_remove_id_zero_address(msk, info); + lock_sock((struct sock *)msk); list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) { -- 2.35.3
This patch adds a selftest for userpsace PM to remove id 0 address. Use userspace_pm_add_addr() helper to add a id 10 address, then use userspace_pm_rm_addr() helper to remove id 0 address. Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- .../testing/selftests/net/mptcp/mptcp_join.sh | 24 +++++++++++++++++++ 1 file changed, 24 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() 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 $ns1 + pm_nl_set_limits $ns2 1 1 + speed=10 \ + run_tests $ns1 $ns2 10.0.1.1 & + local tests_pid=$! + wait_mpj $ns1 + userspace_pm_add_addr $ns1 10.0.2.1 10 + chk_join_nr 1 1 1 + chk_add_nr 1 1 + chk_mptcp_info subflows 1 subflows 1 + chk_all_subflows 2 2 + chk_mptcp_info add_addr_signal 1 add_addr_accepted 1 + userspace_pm_rm_addr $ns1 0 + chk_rm_nr 1 0 invert + chk_rst_nr 1 1 invert + chk_mptcp_info subflows 1 subflows 1 + chk_all_subflows 1 1 + kill_events_pids + wait $tests_pid + fi } endpoint_tests() -- 2.35.3
The four checksum tests are similar, only one line is different. So a for-loop can be used to simplify these tests. Signed-off-by: Geliang Tang <geliang.tang@suse.com> --- .../testing/selftests/net/mptcp/mptcp_join.sh | 40 +++++-------------- 1 file changed, 10 insertions(+), 30 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 @@ syncookies_tests() checksum_tests() { - # checksum test 0 0 - if reset_with_checksum 0 0; then - pm_nl_set_limits $ns1 0 1 - pm_nl_set_limits $ns2 0 1 - run_tests $ns1 $ns2 10.0.1.1 - chk_join_nr 0 0 0 - fi + local enable - # checksum test 1 1 - if reset_with_checksum 1 1; then - pm_nl_set_limits $ns1 0 1 - pm_nl_set_limits $ns2 0 1 - run_tests $ns1 $ns2 10.0.1.1 - chk_join_nr 0 0 0 - fi - - # checksum test 0 1 - if reset_with_checksum 0 1; then - pm_nl_set_limits $ns1 0 1 - pm_nl_set_limits $ns2 0 1 - run_tests $ns1 $ns2 10.0.1.1 - chk_join_nr 0 0 0 - fi - - # checksum test 1 0 - if reset_with_checksum 1 0; then - pm_nl_set_limits $ns1 0 1 - pm_nl_set_limits $ns2 0 1 - run_tests $ns1 $ns2 10.0.1.1 - chk_join_nr 0 0 0 - fi + for enable in "0 0" "1 1" "0 1" "1 0"; do + # checksum test 0 0, 1 1, 0 1, 1 0 + if reset_with_checksum $enable; then + pm_nl_set_limits $ns1 0 1 + pm_nl_set_limits $ns2 0 1 + run_tests $ns1 $ns2 10.0.1.1 + chk_join_nr 0 0 0 + fi + done } deny_join_id0_tests() -- 2.35.3