mirror of
https://github.com/apache/nuttx.git
synced 2026-05-20 12:33:27 +08:00
net/tcp: support OTW SEQ number check in SYN-RCVD state
According rfc793 p69, In SYN-RCVD state, if the incoming segment is not acceptable, an acknowledgment should be sent in reply (unless the RST bit is set): <SEQ=SND.NXT><ACK=RCV.NXT><CTL=ACK> Signed-off-by: wenquan1 <wenquan1@xiaomi.com>
This commit is contained in:
@@ -212,10 +212,7 @@ struct tcp_conn_s
|
||||
uint8_t rcvseq[4]; /* The sequence number that we expect to
|
||||
* receive next */
|
||||
uint8_t sndseq[4]; /* The sequence number that was last sent by us */
|
||||
#if !defined(CONFIG_NET_TCP_WRITE_BUFFERS) || \
|
||||
defined(CONFIG_NET_SENDFILE)
|
||||
uint32_t rexmit_seq; /* The sequence number to be retrasmitted */
|
||||
#endif
|
||||
uint8_t crefs; /* Reference counts on this instance */
|
||||
#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
|
||||
uint8_t domain; /* IP domain: PF_INET or PF_INET6 */
|
||||
|
||||
@@ -1144,9 +1144,7 @@ FAR struct tcp_conn_s *tcp_alloc_accept(FAR struct net_driver_s *dev,
|
||||
conn->tcpstateflags = TCP_SYN_RCVD;
|
||||
|
||||
tcp_initsequence(conn);
|
||||
#if !defined(CONFIG_NET_TCP_WRITE_BUFFERS)
|
||||
conn->rexmit_seq = tcp_getsequence(conn->sndseq);
|
||||
#endif
|
||||
|
||||
conn->tx_unacked = 1;
|
||||
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
|
||||
@@ -1470,9 +1468,7 @@ int tcp_connect(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr)
|
||||
|
||||
/* Save initial sndseq to rexmit_seq, otherwise it will be zero */
|
||||
|
||||
#if !defined(CONFIG_NET_TCP_WRITE_BUFFERS)
|
||||
conn->rexmit_seq = tcp_getsequence(conn->sndseq);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_TCP_CC_NEWRENO
|
||||
/* Initialize the variables of congestion control. */
|
||||
|
||||
@@ -1327,11 +1327,7 @@ skip_rtt:
|
||||
|
||||
if ((tcp->flags & TCP_CTL) == TCP_SYN)
|
||||
{
|
||||
#if !defined(CONFIG_NET_TCP_WRITE_BUFFERS)
|
||||
tcp_setsequence(conn->sndseq, conn->rexmit_seq);
|
||||
#else
|
||||
/* REVISIT for the buffered mode */
|
||||
#endif
|
||||
tcp_synack(dev, conn, TCP_ACK | TCP_SYN);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -238,7 +238,6 @@ static void tcp_sendcommon(FAR struct net_driver_s *dev,
|
||||
g_netstats.tcp.sent++;
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_NET_TCP_WRITE_BUFFERS)
|
||||
if ((tcp->flags & (TCP_SYN | TCP_FIN)) != 0)
|
||||
{
|
||||
/* Remember sndseq that will be used in case of a possible
|
||||
@@ -253,9 +252,6 @@ static void tcp_sendcommon(FAR struct net_driver_s *dev,
|
||||
|
||||
net_incr32(conn->sndseq, 1);
|
||||
}
|
||||
#else
|
||||
/* REVISIT for the buffered mode */
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -602,11 +602,7 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn)
|
||||
* SYNACK.
|
||||
*/
|
||||
|
||||
#if !defined(CONFIG_NET_TCP_WRITE_BUFFERS)
|
||||
tcp_setsequence(conn->sndseq, conn->rexmit_seq);
|
||||
#else
|
||||
/* REVISIT for the buffered mode */
|
||||
#endif
|
||||
tcp_synack(dev, conn, TCP_ACK | TCP_SYN);
|
||||
goto done;
|
||||
|
||||
@@ -614,11 +610,7 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn)
|
||||
|
||||
/* In the SYN_SENT state, we retransmit out SYN. */
|
||||
|
||||
#if !defined(CONFIG_NET_TCP_WRITE_BUFFERS)
|
||||
tcp_setsequence(conn->sndseq, conn->rexmit_seq);
|
||||
#else
|
||||
/* REVISIT for the buffered mode */
|
||||
#endif
|
||||
tcp_synack(dev, conn, TCP_SYN);
|
||||
goto done;
|
||||
|
||||
@@ -659,11 +651,7 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn)
|
||||
|
||||
/* In all these states we should retransmit a FINACK. */
|
||||
|
||||
#if !defined(CONFIG_NET_TCP_WRITE_BUFFERS)
|
||||
tcp_setsequence(conn->sndseq, conn->rexmit_seq);
|
||||
#else
|
||||
/* REVISIT for the buffered mode */
|
||||
#endif
|
||||
tcp_send(dev, conn, TCP_FIN | TCP_ACK, hdrlen);
|
||||
goto done;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user