You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/06/11 03:47:19 UTC
[incubator-nuttx] 02/03: tcp: Use the tcp seq macros in some
obvious places
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit eb00e00e485cd80451514ff01d8799ae279a9765
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Thu Jun 3 16:42:02 2021 +0900
tcp: Use the tcp seq macros in some obvious places
---
net/tcp/tcp_input.c | 4 ++--
net/tcp/tcp_send_buffered.c | 13 ++++++-------
net/tcp/tcp_send_unbuffered.c | 3 ++-
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/net/tcp/tcp_input.c b/net/tcp/tcp_input.c
index c7055a3..d1b4b74 100644
--- a/net/tcp/tcp_input.c
+++ b/net/tcp/tcp_input.c
@@ -429,7 +429,7 @@ found:
ackseq = tcp_getsequence(tcp->seqno);
rcvseq = tcp_getsequence(conn->rcvseq);
- if (ackseq < rcvseq)
+ if (TCP_SEQ_LT(ackseq, rcvseq))
{
/* Send a "normal" acknowledgment of the KeepAlive probe */
@@ -492,7 +492,7 @@ found:
* new sequence number.
*/
- if (ackseq <= unackseq)
+ if (TCP_SEQ_LTE(ackseq, unackseq))
{
/* Calculate the new number of outstanding, unacknowledged bytes */
diff --git a/net/tcp/tcp_send_buffered.c b/net/tcp/tcp_send_buffered.c
index 2adfe40..a8218d7 100644
--- a/net/tcp/tcp_send_buffered.c
+++ b/net/tcp/tcp_send_buffered.c
@@ -407,7 +407,7 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
* the write buffer has been ACKed.
*/
- if (ackno > TCP_WBSEQNO(wrb))
+ if (TCP_SEQ_GT(ackno, TCP_WBSEQNO(wrb)))
{
/* Get the sequence number at the end of the data */
@@ -419,7 +419,7 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
/* Has the entire buffer been ACKed? */
- if (ackno >= lastseq)
+ if (TCP_SEQ_GTE(ackno, lastseq))
{
ninfo("ACK: wrb=%p Freeing write buffer\n", wrb);
@@ -449,7 +449,7 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
* buffers in the chain.
*/
- trimlen = ackno - TCP_WBSEQNO(wrb);
+ trimlen = TCP_SEQ_SUB(ackno, TCP_WBSEQNO(wrb));
if (trimlen > TCP_WBSENT(wrb))
{
/* More data has been ACKed then we have sent? */
@@ -504,13 +504,13 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
*/
wrb = (FAR struct tcp_wrbuffer_s *)sq_peek(&conn->write_q);
- if (wrb && TCP_WBSENT(wrb) > 0 && ackno > TCP_WBSEQNO(wrb))
+ if (wrb && TCP_WBSENT(wrb) > 0 && TCP_SEQ_GT(ackno, TCP_WBSEQNO(wrb)))
{
uint32_t nacked;
/* Number of bytes that were ACKed */
- nacked = ackno - TCP_WBSEQNO(wrb);
+ nacked = TCP_SEQ_SUB(ackno, TCP_WBSEQNO(wrb));
if (nacked > TCP_WBSENT(wrb))
{
/* More data has been ACKed then we have sent? ASSERT? */
@@ -811,8 +811,7 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
predicted_seqno = tcp_getsequence(conn->sndseq) + sndlen;
- if ((predicted_seqno > conn->sndseq_max) ||
- (tcp_getsequence(conn->sndseq) > predicted_seqno)) /* overflow */
+ if (TCP_SEQ_GT(predicted_seqno, conn->sndseq_max))
{
conn->sndseq_max = predicted_seqno;
}
diff --git a/net/tcp/tcp_send_unbuffered.c b/net/tcp/tcp_send_unbuffered.c
index 31e735d..64e41a1 100644
--- a/net/tcp/tcp_send_unbuffered.c
+++ b/net/tcp/tcp_send_unbuffered.c
@@ -220,7 +220,8 @@ static uint16_t tcpsend_eventhandler(FAR struct net_driver_s *dev,
* of bytes to be acknowledged.
*/
- pstate->snd_acked = tcp_getsequence(tcp->ackno) - pstate->snd_isn;
+ pstate->snd_acked = TCP_SEQ_SUB(tcp_getsequence(tcp->ackno),
+ pstate->snd_isn);
ninfo("ACK: acked=%" PRId32 " sent=%zd buflen=%zd\n",
pstate->snd_acked, pstate->snd_sent, pstate->snd_buflen);