Skip to content

Commit e137596

Browse files
committedJun 5, 2024
Merge branch 'tcp-mptcp-close-wait'
Jason Xing says: ==================== tcp/mptcp: count CLOSE-WAIT for CurrEstab Taking CLOSE-WAIT sockets into CurrEstab counters is in accordance with RFC 1213, as suggested by Eric and Neal. v5 Link: https://lore.kernel.org/all/[email protected]/ 1. add more detailed comment (Matthieu) v4 Link: https://lore.kernel.org/all/[email protected]/ 1. correct the Fixes: tag in patch [2/2]. (Eric) Previous discussion Link: https://lore.kernel.org/all/[email protected]/ ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 712115a + 9633e93 commit e137596

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed
 

‎net/ipv4/tcp.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -2649,6 +2649,10 @@ void tcp_set_state(struct sock *sk, int state)
26492649
if (oldstate != TCP_ESTABLISHED)
26502650
TCP_INC_STATS(sock_net(sk), TCP_MIB_CURRESTAB);
26512651
break;
2652+
case TCP_CLOSE_WAIT:
2653+
if (oldstate == TCP_SYN_RECV)
2654+
TCP_INC_STATS(sock_net(sk), TCP_MIB_CURRESTAB);
2655+
break;
26522656

26532657
case TCP_CLOSE:
26542658
if (oldstate == TCP_CLOSE_WAIT || oldstate == TCP_ESTABLISHED)
@@ -2660,7 +2664,7 @@ void tcp_set_state(struct sock *sk, int state)
26602664
inet_put_port(sk);
26612665
fallthrough;
26622666
default:
2663-
if (oldstate == TCP_ESTABLISHED)
2667+
if (oldstate == TCP_ESTABLISHED || oldstate == TCP_CLOSE_WAIT)
26642668
TCP_DEC_STATS(sock_net(sk), TCP_MIB_CURRESTAB);
26652669
}
26662670

‎net/mptcp/protocol.c

+7-2
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)