You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/11/11 18:58:02 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #7510: net/tcp: Avoid starting TCP sequence number from 0

xiaoxiang781216 commented on code in PR #7510:
URL: https://github.com/apache/incubator-nuttx/pull/7510#discussion_r1020486389


##########
net/tcp/tcp_send.c:
##########
@@ -329,6 +332,20 @@ static void tcp_sendcommon(FAR struct net_driver_s *dev,
     }
 #endif /* CONFIG_NET_IPv4 */
 
+  /* If this is the very first connection, seqno and sndseq will be 0!
+   * Rational:
+   * We need to make tcp->seqno random because some servers will not accept
+   * it starting from zero. The way to do it is making the sndseq random
+   * because it will be "memcpyied" to tcp->seqno.
+   */
+
+  seqno = tcp_getsequence(tcp->seqno);

Review Comment:
   why need change here? we can't update only tcp_initsequence instead



##########
net/tcp/tcp_seqno.c:
##########
@@ -142,6 +144,34 @@ uint32_t tcp_addsequence(FAR uint8_t *seqno, uint16_t len)
 
 void tcp_initsequence(FAR uint8_t *seqno)
 {
+  int ret;
+
+  /* Get a random TCP sequence number */
+
+  ret = getrandom(&g_tcpsequence, sizeof(uint32_t), 0);

Review Comment:
   let's check g_tcpsequence isn't zero before getrandom



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org