net/tcp: send a reset if ack is not acceptable in syn-received state

In SYN-RCVD state, if the ACK is not acceptable, send a reset.

Signed-off-by: wenquan1 <wenquan1@xiaomi.com>
This commit is contained in:
wenquan1
2025-09-01 15:55:11 +08:00
committed by Xiang Xiao
parent 8ead446ee4
commit 74ab7816a1
2 changed files with 9 additions and 3 deletions
+2 -2
View File
@@ -1153,7 +1153,7 @@ FAR struct tcp_conn_s *tcp_alloc_accept(FAR struct net_driver_s *dev,
conn->expired = 0;
conn->isn = 0;
conn->sent = 0;
conn->sndseq_max = tcp_getsequence(conn->sndseq);
conn->sndseq_max = tcp_getsequence(conn->sndseq) + 1;
#endif
#ifdef CONFIG_NET_TCP_CC_NEWRENO
@@ -1465,7 +1465,7 @@ int tcp_connect(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr)
conn->expired = 0;
conn->isn = 0;
conn->sent = 0;
conn->sndseq_max = tcp_getsequence(conn->sndseq);
conn->sndseq_max = tcp_getsequence(conn->sndseq) + 1;
#endif
/* Save initial sndseq to rexmit_seq, otherwise it will be zero */
+7 -1
View File
@@ -1056,7 +1056,9 @@ found:
* bytes
*/
/* RFC793,p72~p73 In states from ESTABLISHED to LASTACK:"If the
/* RFC793, p72~p73 1) In SYN-RCVD state, if the ACK is not
* acceptable, send a reset.
* 2)In states from ESTABLISHED to LASTACK:"If the
* ACK acks something not yet sent (SEG.ACK > SND.NXT) then send
* an ACK, drop the segment, and return."
*/
@@ -1067,6 +1069,10 @@ found:
tcp_send(dev, conn, TCP_ACK, tcpiplen);
return;
}
else if ((conn->tcpstateflags & TCP_STATE_MASK) == TCP_SYN_RCVD)
{
goto reset;
}
}
if (lasttxunacked == 0)