[PATCH mptcp-next v8 2/4] mptcp: add statistics for mptcp socket in use

menglong8.dong@gmail.com posted 4 patches 3 years, 2 months ago
Maintainers: Mat Martineau <mathew.j.martineau@linux.intel.com>, Matthieu Baerts <matthieu.baerts@tessares.net>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Shuah Khan <shuah@kernel.org>
There is a newer version of this series
[PATCH mptcp-next v8 2/4] mptcp: add statistics for mptcp socket in use
Posted by menglong8.dong@gmail.com 3 years, 2 months ago
From: Menglong Dong <imagedong@tencent.com>

Do the statistics of mptcp socket in use with sock_prot_inuse_add().
Therefore, we can get the count of used mptcp socket from
/proc/net/protocols:

& cat /proc/net/protocols
protocol  size sockets  memory press maxhdr  slab module     cl co di ac io in de sh ss gs se re sp bi br ha uh gp em
MPTCPv6   2048      0       0   no       0   yes  kernel      y  n  y  y  y  y  y  y  y  y  y  y  n  n  n  y  y  y  n
MPTCP     1896      1       0   no       0   yes  kernel      y  n  y  y  y  y  y  y  y  y  y  y  n  n  n  y  y  y  n

Signed-off-by: Menglong Dong <imagedong@tencent.com>
---
v8:
- remove the MPTCP_INUSE flag and do the statistics according to the
  creation and destruction of the token

v6:
- introduce the 'MPTCP_INUSE' flag and check if msk is in use by it

v5:
- rebase to solve merge conflict

v4:
- rename MPTCP_DESTROIED to MPTCP_DESTROYED

v2:
- decrease the statistics for listening mptcp socket inuse with
  mptcp_listen_inuse_dec()
- add MPTCP_DESTROIED flags to store if mptcp_destroy_common() was
  called on the msk. For fallback case, we need to decrease the
---
 net/mptcp/protocol.c | 16 +++++++++++++++-
 net/mptcp/token.c    |  7 +++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index ffdccf26af99..775454a9d49b 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -3005,6 +3005,16 @@ void mptcp_copy_inaddrs(struct sock *msk, const struct sock *ssk)
 	inet_sk(msk)->inet_rcv_saddr = inet_sk(ssk)->inet_rcv_saddr;
 }
 
+static void mptcp_listen_inuse_dec(struct sock *sk)
+{
+	struct mptcp_sock *msk = mptcp_sk(sk);
+	struct socket *ssock;
+
+	ssock = __mptcp_nmpc_socket(msk);
+	if (ssock && inet_sk_state_load(ssock->sk) == TCP_LISTEN)
+		sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
+}
+
 static int mptcp_disconnect(struct sock *sk, int flags)
 {
 	struct mptcp_sock *msk = mptcp_sk(sk);
@@ -3025,6 +3035,7 @@ static int mptcp_disconnect(struct sock *sk, int flags)
 	if (msk->token)
 		mptcp_event(MPTCP_EVENT_CLOSED, msk, NULL, GFP_KERNEL);
 
+	mptcp_listen_inuse_dec(sk);
 	/* msk->subflow is still intact, the following will not free the first
 	 * subflow
 	 */
@@ -3203,6 +3214,7 @@ static void mptcp_destroy(struct sock *sk)
 {
 	struct mptcp_sock *msk = mptcp_sk(sk);
 
+	mptcp_listen_inuse_dec(sk);
 	/* clears msk->subflow, allowing the following to close
 	 * even the initial subflow
 	 */
@@ -3675,8 +3687,10 @@ static int mptcp_listen(struct socket *sock, int backlog)
 
 	err = ssock->ops->listen(ssock, backlog);
 	inet_sk_state_store(sk, inet_sk_state_load(ssock->sk));
-	if (!err)
+	if (!err) {
+		sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
 		mptcp_copy_inaddrs(sk, ssock->sk);
+	}
 
 	mptcp_event_pm_listener(ssock->sk, MPTCP_EVENT_LISTENER_CREATED);
 
diff --git a/net/mptcp/token.c b/net/mptcp/token.c
index 65430f314a68..54064146175f 100644
--- a/net/mptcp/token.c
+++ b/net/mptcp/token.c
@@ -175,6 +175,9 @@ int mptcp_token_new_connect(struct sock *sk)
 	__sk_nulls_add_node_rcu((struct sock *)msk, &bucket->msk_chain);
 	bucket->chain_len++;
 	spin_unlock_bh(&bucket->lock);
+	sock_prot_inuse_add(sock_net(subflow->conn),
+			    subflow->conn->sk_prot,
+			    1);
 	return 0;
 }
 
@@ -190,8 +193,10 @@ void mptcp_token_accept(struct mptcp_subflow_request_sock *req,
 			struct mptcp_sock *msk)
 {
 	struct mptcp_subflow_request_sock *pos;
+	struct sock *sk = (struct sock *)msk;
 	struct token_bucket *bucket;
 
+	sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
 	bucket = token_bucket(req->token);
 	spin_lock_bh(&bucket->lock);
 
@@ -370,12 +375,14 @@ void mptcp_token_destroy_request(struct request_sock *req)
  */
 void mptcp_token_destroy(struct mptcp_sock *msk)
 {
+	struct sock *sk = (struct sock *)msk;
 	struct token_bucket *bucket;
 	struct mptcp_sock *pos;
 
 	if (sk_unhashed((struct sock *)msk))
 		return;
 
+	sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
 	bucket = token_bucket(msk->token);
 	spin_lock_bh(&bucket->lock);
 	pos = __token_lookup_msk(bucket, msk->token);
-- 
2.37.2
Re: [PATCH mptcp-next v8 2/4] mptcp: add statistics for mptcp socket in use
Posted by Paolo Abeni 3 years, 1 month ago
On Thu, 2022-12-08 at 10:45 +0800, menglong8.dong@gmail.com wrote:
> diff --git a/net/mptcp/token.c b/net/mptcp/token.c
> index 65430f314a68..54064146175f 100644
> --- a/net/mptcp/token.c
> +++ b/net/mptcp/token.c
> @@ -175,6 +175,9 @@ int mptcp_token_new_connect(struct sock *sk)
>  	__sk_nulls_add_node_rcu((struct sock *)msk, &bucket->msk_chain);
>  	bucket->chain_len++;
>  	spin_unlock_bh(&bucket->lock);
> +	sock_prot_inuse_add(sock_net(subflow->conn),
> +			    subflow->conn->sk_prot,
> +			    1);

Whoops, sorry for not noticing the above earlier...
Here it would be better rename the mptcp_token_new_connect argument to
'ssk', and add a new local variable:

	struct sock *sk = subflow->conn;

and replace the '(struct sock *)msk', 'subflow->conn' above with 'sk'. 

Side note: the kunit crash is due to build_icsk() being too naive: it
creates a completely zeroed inet_connection_sock, while after this
patch mptcp_token_new_connect() requires that the sk_prot field is
initialized, too. 

The issue could be addresses with an addtional chunk in token_test.c.
Note that for token's test sake, sk_prot could be initialized to any
available/already exported proto.
---
diff --git a/net/mptcp/token_test.c b/net/mptcp/token_test.c
index 5d984bec1cd8..3bffe8d0d36f 100644
--- a/net/mptcp/token_test.c
+++ b/net/mptcp/token_test.c
@@ -36,6 +36,9 @@ static struct inet_connection_sock *build_icsk(struct kunit *test)
 	icsk = kunit_kzalloc(test, sizeof(struct inet_connection_sock),
 			     GFP_USER);
 	KUNIT_EXPECT_NOT_ERR_OR_NULL(test, icsk);
+
+	/* be sure the tocken helpers can dereference sk->sk_prot */
+	icsk->icsk_inet.sk.sk_prot = &tcp_prot;
 	return icsk;
 }
Re: [PATCH mptcp-next v8 2/4] mptcp: add statistics for mptcp socket in use
Posted by Menglong Dong 3 years, 1 month ago
On Tue, Dec 13, 2022 at 1:03 AM Paolo Abeni <pabeni@redhat.com> wrote:
>
> On Thu, 2022-12-08 at 10:45 +0800, menglong8.dong@gmail.com wrote:
> > diff --git a/net/mptcp/token.c b/net/mptcp/token.c
> > index 65430f314a68..54064146175f 100644
> > --- a/net/mptcp/token.c
> > +++ b/net/mptcp/token.c
> > @@ -175,6 +175,9 @@ int mptcp_token_new_connect(struct sock *sk)
> >       __sk_nulls_add_node_rcu((struct sock *)msk, &bucket->msk_chain);
> >       bucket->chain_len++;
> >       spin_unlock_bh(&bucket->lock);
> > +     sock_prot_inuse_add(sock_net(subflow->conn),
> > +                         subflow->conn->sk_prot,
> > +                         1);
>
> Whoops, sorry for not noticing the above earlier...
> Here it would be better rename the mptcp_token_new_connect argument to
> 'ssk', and add a new local variable:
>
>         struct sock *sk = subflow->conn;
>
> and replace the '(struct sock *)msk', 'subflow->conn' above with 'sk'.
>

Okay!

> Side note: the kunit crash is due to build_icsk() being too naive: it
> creates a completely zeroed inet_connection_sock, while after this
> patch mptcp_token_new_connect() requires that the sk_prot field is
> initialized, too.
>
> The issue could be addresses with an addtional chunk in token_test.c.
> Note that for token's test sake, sk_prot could be initialized to any
> available/already exported proto.
> ---
> diff --git a/net/mptcp/token_test.c b/net/mptcp/token_test.c
> index 5d984bec1cd8..3bffe8d0d36f 100644
> --- a/net/mptcp/token_test.c
> +++ b/net/mptcp/token_test.c
> @@ -36,6 +36,9 @@ static struct inet_connection_sock *build_icsk(struct kunit *test)
>         icsk = kunit_kzalloc(test, sizeof(struct inet_connection_sock),
>                              GFP_USER);
>         KUNIT_EXPECT_NOT_ERR_OR_NULL(test, icsk);
> +
> +       /* be sure the tocken helpers can dereference sk->sk_prot */
> +       icsk->icsk_inet.sk.sk_prot = &tcp_prot;
>         return icsk;
>  }
>

Get it! Thanks~

Menglong Dong

>
Re: [PATCH mptcp-next v8 2/4] mptcp: add statistics for mptcp socket in use
Posted by Paolo Abeni 3 years, 1 month ago
On Thu, 2022-12-08 at 10:45 +0800, menglong8.dong@gmail.com wrote:
> From: Menglong Dong <imagedong@tencent.com>
> 
> Do the statistics of mptcp socket in use with sock_prot_inuse_add().
> Therefore, we can get the count of used mptcp socket from
> /proc/net/protocols:
> 
> & cat /proc/net/protocols
> protocol  size sockets  memory press maxhdr  slab module     cl co di ac io in de sh ss gs se re sp bi br ha uh gp em
> MPTCPv6   2048      0       0   no       0   yes  kernel      y  n  y  y  y  y  y  y  y  y  y  y  n  n  n  y  y  y  n
> MPTCP     1896      1       0   no       0   yes  kernel      y  n  y  y  y  y  y  y  y  y  y  y  n  n  n  y  y  y  n
> 
> Signed-off-by: Menglong Dong <imagedong@tencent.com>
> ---
> v8:
> - remove the MPTCP_INUSE flag and do the statistics according to the
>   creation and destruction of the token
> 
> v6:
> - introduce the 'MPTCP_INUSE' flag and check if msk is in use by it
> 
> v5:
> - rebase to solve merge conflict
> 
> v4:
> - rename MPTCP_DESTROIED to MPTCP_DESTROYED
> 
> v2:
> - decrease the statistics for listening mptcp socket inuse with
>   mptcp_listen_inuse_dec()
> - add MPTCP_DESTROIED flags to store if mptcp_destroy_common() was
>   called on the msk. For fallback case, we need to decrease the
> ---
>  net/mptcp/protocol.c | 16 +++++++++++++++-
>  net/mptcp/token.c    |  7 +++++++
>  2 files changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index ffdccf26af99..775454a9d49b 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -3005,6 +3005,16 @@ void mptcp_copy_inaddrs(struct sock *msk, const struct sock *ssk)
>  	inet_sk(msk)->inet_rcv_saddr = inet_sk(ssk)->inet_rcv_saddr;
>  }
>  
> +static void mptcp_listen_inuse_dec(struct sock *sk)
> +{
> +	struct mptcp_sock *msk = mptcp_sk(sk);
> +	struct socket *ssock;
> +
> +	ssock = __mptcp_nmpc_socket(msk);
> +	if (ssock && inet_sk_state_load(ssock->sk) == TCP_LISTEN)

Here I think you can check directly: sk->sk_state == TCP_LISTEN, which
should be both simpler and safer, since this should be called under the
(m)sk socket lock.

It would be nice adding a comment describing why the state check is
needed, e.g.

	/* Listener sockets do not have a valid token, but we need to
	 * account them, too.
	 */

Other then that, LGTM.

Cheers,

Paolo
Re: [PATCH mptcp-next v8 2/4] mptcp: add statistics for mptcp socket in use
Posted by Menglong Dong 3 years, 1 month ago
Hello,

On Tue, Dec 13, 2022 at 12:35 AM Paolo Abeni <pabeni@redhat.com> wrote:
>
> On Thu, 2022-12-08 at 10:45 +0800, menglong8.dong@gmail.com wrote:
> > From: Menglong Dong <imagedong@tencent.com>
> >
> > Do the statistics of mptcp socket in use with sock_prot_inuse_add().
> > Therefore, we can get the count of used mptcp socket from
> > /proc/net/protocols:
> >
> > & cat /proc/net/protocols
> > protocol  size sockets  memory press maxhdr  slab module     cl co di ac io in de sh ss gs se re sp bi br ha uh gp em
> > MPTCPv6   2048      0       0   no       0   yes  kernel      y  n  y  y  y  y  y  y  y  y  y  y  n  n  n  y  y  y  n
> > MPTCP     1896      1       0   no       0   yes  kernel      y  n  y  y  y  y  y  y  y  y  y  y  n  n  n  y  y  y  n
> >
> > Signed-off-by: Menglong Dong <imagedong@tencent.com>
> > ---
> > v8:
> > - remove the MPTCP_INUSE flag and do the statistics according to the
> >   creation and destruction of the token
> >
> > v6:
> > - introduce the 'MPTCP_INUSE' flag and check if msk is in use by it
> >
> > v5:
> > - rebase to solve merge conflict
> >
> > v4:
> > - rename MPTCP_DESTROIED to MPTCP_DESTROYED
> >
> > v2:
> > - decrease the statistics for listening mptcp socket inuse with
> >   mptcp_listen_inuse_dec()
> > - add MPTCP_DESTROIED flags to store if mptcp_destroy_common() was
> >   called on the msk. For fallback case, we need to decrease the
> > ---
> >  net/mptcp/protocol.c | 16 +++++++++++++++-
> >  net/mptcp/token.c    |  7 +++++++
> >  2 files changed, 22 insertions(+), 1 deletion(-)
> >
> > diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> > index ffdccf26af99..775454a9d49b 100644
> > --- a/net/mptcp/protocol.c
> > +++ b/net/mptcp/protocol.c
> > @@ -3005,6 +3005,16 @@ void mptcp_copy_inaddrs(struct sock *msk, const struct sock *ssk)
> >       inet_sk(msk)->inet_rcv_saddr = inet_sk(ssk)->inet_rcv_saddr;
> >  }
> >
> > +static void mptcp_listen_inuse_dec(struct sock *sk)
> > +{
> > +     struct mptcp_sock *msk = mptcp_sk(sk);
> > +     struct socket *ssock;
> > +
> > +     ssock = __mptcp_nmpc_socket(msk);
> > +     if (ssock && inet_sk_state_load(ssock->sk) == TCP_LISTEN)
>
> Here I think you can check directly: sk->sk_state == TCP_LISTEN, which
> should be both simpler and safer, since this should be called under the
> (m)sk socket lock.
>

Then, mptcp_listen_inuse_dec() needs to be called before msk
enters TCP_CLOSE state, which means __mptcp_close()
and mptcp_disconnect(). Do I miss any case that a listening
msk enters TCP_CLOSE state?

> It would be nice adding a comment describing why the state check is
> needed, e.g.
>
>         /* Listener sockets do not have a valid token, but we need to
>          * account them, too.
>          */
>

Sounds nice!

> Other then that, LGTM.
>
> Cheers,
>
> Paolo
>
Re: [PATCH mptcp-next v8 2/4] mptcp: add statistics for mptcp socket in use
Posted by Paolo Abeni 3 years, 1 month ago
On Fri, 2022-12-16 at 16:01 +0800, Menglong Dong wrote:
> Hello,
> 
> On Tue, Dec 13, 2022 at 12:35 AM Paolo Abeni <pabeni@redhat.com> wrote:
> > 
> > On Thu, 2022-12-08 at 10:45 +0800, menglong8.dong@gmail.com wrote:
> > > From: Menglong Dong <imagedong@tencent.com>
> > > 
> > > Do the statistics of mptcp socket in use with sock_prot_inuse_add().
> > > Therefore, we can get the count of used mptcp socket from
> > > /proc/net/protocols:
> > > 
> > > & cat /proc/net/protocols
> > > protocol  size sockets  memory press maxhdr  slab module     cl co di ac io in de sh ss gs se re sp bi br ha uh gp em
> > > MPTCPv6   2048      0       0   no       0   yes  kernel      y  n  y  y  y  y  y  y  y  y  y  y  n  n  n  y  y  y  n
> > > MPTCP     1896      1       0   no       0   yes  kernel      y  n  y  y  y  y  y  y  y  y  y  y  n  n  n  y  y  y  n
> > > 
> > > Signed-off-by: Menglong Dong <imagedong@tencent.com>
> > > ---
> > > v8:
> > > - remove the MPTCP_INUSE flag and do the statistics according to the
> > >   creation and destruction of the token
> > > 
> > > v6:
> > > - introduce the 'MPTCP_INUSE' flag and check if msk is in use by it
> > > 
> > > v5:
> > > - rebase to solve merge conflict
> > > 
> > > v4:
> > > - rename MPTCP_DESTROIED to MPTCP_DESTROYED
> > > 
> > > v2:
> > > - decrease the statistics for listening mptcp socket inuse with
> > >   mptcp_listen_inuse_dec()
> > > - add MPTCP_DESTROIED flags to store if mptcp_destroy_common() was
> > >   called on the msk. For fallback case, we need to decrease the
> > > ---
> > >  net/mptcp/protocol.c | 16 +++++++++++++++-
> > >  net/mptcp/token.c    |  7 +++++++
> > >  2 files changed, 22 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> > > index ffdccf26af99..775454a9d49b 100644
> > > --- a/net/mptcp/protocol.c
> > > +++ b/net/mptcp/protocol.c
> > > @@ -3005,6 +3005,16 @@ void mptcp_copy_inaddrs(struct sock *msk, const struct sock *ssk)
> > >       inet_sk(msk)->inet_rcv_saddr = inet_sk(ssk)->inet_rcv_saddr;
> > >  }
> > > 
> > > +static void mptcp_listen_inuse_dec(struct sock *sk)
> > > +{
> > > +     struct mptcp_sock *msk = mptcp_sk(sk);
> > > +     struct socket *ssock;
> > > +
> > > +     ssock = __mptcp_nmpc_socket(msk);
> > > +     if (ssock && inet_sk_state_load(ssock->sk) == TCP_LISTEN)
> > 
> > Here I think you can check directly: sk->sk_state == TCP_LISTEN, which
> > should be both simpler and safer, since this should be called under the
> > (m)sk socket lock.
> > 
> 
> Then, mptcp_listen_inuse_dec() needs to be called before msk
> enters TCP_CLOSE state, which means __mptcp_close()
> and mptcp_disconnect(). Do I miss any case that a listening
> msk enters TCP_CLOSE state?

AFAIK, that is correct. Note that the number of hooks will not change
compared to the current patch revision (mptcp_disconnect() +
mptcp_destroy()).


Cheers,

Paolo

Re: [PATCH mptcp-next v8 2/4] mptcp: add statistics for mptcp socket in use
Posted by Menglong Dong 3 years, 1 month ago
Hello,

On Fri, Dec 16, 2022 at 4:45 PM Paolo Abeni <pabeni@redhat.com> wrote:
>
> On Fri, 2022-12-16 at 16:01 +0800, Menglong Dong wrote:
> > Hello,
> >
> > On Tue, Dec 13, 2022 at 12:35 AM Paolo Abeni <pabeni@redhat.com> wrote:
> > >
> > > On Thu, 2022-12-08 at 10:45 +0800, menglong8.dong@gmail.com wrote:
> > > > From: Menglong Dong <imagedong@tencent.com>
> > > >
> > > > Do the statistics of mptcp socket in use with sock_prot_inuse_add().
> > > > Therefore, we can get the count of used mptcp socket from
> > > > /proc/net/protocols:
> > > >
> > > > & cat /proc/net/protocols
> > > > protocol  size sockets  memory press maxhdr  slab module     cl co di ac io in de sh ss gs se re sp bi br ha uh gp em
> > > > MPTCPv6   2048      0       0   no       0   yes  kernel      y  n  y  y  y  y  y  y  y  y  y  y  n  n  n  y  y  y  n
> > > > MPTCP     1896      1       0   no       0   yes  kernel      y  n  y  y  y  y  y  y  y  y  y  y  n  n  n  y  y  y  n
> > > >
> > > > Signed-off-by: Menglong Dong <imagedong@tencent.com>
> > > > ---
> > > > v8:
> > > > - remove the MPTCP_INUSE flag and do the statistics according to the
> > > >   creation and destruction of the token
> > > >
> > > > v6:
> > > > - introduce the 'MPTCP_INUSE' flag and check if msk is in use by it
> > > >
> > > > v5:
> > > > - rebase to solve merge conflict
> > > >
> > > > v4:
> > > > - rename MPTCP_DESTROIED to MPTCP_DESTROYED
> > > >
> > > > v2:
> > > > - decrease the statistics for listening mptcp socket inuse with
> > > >   mptcp_listen_inuse_dec()
> > > > - add MPTCP_DESTROIED flags to store if mptcp_destroy_common() was
> > > >   called on the msk. For fallback case, we need to decrease the
> > > > ---
> > > >  net/mptcp/protocol.c | 16 +++++++++++++++-
> > > >  net/mptcp/token.c    |  7 +++++++
> > > >  2 files changed, 22 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> > > > index ffdccf26af99..775454a9d49b 100644
> > > > --- a/net/mptcp/protocol.c
> > > > +++ b/net/mptcp/protocol.c
> > > > @@ -3005,6 +3005,16 @@ void mptcp_copy_inaddrs(struct sock *msk, const struct sock *ssk)
> > > >       inet_sk(msk)->inet_rcv_saddr = inet_sk(ssk)->inet_rcv_saddr;
> > > >  }
> > > >
> > > > +static void mptcp_listen_inuse_dec(struct sock *sk)
> > > > +{
> > > > +     struct mptcp_sock *msk = mptcp_sk(sk);
> > > > +     struct socket *ssock;
> > > > +
> > > > +     ssock = __mptcp_nmpc_socket(msk);
> > > > +     if (ssock && inet_sk_state_load(ssock->sk) == TCP_LISTEN)
> > >
> > > Here I think you can check directly: sk->sk_state == TCP_LISTEN, which
> > > should be both simpler and safer, since this should be called under the
> > > (m)sk socket lock.
> > >
> >
> > Then, mptcp_listen_inuse_dec() needs to be called before msk
> > enters TCP_CLOSE state, which means __mptcp_close()
> > and mptcp_disconnect(). Do I miss any case that a listening
> > msk enters TCP_CLOSE state?
>
> AFAIK, that is correct. Note that the number of hooks will not change
> compared to the current patch revision (mptcp_disconnect() +
> mptcp_destroy()).
>

With the changes you suggested, I need to the move mptcp_listen_inuse_dec()
that called in mptcp_destroy() to __mptcp_close(), as msk is already in
CLOSE state in mptcp_destroy(). Isn't it?

Thanks!
Menglong Dong

>
> Cheers,
>
> Paolo
>
Re: [PATCH mptcp-next v8 2/4] mptcp: add statistics for mptcp socket in use
Posted by Matthieu Baerts 3 years, 2 months ago
Hi Menglong Dong,

On 08/12/2022 03:45, menglong8.dong@gmail.com wrote:
> From: Menglong Dong <imagedong@tencent.com>
> 
> Do the statistics of mptcp socket in use with sock_prot_inuse_add().
> Therefore, we can get the count of used mptcp socket from
> /proc/net/protocols:
> 
> & cat /proc/net/protocols
> protocol  size sockets  memory press maxhdr  slab module     cl co di ac io in de sh ss gs se re sp bi br ha uh gp em
> MPTCPv6   2048      0       0   no       0   yes  kernel      y  n  y  y  y  y  y  y  y  y  y  y  n  n  n  y  y  y  n
> MPTCP     1896      1       0   no       0   yes  kernel      y  n  y  y  y  y  y  y  y  y  y  y  n  n  n  y  y  y  n
> 
> Signed-off-by: Menglong Dong <imagedong@tencent.com>
> ---
> v8:
> - remove the MPTCP_INUSE flag and do the statistics according to the
>   creation and destruction of the token

Thank you for the new version!

I marked this series as "Changes Requested" on Patchwork because I guess
you saw the CI was not happy with the KUnit token tests, e.g.:

- KVM Validation: normal (except selftest_mptcp_join):
  - Unstable: 1 failed test(s): insmod - Critical: 3 Call Trace(s) ❌:
  - Task: https://cirrus-ci.com/task/5270512411082752
  - Summary:
https://api.cirrus-ci.com/v1/artifact/task/5270512411082752/summary/summary.txt
  - Debug: https://cirrus-ci.com/task/4989037434372096

Do you mind looking at that please?

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net
Re: [PATCH mptcp-next v8 2/4] mptcp: add statistics for mptcp socket in use
Posted by Menglong Dong 3 years, 2 months ago
On Thu, Dec 8, 2022 at 9:53 PM Matthieu Baerts
<matthieu.baerts@tessares.net> wrote:
>
> Hi Menglong Dong,
>
> On 08/12/2022 03:45, menglong8.dong@gmail.com wrote:
> > From: Menglong Dong <imagedong@tencent.com>
> >
> > Do the statistics of mptcp socket in use with sock_prot_inuse_add().
> > Therefore, we can get the count of used mptcp socket from
> > /proc/net/protocols:
> >
> > & cat /proc/net/protocols
> > protocol  size sockets  memory press maxhdr  slab module     cl co di ac io in de sh ss gs se re sp bi br ha uh gp em
> > MPTCPv6   2048      0       0   no       0   yes  kernel      y  n  y  y  y  y  y  y  y  y  y  y  n  n  n  y  y  y  n
> > MPTCP     1896      1       0   no       0   yes  kernel      y  n  y  y  y  y  y  y  y  y  y  y  n  n  n  y  y  y  n
> >
> > Signed-off-by: Menglong Dong <imagedong@tencent.com>
> > ---
> > v8:
> > - remove the MPTCP_INUSE flag and do the statistics according to the
> >   creation and destruction of the token
>
> Thank you for the new version!
>
> I marked this series as "Changes Requested" on Patchwork because I guess
> you saw the CI was not happy with the KUnit token tests, e.g.:
>
> - KVM Validation: normal (except selftest_mptcp_join):
>   - Unstable: 1 failed test(s): insmod - Critical: 3 Call Trace(s) ❌:
>   - Task: https://cirrus-ci.com/task/5270512411082752
>   - Summary:
> https://api.cirrus-ci.com/v1/artifact/task/5270512411082752/summary/summary.txt
>   - Debug: https://cirrus-ci.com/task/4989037434372096
>
> Do you mind looking at that please?
>

Of course! I'll run all of the tests to make sure they pass.

> Cheers,
> Matt
> --
> Tessares | Belgium | Hybrid Access Solutions
> www.tessares.net