Skip to content

Commit 9633e93

Browse files
JasonXingdavem330
authored andcommitted
mptcp: count CLOSE-WAIT sockets for MPTCP_MIB_CURRESTAB
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: d9cd27b ("mptcp: add CurrEstab MIB counter support") Signed-off-by: Jason Xing <kernelxing@tencent.com> Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a46d0ea commit 9633e93

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

net/mptcp/protocol.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2916,9 +2916,14 @@ void mptcp_set_state(struct sock *sk, int state)
29162916
if (oldstate != TCP_ESTABLISHED)
29172917
MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_CURRESTAB);
29182918
break;
2919-
2919+
case TCP_CLOSE_WAIT:
2920+
/* Unlike TCP, MPTCP sk would not have the TCP_SYN_RECV state:
2921+
* MPTCP "accepted" sockets will be created later on. So no
2922+
* transition from TCP_SYN_RECV to TCP_CLOSE_WAIT.
2923+
*/
2924+
break;
29202925
default:
2921-
if (oldstate == TCP_ESTABLISHED)
2926+
if (oldstate == TCP_ESTABLISHED || oldstate == TCP_CLOSE_WAIT)
29222927
MPTCP_DEC_STATS(sock_net(sk), MPTCP_MIB_CURRESTAB);
29232928
}
29242929

0 commit comments

Comments
 (0)