Skip to content

Commit 4c85805

Browse files
liqinhuixmxiaoxiang781216
authored andcommitted
net/tcp: Reset the conn when receiving a ACK in the SYN_SENT state.
According to RFC793, Section 3.4, Page 33. In the SYN_SENT state, if receive a ACK without the SYN, we should reset the connection and retransmit the SYN. Signed-off-by: liqinhui <[email protected]>
1 parent 2431482 commit 4c85805

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

net/tcp/tcp_input.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,27 @@ static void tcp_input(FAR struct net_driver_s *dev, uint8_t domain,
11741174
seq = tcp_getsequence(tcp->seqno);
11751175
rcvseq = tcp_getsequence(conn->rcvseq);
11761176

1177+
/* According to RFC793, Section 3.4, Page 33.
1178+
* In the SYN_SENT state, if receive a ACK without SYN,
1179+
* we should reset the connection and retransmit the SYN.
1180+
*/
1181+
1182+
if (((conn->tcpstateflags & TCP_STATE_MASK) == TCP_SYN_SENT) &&
1183+
((tcp->flags & TCP_SYN) == 0 && (tcp->flags & TCP_ACK) != 0))
1184+
{
1185+
/* Send the RST to close the half-open connection. */
1186+
1187+
tcp_reset(dev, conn);
1188+
1189+
/* Retransmit the SYN as soon as possible in order to establish
1190+
* the tcp connection.
1191+
*/
1192+
1193+
tcp_update_retrantimer(conn, 1);
1194+
1195+
return;
1196+
}
1197+
11771198
if (seq != rcvseq)
11781199
{
11791200
/* Trim the head of the segment */

0 commit comments

Comments
 (0)