kernel tcp sockets stuck in FIN_WAIT1 after call tcp_close

From: mengkanglai
Date: Wed Nov 13 2024 - 07:53:58 EST


Hello, Eric:
Commit 151c9c724d05 (tcp: properly terminate timers for kernel sockets) introduce inet_csk_clear_xmit_timers_sync in tcp_close.
For kernel sockets it does not hold sk->sk_net_refcnt, if this is kernel tcp socket it will call tcp_send_fin in __tcp_close to send FIN packet to remotes server,
if this fin packet lost due to network faults, tcp should retransmit this fin packet, but tcp_timer stopped by inet_csk_clear_xmit_timers_sync.
tcp sockets state will stuck in FIN_WAIT1 and never go away. I think it's not right.

Best wishes!