userspace pm remove id 0 subflow & address
Subsystems (3)
v8 cover userspace pm remove id 0 subflow & address
v8:
- merge two squash-to patches for v7.
- address to #428 too.
v7:
- move evts_get_info into mptcp_lib.sh, update userspace_pm.sh with this helper too.
- drop the last two cleanup patches, they'll be sent in another series.
v6:
- add a new helper get_info_value, update chk_mptcp_info(), verify_listener_events() and pedit_action_pkts() too.
- only patch 1, 2, 4 are changed, other patches are the same as v5.
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.
Geliang Tang (8):
mptcp: add NO_INITIAL_SUBFLOW flag
selftests: mptcp: add evts_get_info helper
selftests: mptcp: update userspace pm test 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
include/uapi/linux/mptcp.h | 1 + net/mptcp/pm_netlink.c | 4 +- net/mptcp/pm_userspace.c | 33 ++- net/mptcp/protocol.c | 4 + net/mptcp/protocol.h | 15 ++ net/mptcp/sockopt.c | 2 + .../testing/selftests/net/mptcp/mptcp_join.sh | 221 +++++++++++++----- .../testing/selftests/net/mptcp/mptcp_lib.sh | 12 + .../selftests/net/mptcp/userspace_pm.sh | 87 ++++--- 9 files changed, 267 insertions(+), 112 deletions(-)
Signature · 1 line
2.35.3
PATCH v8 1/8 mptcp: add NO_INITIAL_SUBFLOW flag
If the initial subflow has been removed, we cannot know without checking other counters, e.g. ss -ti <filter> | grep -c tcp-ulp-mptcp or getsockopt(SOL_MPTCP, MPTCP_FULL_INFO, ...) (or others except MPTCP_INFO of course) and then check mptcp_subflow_data->num_subflows to get the total amount of subflows.
This patch adds a new flag NO_INITIAL_SUBFLOW in mptcpi_flags to know if the initial subflow has been removed. With this bit, we can then compute the total amount of subflows from mptcp_info by doing something like:
if (mptcpi_flags & MPTCP_INFO_FLAG_HAS_INITIAL_SUBFLOW)
mptcpi_subflows += 1;
Add two helpers __mptcp_check_no_initial_subflow() and __mptcp_set_no_initial_subflow() too.
--- include/uapi/linux/mptcp.h | 1 + net/mptcp/pm_netlink.c | 4 +++- net/mptcp/protocol.c | 4 ++++ net/mptcp/protocol.h | 15 +++++++++++++++ net/mptcp/sockopt.c | 2 ++ 5 files changed, 25 insertions(+), 1 deletion(-)
include/uapi/linux/mptcp.h +1 -0
@@ -107,6 +107,7 @@ enum {#define MPTCP_INFO_FLAG_FALLBACK _BITUL(0)#define MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED _BITUL(1) +#define MPTCP_INFO_FLAG_NO_INITIAL_SUBFLOW _BITUL(2)struct mptcp_info {__u8 mptcpi_subflows;
net/mptcp/pm_netlink.c +3 -1
@@ -1462,7 +1462,9 @@ static int mptcp_nl_remove_id_zero_address(struct net *net,struct sock *sk = (struct sock *)msk;struct mptcp_addr_info msk_local; -if (list_empty (&msk->conn_list) ||mptcp_pm_is_userspace (msk)) +if (list_empty (&msk->conn_list) || +mptcp_pm_is_userspace (msk) || +__mptcp_check_no_initial_subflow (msk)) goto next;mptcp_local_address ((struct sock_common *)msk, &msk_local);
net/mptcp/protocol.c +4 -0
@@ -2461,6 +2461,8 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,void mptcp_close_ssk (struct sock *sk,struct sock *ssk,struct mptcp_subflow_context *subflow) { +struct mptcp_sock *msk =mptcp_sk (sk); +if (sk->sk_state ==TCP_ESTABLISHED )mptcp_event (MPTCP_EVENT_SUB_CLOSED ,mptcp_sk (sk), ssk,GFP_KERNEL );
@@ -2469,6 +2471,8 @@ void mptcp_close_ssk(struct sock *sk, struct sock *ssk,*/ mptcp_pm_subflow_check_next (mptcp_sk (sk), ssk, subflow); +if (ssk == msk->first) +__mptcp_set_no_initial_subflow (msk);__mptcp_close_ssk (sk, ssk, subflow,MPTCP_CF_PUSH ); }
net/mptcp/protocol.h +15 -0
@@ -115,6 +115,7 @@#define MPTCP_WORK_RTX 2#define MPTCP_FALLBACK_DONE 4#define MPTCP_WORK_CLOSE_SUBFLOW 5 +#define MPTCP_NO_INITIAL_SUBFLOW 6/* MPTCP socket release cb flags */ #define MPTCP_PUSH_PENDING 1
@@ -1031,6 +1032,20 @@ static inline void __mptcp_do_fallback(struct mptcp_sock *msk)set_bit (MPTCP_FALLBACK_DONE , &msk->flags); } +static inline bool __mptcp_check_no_initial_subflow (const struct mptcp_sock *msk) +{ +return test_bit (MPTCP_NO_INITIAL_SUBFLOW , &msk->flags); +} + +static inline void __mptcp_set_no_initial_subflow (struct mptcp_sock *msk) +{ +if (__mptcp_check_no_initial_subflow (msk)) { +pr_debug ("no initial subflow (msk=%p)" , msk); +return ; + } +set_bit (MPTCP_NO_INITIAL_SUBFLOW , &msk->flags); +} +static inline void mptcp_do_fallback (struct sock *ssk) {struct mptcp_subflow_context *subflow =mptcp_subflow_ctx (ssk);
net/mptcp/sockopt.c +2 -0
@@ -919,6 +919,8 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info) flags |=MPTCP_INFO_FLAG_FALLBACK ;if (READ_ONCE (msk->can_ack)) flags |=MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED ; +if (__mptcp_check_no_initial_subflow (msk)) + flags |=MPTCP_INFO_FLAG_NO_INITIAL_SUBFLOW ; info->mptcpi_flags = flags;mptcp_data_lock (sk); info->mptcpi_snd_una = msk->snd_una;
Signature · 1 line
2.35.3
Re: [PATCH mptcp-next v8 1/8] mptcp: add NO_INITIAL_SUBFLOW flag
Hi Geliang,
Quoted 6 lines · Geliang Tang
If the initial subflow has been removed, we cannot know without checking other counters, e.g. ss -ti <filter> | grep -c tcp-ulp-mptcp or
getsockopt(SOL_MPTCP, MPTCP_FULL_INFO, ...)(or others exceptMPTCP_INFOof course) and then checkmptcp_subflow_data->num_subflowsto get the total amount of subflows.
Quoted 6 lines
This patch adds a new flag
NO_INITIAL_SUBFLOWinmptcpi_flagsto know if the initial subflow has been removed. With this bit, we can then compute the total amount of subflows frommptcp_infoby doing something like:if (
mptcpi_flags&MPTCP_INFO_FLAG_HAS_INITIAL_SUBFLOW)mptcpi_subflows += 1;
Thank you for looking at that!
(...)
net/mptcp/sockopt.c void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info) · line 923
Quoted 10 lines
net/mptcp/sockopt.c +2
-0@@ -919,6 +919,8 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info) flags |=MPTCP_INFO_FLAG_FALLBACK ;if (READ_ONCE (msk->can_ack)) flags |=MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED ; +if (__mptcp_check_no_initial_subflow (msk)) + flags |=MPTCP_INFO_FLAG_NO_INITIAL_SUBFLOW ;
I had a very brief look but can we not just check if msk->first == NULL instead?
Cheers,
Matt
Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net
Re: [PATCH mptcp-next v8 1/8] mptcp: add NO_INITIAL_SUBFLOW flag
Hi Matt,
Quoted 20 lines · Matthieu Baerts
Hi Geliang,
Quoted 6 lines · Geliang Tang
If the initial subflow has been removed, we cannot know without checking other counters, e.g. ss -ti <filter> | grep -c tcp-ulp-mptcp or
getsockopt(SOL_MPTCP, MPTCP_FULL_INFO, ...)(or others exceptMPTCP_INFOof course) and then checkmptcp_subflow_data->num_subflowsto get the total amount of subflows.Quoted 6 lines
This patch adds a new flag
NO_INITIAL_SUBFLOWinmptcpi_flagsto know if the initial subflow has been removed. With this bit, we can then compute the total amount of subflows frommptcp_infoby doing something like:if (
mptcpi_flags&MPTCP_INFO_FLAG_HAS_INITIAL_SUBFLOW)mptcpi_subflows += 1;Thank you for looking at that!
(...)
Quoted 13 lines
net/mptcp/sockopt.c void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info) · line 923
Quoted 10 lines
net/mptcp/sockopt.c +2
-0@@ -919,6 +919,8 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info) flags |=MPTCP_INFO_FLAG_FALLBACK ;if (READ_ONCE (msk->can_ack)) flags |=MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED ; +if (__mptcp_check_no_initial_subflow (msk)) + flags |=MPTCP_INFO_FLAG_NO_INITIAL_SUBFLOW ;I had a very brief look but can we not just check if
msk->first== NULL instead?
msk->first is not NULL in this case.
When closing the initial subflow in __mptcp_close_ssk(), dispose_it is false, it goes to:
if (!dispose_it) {
/* The MPTCP code never wait on the subflow sockets, TCP-level
* disconnect should never fail
*/
WARN_ON_ONCE(tcp_disconnect(ssk, 0));
mptcp_subflow_ctx_reset(subflow);
release_sock(ssk);
goto out;
}... ...
if (ssk == msk->first)
WRITE_ONCE(msk->first, NULL);out:
if (need_push)
__mptcp_push_pending(sk, 0);"WRITE_ONCE(msk->first, NULL)" is skipped in this case.
Thanks,
-Geliang
Quoted 6 lines
Cheers,
MattSignature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net
Re: [PATCH mptcp-next v8 1/8] mptcp: add NO_INITIAL_SUBFLOW flag
Hi Geliang,
Quoted 37 lines · Geliang Tang
Hi Matt,
Quoted 20 lines · Matthieu Baerts
Hi Geliang,
Quoted 6 lines · Geliang Tang
If the initial subflow has been removed, we cannot know without checking other counters, e.g. ss -ti <filter> | grep -c tcp-ulp-mptcp or
getsockopt(SOL_MPTCP, MPTCP_FULL_INFO, ...)(or others exceptMPTCP_INFOof course) and then checkmptcp_subflow_data->num_subflowsto get the total amount of subflows.Quoted 6 lines
This patch adds a new flag
NO_INITIAL_SUBFLOWinmptcpi_flagsto know if the initial subflow has been removed. With this bit, we can then compute the total amount of subflows frommptcp_infoby doing something like:if (
mptcpi_flags&MPTCP_INFO_FLAG_HAS_INITIAL_SUBFLOW)mptcpi_subflows += 1;Thank you for looking at that!
(...)
Quoted 13 lines
net/mptcp/sockopt.c void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info) · line 923
Quoted 10 lines
net/mptcp/sockopt.c +2
-0@@ -919,6 +919,8 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info) flags |=MPTCP_INFO_FLAG_FALLBACK ;if (READ_ONCE (msk->can_ack)) flags |=MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED ; +if (__mptcp_check_no_initial_subflow (msk)) + flags |=MPTCP_INFO_FLAG_NO_INITIAL_SUBFLOW ;I had a very brief look but can we not just check if
msk->first== NULL instead?
Quoted 1 line
msk->firstis not NULL in this case.
Thank you for having looked!
Quoted 16 lines
When closing the initial subflow in
__mptcp_close_ssk(),dispose_itis false, it goes to:if (!dispose_it) { /* The MPTCP code never wait on the subflow sockets, TCP-level * disconnect should never fail */ WARN_ON_ONCE(tcp_disconnect(ssk, 0)); mptcp_subflow_ctx_reset(subflow); release_sock(ssk); goto out; }... ...
Quoted 8 lines
if (ssk == msk->first) WRITE_ONCE(msk->first, NULL);out:
if (need_push) __mptcp_push_pending(sk, 0);"
WRITE_ONCE(msk->first, NULL)" is skipped in this case.
I didn't check further but is it normal? Is 'msk->first' still valid at the end of __mptcp_close_ssk() if we close the initial subflow?
If yes, can we not check something like "msk->first->sk_state"?
Cheers,
Matt
Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net
PATCH v8 2/8 selftests: mptcp: add evts_get_info helper
In reply to Geliang TangThis patch adds a new helper get_info_value(), using 'sed' command to parse the value of the given item name in the line with the given keyword, to make chk_mptcp_info() and pedit_action_pkts() more readable.
Also add another helper evts_get_info() to use get_info_value() to parse the output of 'pm_nl_ctl events' command, to make all the userpsace pm selftests more readable, both in mptcp_join.sh and userspace_pm.sh.
--- .../testing/selftests/net/mptcp/mptcp_join.sh | 19 ++-- .../testing/selftests/net/mptcp/mptcp_lib.sh | 10 +++ .../selftests/net/mptcp/userspace_pm.sh | 86 +++++++++---------- 3 files changed, 57 insertions(+), 58 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +8 -11
@@ -1862,10 +1862,8 @@ chk_mptcp_info() print_check "mptcp_info ${info1:0:8}=$exp1:$exp2" - cnt1=$(ss -N $ns1 -inmHM | grep "$info1:" | - sed -n 's/.*\('"$info1"':\)\([[:digit:]]*\).*$/\2/p;q') - cnt2=$(ss -N $ns2 -inmHM | grep "$info2:" | - sed -n 's/.*\('"$info2"':\)\([[:digit:]]*\).*$/\2/p;q') + cnt1=$(ss -N $ns1 -inmHM | mptcp_lib_get_info_value "$info1" "$info1") + cnt2=$(ss -N $ns2 -inmHM | mptcp_lib_get_info_value "$info2" "$info2") # 'ss' only display active connections and counters that are not 0. [ -z "$cnt1" ] && cnt1=0 [ -z "$cnt2" ] && cnt2=0
@@ -2828,13 +2826,13 @@ verify_listener_events() return fi - type=$(grep "type:$e_type," $evt | sed -n 's/.*\(type:\)\([[:digit:]]*\).*$/\2/p;q') - family=$(grep "type:$e_type," $evt | sed -n 's/.*\(family:\)\([[:digit:]]*\).*$/\2/p;q') - sport=$(grep "type:$e_type," $evt | sed -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q') + type=$(mptcp_lib_evts_get_info type "$evt" "$e_type") + family=$(mptcp_lib_evts_get_info family "$evt" "$e_type") + sport=$(mptcp_lib_evts_get_info sport "$evt" "$e_type") if [ $family ] && [ $family = $AF_INET6 ]; then - saddr=$(grep "type:$e_type," $evt | sed -n 's/.*\(saddr6:\)\([0-9a-f:.]*\).*$/\2/p;q') + saddr=$(mptcp_lib_evts_get_info saddr6 "$evt" "$e_type") else - saddr=$(grep "type:$e_type," $evt | sed -n 's/.*\(saddr4:\)\([0-9.]*\).*$/\2/p;q') + saddr=$(mptcp_lib_evts_get_info saddr4 "$evt" "$e_type") fi if [ $type ] && [ $type = $e_type ] &&
@@ -3229,8 +3227,7 @@ fastclose_tests() pedit_action_pkts() { tc -n $ns2 -j -s action show action pedit index 100 | \ - grep "packets" | \ - sed 's/.*"packets":\([0-9]\+\),.*/\1/' + mptcp_lib_get_info_value \"packets\" packets } fail_tests()
tools/testing/selftests/net/mptcp/mptcp_lib.sh +10 -0
@@ -207,3 +207,13 @@ mptcp_lib_result_print_all_tap() { printf "%s\n" "${subtest}" done } + +# get the value of keyword $1 in the line marked by keyword $2 +mptcp_lib_get_info_value() { + grep "${2}" | sed -n 's/.*\('${1}':\)\([0-9a-f:.]*\).*$/\2/p;q' +} + +# $1: info name ; $2: evts_ns ; $3: event type +mptcp_lib_evts_get_info() { + cat "${2}" | mptcp_lib_get_info_value "${1}" "^type:${3:-1}," +}
tools/testing/selftests/net/mptcp/userspace_pm.sh +39 -47
185 lines not on this page · raw message
Signature · 1 line
2.35.3
PATCH v8 3/8 selftests: mptcp: update userspace pm test helpers
In reply to Geliang TangThis patch adds a new argument namespace to userspace_pm_add_addr() and userspace_pm_add_sf() to make these two helper more versatile.
Add two more versatile helpers for userspace pm remove subflow or address:userspace_pm_rm_addr() and userspace_pm_rm_sf(). The original test helpers userspace_pm_rm_sf_addr_ns1() and userspace_pm_rm_sf_addr_ns2() can be replaced by these new helpers.
--- .../testing/selftests/net/mptcp/mptcp_join.sh | 89 +++++++++---------- .../testing/selftests/net/mptcp/mptcp_lib.sh | 2 + .../selftests/net/mptcp/userspace_pm.sh | 1 - 3 files changed, 46 insertions(+), 46 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +44 -45
@@ -3252,69 +3252,66 @@ fail_tests() fi } +# $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=$(mptcp_lib_evts_get_info token "$evts") + + ip netns exec $1 ./pm_nl_ctl ann $2 token $tk id $3 sleep 1 } -userspace_pm_rm_sf_addr_ns1() +# $1: ns ; $2: id +userspace_pm_rm_addr() { - local addr=$1 - local id=$2 - local tk sp da dp - - tk=$(grep "type:1," "$evts_ns1" | - sed -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q') - sp=$(grep "type:10" "$evts_ns1" | - sed -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q') - da=$(grep "type:10" "$evts_ns1" | - sed -n 's/.*\(daddr6:\)\([0-9a-f:.]*\).*$/\2/p;q') - dp=$(grep "type:10" "$evts_ns1" | - sed -n 's/.*\(dport:\)\([[:digit:]]*\).*$/\2/p;q') - ip netns exec $ns1 ./pm_nl_ctl rem token $tk id $id - ip netns exec $ns1 ./pm_nl_ctl dsf lip "::ffff:$addr" \ - lport $sp rip $da rport $dp token $tk - wait_rm_addr $ns1 1 - wait_rm_sf $ns1 1 + local evts=$evts_ns1 + local tk + + [ "$1" == "$ns2" ] && evts=$evts_ns2 + tk=$(mptcp_lib_evts_get_info token "$evts") + + ip netns exec $1 ./pm_nl_ctl rem token $tk id $2 + wait_rm_addr $1 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=$(mptcp_lib_evts_get_info token "$evts") + da=$(mptcp_lib_evts_get_info daddr4 "$evts") + dp=$(mptcp_lib_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 } -userspace_pm_rm_sf_addr_ns2() +# $1: ns ; $2: addr $3: event type +userspace_pm_rm_sf() { - local addr=$1 - local id=$2 + local evts=$evts_ns1 + local t=${3:-1} + local ip=4 local tk da dp sp - 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") - sp=$(grep "type:10" "$evts_ns2" | - sed -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q') - ip netns exec $ns2 ./pm_nl_ctl rem token $tk id $id - ip netns exec $ns2 ./pm_nl_ctl dsf lip $addr lport $sp \ + [ "$1" == "$ns2" ] && evts=$evts_ns2 + if is_v6 $2; then ip=6; fi + tk=$(mptcp_lib_evts_get_info token "$evts") + da=$(mptcp_lib_evts_get_info "daddr$ip" "$evts" $t) + dp=$(mptcp_lib_evts_get_info dport "$evts" $t) + sp=$(mptcp_lib_evts_get_info sport "$evts" $t) + + ip netns exec $1 ./pm_nl_ctl dsf lip $2 lport $sp \ rip $da rport $dp token $tk - wait_rm_addr $ns2 1 - wait_rm_sf $ns2 1 + wait_rm_sf $1 1 } userspace_tests()
@@ -3401,12 +3398,13 @@ 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 chk_mptcp_info add_addr_signal 1 add_addr_accepted 1 - userspace_pm_rm_sf_addr_ns1 10.0.2.1 10 + 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 kill_events_pids
@@ -3422,10 +3420,11 @@ 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 + 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 kill_events_pids
tools/testing/selftests/net/mptcp/mptcp_lib.sh +2 -0
@@ -8,6 +8,8 @@ readonly KSFT_SKIP=4 # shellcheck disable=SC2155 # declare and assign separately readonly KSFT_TEST=$(basename "${0}" | sed 's/\.sh$//g') +SUB_ESTABLISHED=10 # MPTCP_EVENT_SUB_ESTABLISHED + MPTCP_LIB_SUBTESTS=() # only if supported (or forced) and not disabled, see no-color.org
tools/testing/selftests/net/mptcp/userspace_pm.sh +0 -1
@@ -25,7 +25,6 @@ fi ANNOUNCED=6 # MPTCP_EVENT_ANNOUNCED REMOVED=7 # MPTCP_EVENT_REMOVED -SUB_ESTABLISHED=10 # MPTCP_EVENT_SUB_ESTABLISHED SUB_CLOSED=11 # MPTCP_EVENT_SUB_CLOSED LISTENER_CREATED=15 #MPTCP_EVENT_LISTENER_CREATED LISTENER_CLOSED=16 #MPTCP_EVENT_LISTENER_CLOSED
Signature · 1 line
2.35.3
PATCH v8 4/8 selftests: mptcp: userspace pm remove id 0 subflow
In reply to Geliang TangThis 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.
Add a new argument all for chk_mptcp_info() to get the "correct" amount of subflows, including the initial one, if it's set as "all".
Add a new helper chk_all_subflows(), in it use 'ss' command
ss -ti | grep -c tcp-ulp-mptcp
to get all subflows number if iproute2 version is less then 6.5.0. New version of ss will test the no_initial_subflow flag to count number of all subflows.
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'.
--- .../testing/selftests/net/mptcp/mptcp_join.sh | 70 ++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +69 -1
@@ -1856,14 +1856,23 @@ chk_mptcp_info() local exp1=$2 local info2=$3 local exp2=$4 + local all=${5:-""} local cnt1 local cnt2 local dump_stats - print_check "mptcp_info ${info1:0:8}=$exp1:$exp2" + print_check "mptcp_info $all ${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") + if [ "$all" == "all" ]; then + local no_initial_1=0 no_initial_2=0 + + no_initial_1=$(ss -N $ns1 -inmHM | grep -c "no_initial_subflow") + no_initial_2=$(ss -N $ns2 -inmHM | grep -c "no_initial_subflow") + [ $info1 == "subflows" ] && [ $no_initial_1 == 0 ] && cnt1=$((cnt1+1)) + [ $info2 == "subflows" ] && [ $no_initial_2 == 0 ] && cnt2=$((cnt2+1)) + fi # 'ss' only display active connections and counters that are not 0. [ -z "$cnt1" ] && cnt1=0 [ -z "$cnt2" ] && cnt2=0
@@ -1881,6 +1890,43 @@ chk_mptcp_info() fi } +ver() +{ + printf "%02d%02d%02d%02d" ${1//./ } +} + +# $1: subflows in ns1 ; $2: subflows in ns2 +# number of all subflows, including the initial subflow. +chk_all_subflows() +{ + local ver_iproute2 + local cnt1 + local cnt2 + + ver_iproute2=$(ss -v | + sed -n 's/.*\(iproute2-\)\([0-9].[0-9].[0-9]\).*$/\2/p') + (( $(ver $ver_iproute2) > $(ver 6.5.0) )) && \ + chk_mptcp_info subflows $1 subflows $2 all && \ + return + + print_check "all 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 +} + chk_link_usage() { local ns=$1
@@ -3430,6 +3476,28 @@ 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 $ns2 10.0.3.2 20 + chk_join_nr 1 1 1 + chk_mptcp_info subflows 1 subflows 1 + chk_all_subflows 2 2 + userspace_pm_rm_sf $ns2 10.0.1.2 + chk_rm_nr 0 1 + 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()
Signature · 1 line
2.35.3
PATCH v8 5/8 mptcp: userspace pm allow creating id 0 subflow
In reply to Geliang TangThis 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.
--- net/mptcp/pm_userspace.c | 6 ------ 1 file changed, 6 deletions(-)
net/mptcp/pm_userspace.c +0 -6
@@ -307,12 +307,6 @@ 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" );
Signature · 1 line
2.35.3
PATCH v8 6/8 selftests: mptcp: userspace pm create id 0 subflow
In reply to Geliang TangThis 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.
--- .../testing/selftests/net/mptcp/mptcp_join.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
tools/testing/selftests/net/mptcp/mptcp_join.sh +19 -0
@@ -3477,6 +3477,25 @@ 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=10 \ + 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
Signature · 1 line
2.35.3
PATCH v8 7/8 mptcp: userspace pm remove id 0 address
In reply to Geliang TangThis 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.
--- net/mptcp/pm_userspace.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
net/mptcp/pm_userspace.c +27 -0
@@ -208,6 +208,30 @@ 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 sock *sk = (struct sock *)msk; +int err = -EINVAL ; + +lock_sock (sk); +spin_lock_bh (&msk->pm.lock); +if (__mptcp_check_no_initial_subflow (msk)) { +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 (sk); +sock_put (sk); +return err; +} +int mptcp_nl_cmd_remove (struct sk_buff *skb,struct genl_info *info) {struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN ];
@@ -239,6 +263,9 @@ 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) {
Signature · 1 line
2.35.3
PATCH v8 8/8 selftests: mptcp: userspace pm remove id 0 address
In reply to Geliang TangThis 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.
--- .../testing/selftests/net/mptcp/mptcp_join.sh | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+)
tools/testing/selftests/net/mptcp/mptcp_join.sh +24 -0
@@ -3517,6 +3517,30 @@ 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()
Signature · 1 line
2.35.3
PATCH 1/1 ss: mptcp: print no_initial_subflow flag
In reply to Geliang TangA new flag MPTCP_INFO_FLAG_NO_INITIAL_SUBFLOW has been added in mptcpi_flags to know if the initial subflow has been removed. With this bit, we can then compute the total amount of subflows from mptcp_info including the initial one.
This patch prints a "no_initial_subflow" info into mptcp_stats output to show the MPTCP_INFO_FLAG_NO_INITIAL_SUBFLOW has been set.
--- include/uapi/linux/mptcp.h | 1 + misc/ss.c | 2 ++ 2 files changed, 3 insertions(+)
include/uapi/linux/mptcp.h +1 -0
@@ -105,6 +105,7 @@ enum {#define MPTCP_INFO_FLAG_FALLBACK _BITUL(0)#define MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED _BITUL(1) +#define MPTCP_INFO_FLAG_NO_INITIAL_SUBFLOW _BITUL(2)struct mptcp_info {__u8 mptcpi_subflows;
misc/ss.c +2 -0
@@ -3247,6 +3247,8 @@ static void mptcp_stats_print(struct mptcp_info *s)out (" fallback" );if (s->mptcpi_flags &MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED )out (" remote_key" ); +if (s->mptcpi_flags &MPTCP_INFO_FLAG_NO_INITIAL_SUBFLOW ) +out (" no_initial_subflow" );if (s->mptcpi_token)out (" token:%x" , s->mptcpi_token);if (s->mptcpi_write_seq)
Signature · 1 line
2.35.3