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:17 UTC

[incubator-nuttx] branch master updated (bf1d587 -> 7d82e7a)

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from bf1d587  Documentation: Update kconfig-frontends install instructions
     new 433a2b2  tcp: add macros to deal with sequence number wraparound
     new eb00e00  tcp: Use the tcp seq macros in some obvious places
     new 7d82e7a  tcp_input: fix a confusing variable name and a comment

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 net/tcp/tcp.h                 |  9 +++++++++
 net/tcp/tcp_input.c           | 12 ++++--------
 net/tcp/tcp_send_buffered.c   | 13 ++++++-------
 net/tcp/tcp_send_unbuffered.c |  3 ++-
 4 files changed, 21 insertions(+), 16 deletions(-)

[incubator-nuttx] 03/03: tcp_input: fix a confusing variable name and a comment

Posted by xi...@apache.org.
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 7d82e7a7c4e93f7592c8f8114943e24658eb7035
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Fri Jun 4 10:53:06 2021 +0900

    tcp_input: fix a confusing variable name and a comment
    
    It looks like a copy-and-paste mistake.
---
 net/tcp/tcp_input.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/net/tcp/tcp_input.c b/net/tcp/tcp_input.c
index d1b4b74..5823f24 100644
--- a/net/tcp/tcp_input.c
+++ b/net/tcp/tcp_input.c
@@ -419,17 +419,13 @@ found:
       (dev->d_len == 0 || dev->d_len == 1) &&
       conn->tx_unacked <= 0)
     {
-      uint32_t ackseq;
+      uint32_t seq;
       uint32_t rcvseq;
 
-      /* Get the sequence number of that has just been acknowledged by this
-       * incoming packet.
-       */
-
-      ackseq = tcp_getsequence(tcp->seqno);
+      seq = tcp_getsequence(tcp->seqno);
       rcvseq = tcp_getsequence(conn->rcvseq);
 
-      if (TCP_SEQ_LT(ackseq, rcvseq))
+      if (TCP_SEQ_LT(seq, rcvseq))
         {
           /* Send a "normal" acknowledgment of the KeepAlive probe */
 

[incubator-nuttx] 02/03: tcp: Use the tcp seq macros in some obvious places

Posted by xi...@apache.org.
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);
 

[incubator-nuttx] 01/03: tcp: add macros to deal with sequence number wraparound

Posted by xi...@apache.org.
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 433a2b27d9e375359f46f8dcbaaa1e4f9f73cb98
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Tue Jun 1 13:48:47 2021 +0900

    tcp: add macros to deal with sequence number wraparound
---
 net/tcp/tcp.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/net/tcp/tcp.h b/net/tcp/tcp.h
index fc43dd6..c83f832 100644
--- a/net/tcp/tcp.h
+++ b/net/tcp/tcp.h
@@ -86,6 +86,15 @@
 #  endif
 #endif
 
+/* 32-bit modular arithmetics for tcp sequence numbers */
+
+#define TCP_SEQ_LT(a, b)	((int32_t)((a) - (b)) < 0)
+#define TCP_SEQ_GT(a, b)	TCP_SEQ_LT(b, a)
+#define TCP_SEQ_LTE(a, b)	(!TCP_SEQ_GT(a, b))
+#define TCP_SEQ_GTE(a, b)	(!TCP_SEQ_LT(a, b))
+
+#define TCP_SEQ_SUB(a, b)	((uint32_t)((a) - (b)))
+
 /****************************************************************************
  * Public Type Definitions
  ****************************************************************************/