net: tcp2: Acknowledge the incoming FIN+ACK in FIN_WAIT_1

In order to avoid retransmissions from the peer's side
on active connection close, acknowledge the incoming FIN+ACK
in FIN_WAIT_1 state.

Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
This commit is contained in:
Oleg Zhurakivskyy 2020-04-20 14:33:24 +03:00 committed by Jukka Rissanen
commit 61a1dc934c

View file

@ -939,6 +939,8 @@ next_state:
case TCP_FIN_WAIT_1:
if (th && FL(&fl, ==, (FIN | ACK), th_seq(th) == conn->ack)) {
tcp_send_timer_cancel(conn);
conn_ack(conn, + 1);
tcp_out(conn, ACK);
next = TCP_TIME_WAIT;
}
break;
@ -972,9 +974,14 @@ int net_tcp_put(struct net_context *context)
NET_DBG("%s", conn ? log_strdup(tcp_conn_state(conn, NULL)) : "");
if (conn) {
k_mutex_lock(&conn->lock, K_FOREVER);
tcp_out(conn, FIN | ACK);
conn_seq(conn, + 1);
conn_state(conn, TCP_FIN_WAIT_1);
k_mutex_unlock(&conn->lock);
}
net_context_unref(context);