net: tcp: Acknowledge FIN packets in TIMED_WAIT state

In case TCP stack enters TIMED_WAIT state (after receiving FIN/ACK reply
from peer), it should stil be ready to reply with ACK for any
consecutive FIN attempts. Othewise, in case the final ACK from Zephyr
side is lost, the connection is not properly closed on the other end,
and peer keeps retransmitting the final FIN packet.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2022-06-09 13:45:39 +02:00 committed by Carles Cufí
commit 2bd00e65ba

View file

@ -2230,6 +2230,14 @@ next_state:
}
break;
case TCP_TIME_WAIT:
/* Acknowledge any FIN attempts, in case retransmission took
* place.
*/
if (th && (FL(&fl, ==, (FIN | ACK), th_seq(th) + 1 == conn->ack) ||
FL(&fl, ==, FIN, th_seq(th) + 1 == conn->ack))) {
tcp_out(conn, ACK);
}
k_work_reschedule_for_queue(
&tcp_work_q, &conn->timewait_timer,
K_MSEC(CONFIG_NET_TCP_TIME_WAIT_DELAY));