* [PATCH net v3 0/2] tcp/mptcp: count CLOSE-WAIT for CurrEstab
@ 2024-05-30 13:13 Jason Xing
2024-05-30 13:13 ` [PATCH net v3 1/2] tcp: count CLOSE-WAIT sockets for TCP_MIB_CURRESTAB Jason Xing
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Jason Xing @ 2024-05-30 13:13 UTC (permalink / raw)
To: edumazet, kuba, pabeni, davem, dsahern, matttbe, martineau,
geliang
Cc: netdev, mptcp, kerneljasonxing, Jason Xing
From: Jason Xing <kernelxing@tencent.com>
Taking CLOSE-WAIT sockets into CurrEstab counters is in accordance with RFC
1213, as suggested by Eric and Neal.
Previous discussion
Link: https://lore.kernel.org/all/20240529033104.33882-1-kerneljasonxing@gmail.com/
Jason Xing (2):
tcp: count CLOSE-WAIT sockets for TCP_MIB_CURRESTAB
mptcp: count CLOSE-WAIT sockets for MPTCP_MIB_CURRESTAB
net/ipv4/tcp.c | 6 +++++-
net/mptcp/protocol.c | 5 +++--
2 files changed, 8 insertions(+), 3 deletions(-)
--
2.37.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net v3 1/2] tcp: count CLOSE-WAIT sockets for TCP_MIB_CURRESTAB
2024-05-30 13:13 [PATCH net v3 0/2] tcp/mptcp: count CLOSE-WAIT for CurrEstab Jason Xing
@ 2024-05-30 13:13 ` Jason Xing
2024-05-31 6:23 ` Eric Dumazet
2024-05-30 13:13 ` [PATCH net v3 2/2] mptcp: count CLOSE-WAIT sockets for MPTCP_MIB_CURRESTAB Jason Xing
2024-05-30 14:05 ` [PATCH net v3 0/2] tcp/mptcp: count CLOSE-WAIT for CurrEstab MPTCP CI
2 siblings, 1 reply; 7+ messages in thread
From: Jason Xing @ 2024-05-30 13:13 UTC (permalink / raw)
To: edumazet, kuba, pabeni, davem, dsahern, matttbe, martineau,
geliang
Cc: netdev, mptcp, kerneljasonxing, Jason Xing
From: Jason Xing <kernelxing@tencent.com>
According to RFC 1213, we should also take CLOSE-WAIT sockets into
consideration:
"tcpCurrEstab OBJECT-TYPE
...
The number of TCP connections for which the current state
is either ESTABLISHED or CLOSE- WAIT."
After this, CurrEstab counter will display the total number of
ESTABLISHED and CLOSE-WAIT sockets.
The logic of counting
When we increment the counter?
a) if we change the state to ESTABLISHED.
b) if we change the state from SYN-RECEIVED to CLOSE-WAIT.
When we decrement the counter?
a) if the socket leaves ESTABLISHED and will never go into CLOSE-WAIT,
say, on the client side, changing from ESTABLISHED to FIN-WAIT-1.
b) if the socket leaves CLOSE-WAIT, say, on the server side, changing
from CLOSE-WAIT to LAST-ACK.
Please note: there are two chances that old state of socket can be changed
to CLOSE-WAIT in tcp_fin(). One is SYN-RECV, the other is ESTABLISHED.
So we have to take care of the former case.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Jason Xing <kernelxing@tencent.com>
---
previous discussion
Link: https://lore.kernel.org/all/20240529033104.33882-1-kerneljasonxing@gmail.com/
1. Chose to fix CurrEstab instead of introduing a new counter (Eric, Neal)
---
net/ipv4/tcp.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 5fa68e7f6ddb..902266146d0e 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2646,6 +2646,10 @@ void tcp_set_state(struct sock *sk, int state)
if (oldstate != TCP_ESTABLISHED)
TCP_INC_STATS(sock_net(sk), TCP_MIB_CURRESTAB);
break;
+ case TCP_CLOSE_WAIT:
+ if (oldstate == TCP_SYN_RECV)
+ TCP_INC_STATS(sock_net(sk), TCP_MIB_CURRESTAB);
+ break;
case TCP_CLOSE:
if (oldstate == TCP_CLOSE_WAIT || oldstate == TCP_ESTABLISHED)
@@ -2657,7 +2661,7 @@ void tcp_set_state(struct sock *sk, int state)
inet_put_port(sk);
fallthrough;
default:
- if (oldstate == TCP_ESTABLISHED)
+ if (oldstate == TCP_ESTABLISHED || oldstate == TCP_CLOSE_WAIT)
TCP_DEC_STATS(sock_net(sk), TCP_MIB_CURRESTAB);
}
--
2.37.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH net v3 2/2] mptcp: count CLOSE-WAIT sockets for MPTCP_MIB_CURRESTAB
2024-05-30 13:13 [PATCH net v3 0/2] tcp/mptcp: count CLOSE-WAIT for CurrEstab Jason Xing
2024-05-30 13:13 ` [PATCH net v3 1/2] tcp: count CLOSE-WAIT sockets for TCP_MIB_CURRESTAB Jason Xing
@ 2024-05-30 13:13 ` Jason Xing
2024-05-31 6:26 ` Eric Dumazet
2024-05-30 14:05 ` [PATCH net v3 0/2] tcp/mptcp: count CLOSE-WAIT for CurrEstab MPTCP CI
2 siblings, 1 reply; 7+ messages in thread
From: Jason Xing @ 2024-05-30 13:13 UTC (permalink / raw)
To: edumazet, kuba, pabeni, davem, dsahern, matttbe, martineau,
geliang
Cc: netdev, mptcp, kerneljasonxing, Jason Xing
From: Jason Xing <kernelxing@tencent.com>
Like previous patch does in TCP, we need to adhere to RFC 1213:
"tcpCurrEstab OBJECT-TYPE
...
The number of TCP connections for which the current state
is either ESTABLISHED or CLOSE- WAIT."
So let's consider CLOSE-WAIT sockets.
The logic of counting
When we increment the counter?
a) Only if we change the state to ESTABLISHED.
When we decrement the counter?
a) if the socket leaves ESTABLISHED and will never go into CLOSE-WAIT,
say, on the client side, changing from ESTABLISHED to FIN-WAIT-1.
b) if the socket leaves CLOSE-WAIT, say, on the server side, changing
from CLOSE-WAIT to LAST-ACK.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Jason Xing <kernelxing@tencent.com>
---
net/mptcp/protocol.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 7d44196ec5b6..6d59c1c4baba 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2916,9 +2916,10 @@ void mptcp_set_state(struct sock *sk, int state)
if (oldstate != TCP_ESTABLISHED)
MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_CURRESTAB);
break;
-
+ case TCP_CLOSE_WAIT:
+ break;
default:
- if (oldstate == TCP_ESTABLISHED)
+ if (oldstate == TCP_ESTABLISHED || oldstate == TCP_CLOSE_WAIT)
MPTCP_DEC_STATS(sock_net(sk), MPTCP_MIB_CURRESTAB);
}
--
2.37.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net v3 0/2] tcp/mptcp: count CLOSE-WAIT for CurrEstab
2024-05-30 13:13 [PATCH net v3 0/2] tcp/mptcp: count CLOSE-WAIT for CurrEstab Jason Xing
2024-05-30 13:13 ` [PATCH net v3 1/2] tcp: count CLOSE-WAIT sockets for TCP_MIB_CURRESTAB Jason Xing
2024-05-30 13:13 ` [PATCH net v3 2/2] mptcp: count CLOSE-WAIT sockets for MPTCP_MIB_CURRESTAB Jason Xing
@ 2024-05-30 14:05 ` MPTCP CI
2 siblings, 0 replies; 7+ messages in thread
From: MPTCP CI @ 2024-05-30 14:05 UTC (permalink / raw)
To: Jason Xing; +Cc: mptcp
Hi Jason,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal: Success! ✅
- KVM Validation: debug: Success! ✅
- KVM Validation: btf (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/9303441254
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/7f7bd9b64def
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=857361
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-normal
For 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)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net v3 1/2] tcp: count CLOSE-WAIT sockets for TCP_MIB_CURRESTAB
2024-05-30 13:13 ` [PATCH net v3 1/2] tcp: count CLOSE-WAIT sockets for TCP_MIB_CURRESTAB Jason Xing
@ 2024-05-31 6:23 ` Eric Dumazet
0 siblings, 0 replies; 7+ messages in thread
From: Eric Dumazet @ 2024-05-31 6:23 UTC (permalink / raw)
To: Jason Xing
Cc: kuba, pabeni, davem, dsahern, matttbe, martineau, geliang, netdev,
mptcp, Jason Xing
On Thu, May 30, 2024 at 3:13 PM Jason Xing <kerneljasonxing@gmail.com> wrote:
>
> From: Jason Xing <kernelxing@tencent.com>
>
> According to RFC 1213, we should also take CLOSE-WAIT sockets into
> consideration:
>
> "tcpCurrEstab OBJECT-TYPE
> ...
> The number of TCP connections for which the current state
> is either ESTABLISHED or CLOSE- WAIT."
>
> After this, CurrEstab counter will display the total number of
> ESTABLISHED and CLOSE-WAIT sockets.
>
> The logic of counting
> When we increment the counter?
> a) if we change the state to ESTABLISHED.
> b) if we change the state from SYN-RECEIVED to CLOSE-WAIT.
>
> When we decrement the counter?
> a) if the socket leaves ESTABLISHED and will never go into CLOSE-WAIT,
> say, on the client side, changing from ESTABLISHED to FIN-WAIT-1.
> b) if the socket leaves CLOSE-WAIT, say, on the server side, changing
> from CLOSE-WAIT to LAST-ACK.
>
> Please note: there are two chances that old state of socket can be changed
> to CLOSE-WAIT in tcp_fin(). One is SYN-RECV, the other is ESTABLISHED.
> So we have to take care of the former case.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Jason Xing <kernelxing@tencent.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net v3 2/2] mptcp: count CLOSE-WAIT sockets for MPTCP_MIB_CURRESTAB
2024-05-30 13:13 ` [PATCH net v3 2/2] mptcp: count CLOSE-WAIT sockets for MPTCP_MIB_CURRESTAB Jason Xing
@ 2024-05-31 6:26 ` Eric Dumazet
2024-05-31 6:36 ` Jason Xing
0 siblings, 1 reply; 7+ messages in thread
From: Eric Dumazet @ 2024-05-31 6:26 UTC (permalink / raw)
To: Jason Xing
Cc: kuba, pabeni, davem, dsahern, matttbe, martineau, geliang, netdev,
mptcp, Jason Xing
On Thu, May 30, 2024 at 3:13 PM Jason Xing <kerneljasonxing@gmail.com> wrote:
>
> From: Jason Xing <kernelxing@tencent.com>
>
> Like previous patch does in TCP, we need to adhere to RFC 1213:
>
> "tcpCurrEstab OBJECT-TYPE
> ...
> The number of TCP connections for which the current state
> is either ESTABLISHED or CLOSE- WAIT."
>
> So let's consider CLOSE-WAIT sockets.
>
> The logic of counting
> When we increment the counter?
> a) Only if we change the state to ESTABLISHED.
>
> When we decrement the counter?
> a) if the socket leaves ESTABLISHED and will never go into CLOSE-WAIT,
> say, on the client side, changing from ESTABLISHED to FIN-WAIT-1.
> b) if the socket leaves CLOSE-WAIT, say, on the server side, changing
> from CLOSE-WAIT to LAST-ACK.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
MPTCP was not part of linux at that time.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net v3 2/2] mptcp: count CLOSE-WAIT sockets for MPTCP_MIB_CURRESTAB
2024-05-31 6:26 ` Eric Dumazet
@ 2024-05-31 6:36 ` Jason Xing
0 siblings, 0 replies; 7+ messages in thread
From: Jason Xing @ 2024-05-31 6:36 UTC (permalink / raw)
To: Eric Dumazet
Cc: kuba, pabeni, davem, dsahern, matttbe, martineau, geliang, netdev,
mptcp, Jason Xing
On Fri, May 31, 2024 at 2:26 PM Eric Dumazet <edumazet@google.com> wrote:
>
> On Thu, May 30, 2024 at 3:13 PM Jason Xing <kerneljasonxing@gmail.com> wrote:
> >
> > From: Jason Xing <kernelxing@tencent.com>
> >
> > Like previous patch does in TCP, we need to adhere to RFC 1213:
> >
> > "tcpCurrEstab OBJECT-TYPE
> > ...
> > The number of TCP connections for which the current state
> > is either ESTABLISHED or CLOSE- WAIT."
> >
> > So let's consider CLOSE-WAIT sockets.
> >
> > The logic of counting
> > When we increment the counter?
> > a) Only if we change the state to ESTABLISHED.
> >
> > When we decrement the counter?
> > a) if the socket leaves ESTABLISHED and will never go into CLOSE-WAIT,
> > say, on the client side, changing from ESTABLISHED to FIN-WAIT-1.
> > b) if the socket leaves CLOSE-WAIT, say, on the server side, changing
> > from CLOSE-WAIT to LAST-ACK.
> >
> > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
>
> MPTCP was not part of linux at that time.
Oh, right, thank you.
It should be:
Fixes: d9cd27b8cd19 ("mptcp: add CurrEstab MIB counter support")
I'll fix it soon.
Thanks,
Jason
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-05-31 6:36 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-30 13:13 [PATCH net v3 0/2] tcp/mptcp: count CLOSE-WAIT for CurrEstab Jason Xing
2024-05-30 13:13 ` [PATCH net v3 1/2] tcp: count CLOSE-WAIT sockets for TCP_MIB_CURRESTAB Jason Xing
2024-05-31 6:23 ` Eric Dumazet
2024-05-30 13:13 ` [PATCH net v3 2/2] mptcp: count CLOSE-WAIT sockets for MPTCP_MIB_CURRESTAB Jason Xing
2024-05-31 6:26 ` Eric Dumazet
2024-05-31 6:36 ` Jason Xing
2024-05-30 14:05 ` [PATCH net v3 0/2] tcp/mptcp: count CLOSE-WAIT for CurrEstab MPTCP CI
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.