add MPTCP_MIB_CURRESTAB
Subsystems (3)
v3 cover add MPTCP_MIB_CURRESTAB
v3:
- add mptcp_set_state helper
v2:
- use ftrace_regs_get_argument instead of regs_get_kernel_argument to fix build warnings reported kernel test robot.
Geliang Tang (5):
mptcp: add mib counter dec helper
mptcp: add a current established counter
mptcp: add mptcp_set_state helper
mptcp: use mptcp_set_state
selftests: mptcp: join: check CURRESTAB counters
net/mptcp/mib.c | 1 + net/mptcp/mib.h | 8 +++ net/mptcp/pm_netlink.c | 3 + net/mptcp/protocol.c | 57 ++++++++++++------- net/mptcp/protocol.h | 1 + net/mptcp/subflow.c | 2 +- .../testing/selftests/net/mptcp/mptcp_join.sh | 34 +++++++++++ 7 files changed, 86 insertions(+), 20 deletions(-)
Signature · 1 line
2.35.3
PATCH v3 1/5 mptcp: add mib counter dec helper
Similar to MPTCP_INC_STATS() helper, this patch adds a new helper named MPTCP_DEC_STATS() to decrement a MIB counter.
--- net/mptcp/mib.h | 7 +++++++ 1 file changed, 7 insertions(+)
net/mptcp/mib.h +7 -0
@@ -95,4 +95,11 @@ static inline void __MPTCP_INC_STATS(struct net *net,__SNMP_INC_STATS (net->mib.mptcp_statistics, field); } +static inline void MPTCP_DEC_STATS (struct net *net, +enum linux_mptcp_mib_field field) +{ +if (likely (net->mib.mptcp_statistics)) +SNMP_DEC_STATS (net->mib.mptcp_statistics, field); +} +bool mptcp_mib_alloc (struct net *net);
Signature · 1 line
2.35.3
PATCH v3 2/5 mptcp: add a current established counter
In reply to Geliang TangThis patch adds a new MIB counter named MPTCP_MIB_CURRESTAB to count current established MPTCP connections.
--- net/mptcp/mib.c | 1 + net/mptcp/mib.h | 1 + 2 files changed, 2 insertions(+)
net/mptcp/mib.c +1 -0
@@ -66,6 +66,7 @@ static const struct snmp_mib mptcp_snmp_list[] = {SNMP_MIB_ITEM ("RcvWndShared" ,MPTCP_MIB_RCVWNDSHARED ),SNMP_MIB_ITEM ("RcvWndConflictUpdate" ,MPTCP_MIB_RCVWNDCONFLICTUPDATE ),SNMP_MIB_ITEM ("RcvWndConflict" ,MPTCP_MIB_RCVWNDCONFLICT ), +SNMP_MIB_ITEM ("MPCurrEstab" ,MPTCP_MIB_CURRESTAB ), SNMP_MIB_SENTINEL };
net/mptcp/mib.h +1 -0
@@ -65,6 +65,7 @@ enum linux_mptcp_mib_field {* conflict with another subflow while updating msk rcv wnd */ MPTCP_MIB_RCVWNDCONFLICT ,/* Conflict with while updating msk rcv wnd */ +MPTCP_MIB_CURRESTAB ,/* Current established MPTCP connections */ __MPTCP_MIB_MAX };
Signature · 1 line
2.35.3
PATCH v3 3/5 mptcp: add mptcp_set_state helper
In reply to Geliang TangThis patch adds a new function mptcp_set_state(), in it if switch from or to ESTABLISH state, increment or decrement the newly added counter MPTCP_MIB_CURRESTAB.
--- net/mptcp/protocol.c | 19 +++++++++++++++++++ net/mptcp/protocol.h | 1 + 2 files changed, 20 insertions(+)
net/mptcp/protocol.c +19 -0
@@ -2885,6 +2885,25 @@ void mptcp_subflow_shutdown(struct sock *sk, struct sock *ssk, int how)release_sock (ssk); } +void mptcp_set_state (struct sock *sk,int state) +{ +int oldstate = sk->sk_state; + +switch (state) { +case TCP_ESTABLISHED : +if (oldstate !=TCP_ESTABLISHED ) +MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_CURRESTAB ); +break ; + +default : +if (oldstate ==TCP_ESTABLISHED ) +MPTCP_DEC_STATS (sock_net (sk),MPTCP_MIB_CURRESTAB ); + } + +inet_sk_state_store (sk, state); +} +EXPORT_SYMBOL_GPL (mptcp_set_state); +static const unsigned char new_state[16 ] = {/* current state: new state: action: */ [0 /* (Invalid) */ ] =TCP_CLOSE ,
net/mptcp/protocol.h +1 -0
@@ -643,6 +643,7 @@ bool __mptcp_close(struct sock *sk, long timeout);void mptcp_cancel_work (struct sock *sk);void __mptcp_unaccepted_force_close (struct sock *sk);void mptcp_set_owner_r (struct sk_buff *skb,struct sock *sk); +void mptcp_set_state (struct sock *sk,int state);bool mptcp_addresses_equal (const struct mptcp_addr_info *a,const struct mptcp_addr_info *b,bool use_port);
Signature · 1 line
2.35.3
PATCH v3 4/5 mptcp: use mptcp_set_state
In reply to Geliang TangThis patch replaces all the 'inet_sk_state_store()' calls under net/mptcp with the new helper mptcp_set_state().
--- net/mptcp/pm_netlink.c | 3 +++ net/mptcp/protocol.c | 38 +++++++++++++++++++------------------- net/mptcp/subflow.c | 2 +- 3 files changed, 23 insertions(+), 20 deletions(-)
net/mptcp/pm_netlink.c +3 -0
@@ -1048,6 +1048,9 @@ static int mptcp_pm_nl_create_listen_socket(struct sock *sk,if (err)return err; +/* avoid replacing inet_sk_state_store with mptcp_set_state here, as the +* old status is known to be TCP_CLOSE, hence will not affect the count. +*/ inet_sk_state_store (newsk,TCP_LISTEN );lock_sock (ssk); err =__inet_listen_sk (ssk, backlog);
net/mptcp/protocol.c +19 -19
@@ -443,11 +443,11 @@ static void mptcp_check_data_fin_ack(struct sock *sk)switch (sk->sk_state) {case TCP_FIN_WAIT1 : -inet_sk_state_store (sk,TCP_FIN_WAIT2 ); +mptcp_set_state (sk,TCP_FIN_WAIT2 );break ;case TCP_CLOSING :case TCP_LAST_ACK : -inet_sk_state_store (sk,TCP_CLOSE ); +mptcp_set_state (sk,TCP_CLOSE );break ; }
@@ -608,13 +608,13 @@ static bool mptcp_check_data_fin(struct sock *sk)switch (sk->sk_state) {case TCP_ESTABLISHED : -inet_sk_state_store (sk,TCP_CLOSE_WAIT ); +mptcp_set_state (sk,TCP_CLOSE_WAIT );break ;case TCP_FIN_WAIT1 : -inet_sk_state_store (sk,TCP_CLOSING ); +mptcp_set_state (sk,TCP_CLOSING );break ;case TCP_FIN_WAIT2 : -inet_sk_state_store (sk,TCP_CLOSE ); +mptcp_set_state (sk,TCP_CLOSE );break ;default :/* Other states not expected */
@@ -789,7 +789,7 @@ static bool __mptcp_subflow_error_report(struct sock *sk, struct sock *ssk)*/ ssk_state =inet_sk_state_load (ssk);if (ssk_state ==TCP_CLOSE && !sock_flag (sk,SOCK_DEAD )) -inet_sk_state_store (sk, ssk_state); +mptcp_set_state (sk, ssk_state);WRITE_ONCE (sk->sk_err, -err);/* This barrier is coupled with smp_rmb() in mptcp_poll() */
@@ -2477,7 +2477,7 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk, inet_sk_state_load(msk->first) == TCP_CLOSE) {if (sk->sk_state !=TCP_ESTABLISHED || msk->in_accept_queue ||sock_flag (sk,SOCK_DEAD )) { -inet_sk_state_store (sk,TCP_CLOSE ); +mptcp_set_state (sk,TCP_CLOSE );mptcp_close_wake_up (sk); }else {mptcp_start_tout_timer (sk);
@@ -2572,7 +2572,7 @@ static void mptcp_check_fastclose(struct mptcp_sock *msk)WRITE_ONCE (sk->sk_err,ECONNRESET ); } -inet_sk_state_store (sk,TCP_CLOSE ); +mptcp_set_state (sk,TCP_CLOSE );WRITE_ONCE (sk->sk_shutdown,SHUTDOWN_MASK );smp_mb__before_atomic ();/* SHUTDOWN must be visible first */ set_bit (MPTCP_WORK_CLOSE_SUBFLOW , &msk->flags);
@@ -2707,7 +2707,7 @@ static void mptcp_do_fastclose(struct sock *sk)struct mptcp_subflow_context *subflow, *tmp;struct mptcp_sock *msk =mptcp_sk (sk); -inet_sk_state_store (sk,TCP_CLOSE ); +mptcp_set_state (sk,TCP_CLOSE );mptcp_for_each_subflow_safe (msk, subflow, tmp)__mptcp_close_ssk (sk,mptcp_subflow_tcp_sock (subflow), subflow,MPTCP_CF_FASTCLOSE );
@@ -2926,7 +2926,7 @@ static int mptcp_close_state(struct sock *sk)int next = (int )new_state[sk->sk_state];int ns = next &TCP_STATE_MASK ; -inet_sk_state_store (sk, ns); +mptcp_set_state (sk, ns);return next &TCP_ACTION_FIN ; }
@@ -3037,7 +3037,7 @@ bool __mptcp_close(struct sock *sk, long timeout)if ((1 << sk->sk_state) & (TCPF_LISTEN |TCPF_CLOSE )) {mptcp_check_listen_stop (sk); -inet_sk_state_store (sk,TCP_CLOSE ); +mptcp_set_state (sk,TCP_CLOSE ); goto cleanup; }
@@ -3080,7 +3080,7 @@ bool __mptcp_close(struct sock *sk, long timeout)* state, let's not keep resources busy for no reasons */ if (subflows_alive ==0 ) -inet_sk_state_store (sk,TCP_CLOSE ); +mptcp_set_state (sk,TCP_CLOSE );sock_hold (sk);pr_debug ("msk=%p state=%d" , sk, sk->sk_state);
@@ -3146,7 +3146,7 @@ static int mptcp_disconnect(struct sock *sk, int flags)return -EBUSY ;mptcp_check_listen_stop (sk); -inet_sk_state_store (sk,TCP_CLOSE ); +mptcp_set_state (sk,TCP_CLOSE );mptcp_stop_rtx_timer (sk);mptcp_stop_tout_timer (sk);
@@ -3234,7 +3234,7 @@ struct sock *mptcp_sk_clone_init(const struct sock *sk,/* this can't race with mptcp_close(), as the msk is * not yet exposted to user-space */ -inet_sk_state_store (nsk,TCP_ESTABLISHED ); +mptcp_set_state (nsk,TCP_ESTABLISHED );/* The msk maintain a ref to each subflow in the connections list */ WRITE_ONCE (msk->first, ssk);
@@ -3693,7 +3693,7 @@ static int mptcp_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)if (IS_ERR (ssk))return PTR_ERR (ssk); -inet_sk_state_store (sk,TCP_SYN_SENT ); +mptcp_set_state (sk,TCP_SYN_SENT ); subflow =mptcp_subflow_ctx (ssk);#ifdef CONFIG_TCP_MD5SIG /* no MPTCP if MD5SIG is enabled on this socket or we may run out of
@@ -3743,7 +3743,7 @@ static int mptcp_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)if (unlikely (err)) {/* avoid leaving a dangling token in an unconnected socket */ mptcp_token_destroy (msk); -inet_sk_state_store (sk,TCP_CLOSE ); +mptcp_set_state (sk,TCP_CLOSE );return err; }
@@ -3833,13 +3833,13 @@ static int mptcp_listen(struct socket *sock, int backlog) goto unlock; } -inet_sk_state_store (sk,TCP_LISTEN ); +mptcp_set_state (sk,TCP_LISTEN );sock_set_flag (sk,SOCK_RCU_FREE );lock_sock (ssk); err =__inet_listen_sk (ssk, backlog);release_sock (ssk); -inet_sk_state_store (sk,inet_sk_state_load (ssk)); +mptcp_set_state (sk,inet_sk_state_load (ssk));if (!err) {sock_prot_inuse_add (sock_net (sk), sk->sk_prot,1 );
@@ -3899,7 +3899,7 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock,__mptcp_close_ssk (newsk, msk->first,mptcp_subflow_ctx (msk->first),0 );if (unlikely (list_is_singular (&msk->conn_list))) -inet_sk_state_store (newsk,TCP_CLOSE ); +mptcp_set_state (newsk,TCP_CLOSE ); } }release_sock (newsk);
net/mptcp/subflow.c +1 -1
@@ -423,7 +423,7 @@ void __mptcp_set_connected(struct sock *sk) {__mptcp_propagate_sndbuf (sk,mptcp_sk (sk)->first);if (sk->sk_state ==TCP_SYN_SENT ) { -inet_sk_state_store (sk,TCP_ESTABLISHED ); +mptcp_set_state (sk,TCP_ESTABLISHED ); sk->sk_state_change (sk); } }
Signature · 1 line
2.35.3
PATCH v3 5/5 selftests: mptcp: join: check CURRESTAB counters
In reply to Geliang TangThis patch adds a new helper chk_cestab_nr() to check the current established connections counter MIB_CURRESTAB.
In do_transfer(), invoke chk_cestab_nr() to check during the connection and when the connectin closed.
--- .../testing/selftests/net/mptcp/mptcp_join.sh | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+)
tools/testing/selftests/net/mptcp/mptcp_join.sh +34 -0
@@ -976,6 +976,23 @@ pm_nl_set_endpoint() fi } +chk_cestab_nr() +{ + local ns=$1 + local cestab=$2 + local count + + print_check "cestab" + count=$(mptcp_lib_get_counter ${ns} "MPTcpExtMPCurrEstab") + if [ -z "$count" ]; then + print_skip + elif [ "$count" != "$cestab" ]; then + fail_test "got $count current establish[s] expected $cestab" + else + print_ok + fi +} + do_transfer() { local listener_ns="$1"
@@ -990,6 +1007,9 @@ do_transfer() local fastclose=${fastclose:-""} local speed=${speed:-"fast"} + local addr_nr_ns1=${addr_nr_ns1:-0} + local addr_nr_ns2=${addr_nr_ns2:-0} + :> "$cout" :> "$sout" :> "$capout"
@@ -1090,6 +1110,13 @@ do_transfer() pm_nl_set_endpoint $listener_ns $connector_ns $connect_addr + if [ $addr_nr_ns1 != "0" ]; then + chk_cestab_nr $ns1 1 + fi + if [ $addr_nr_ns2 != "0" ]; then + chk_cestab_nr $ns2 1 + fi + wait $cpid local retc=$? wait $spid
@@ -1100,6 +1127,13 @@ do_transfer() kill $cappid fi + if [ $addr_nr_ns1 != "0" ]; then + chk_cestab_nr $ns1 0 + fi + if [ $addr_nr_ns2 != "0" ]; then + chk_cestab_nr $ns2 0 + fi + NSTAT_HISTORY=/tmp/${listener_ns}.nstat ip netns exec ${listener_ns} \ nstat | grep Tcp > /tmp/${listener_ns}.out NSTAT_HISTORY=/tmp/${connector_ns}.nstat ip netns exec ${connector_ns} \
Signature · 1 line
2.35.3
Re: selftests: mptcp: join: check CURRESTAB counters: Tests Results
Hi Geliang,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- {"code":404,"message":
- "Can't find artifacts containing file conclusion.txt"}:
- Task: https://cirrus-ci.com/task/5843851173167104
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5843851173167104/summary/summary.txt
- {"code":404,"message":
- "Can't find artifacts containing file conclusion.txt"}:
- Task: https://cirrus-ci.com/task/6406801126588416
- Summary: https://api.cirrus-ci.com/v1/artifact/task/6406801126588416/summary/summary.txt
- {"code":404,"message":
- "Can't find artifacts containing file conclusion.txt"}:
- Task: https://cirrus-ci.com/task/4999426243035136
- Summary: https://api.cirrus-ci.com/v1/artifact/task/4999426243035136/summary/summary.txt
- {"code":404,"message":
- "Can't find artifacts containing file conclusion.txt"}:
- Task: https://cirrus-ci.com/task/5280901219745792
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5280901219745792/summary/summary.txt
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/a2f9b2d4aae5
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-debugFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
Re: selftests: mptcp: join: check CURRESTAB counters: Tests Results
In reply to Geliang TangHi Geliang,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal (except selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/5025343417876480
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5025343417876480/summary/summary.txt
- KVM Validation: normal (only selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/6151243324719104
- Summary: https://api.cirrus-ci.com/v1/artifact/task/6151243324719104/summary/summary.txt
- KVM Validation: debug (only selftest_mptcp_join):
- Unstable: 1 failed test(s): selftest_mptcp_join 🔴:
- Task: https://cirrus-ci.com/task/6714193278140416
- Summary: https://api.cirrus-ci.com/v1/artifact/task/6714193278140416/summary/summary.txt
- KVM Validation: debug (except selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/5588293371297792
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5588293371297792/summary/summary.txt
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/31a63b62ef12
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-debugFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
Mat Martineau
maintainerQuoted 2 lines · Geliang Tang
v3:
- addmptcp_set_statehelper
Hi Geliang -
Could you rebase this so it applies to the current export branch?
Thanks,
Mat
Quoted 28 lines
v2:
- useftrace_regs_get_argumentinstead ofregs_get_kernel_argumentto fix build warnings reported kernel test robot.Geliang Tang (5):
mptcp: add mib counter dec helper
mptcp: add a current established counter
mptcp: addmptcp_set_statehelper
mptcp: usemptcp_set_state
selftests: mptcp: join: check CURRESTAB countersnet/mptcp/mib.c | 1 + net/mptcp/mib.h | 8 +++ net/mptcp/pm_netlink.c | 3 + net/mptcp/protocol.c | 57 ++++++++++++------- net/mptcp/protocol.h | 1 + net/mptcp/subflow.c | 2 +- .../testing/selftests/net/mptcp/mptcp_join.sh | 34 +++++++++++ 7 files changed, 86 insertions(+), 20 deletions(-)Signature · 1 line
2.35.3