patacongo commented on a change in pull request #1054:
URL: https://github.com/apache/incubator-nuttx/pull/1054#discussion_r425799753
##########
File path: net/tcp/tcp_conn.c
##########
@@ -263,6 +260,20 @@ static FAR struct tcp_conn_s *
static int tcp_selectport(uint8_t domain, FAR const union ip_addr_u *ipaddr,
uint16_t portno)
{
+ static uint16_t g_last_tcp_port;
+
+ /* Generate port base dynamically */
+
+ if (g_last_tcp_port == 0)
+ {
+ g_last_tcp_port = clock_systime_ticks() % 32000;
+
+ if (g_last_tcp_port < 4096)
+ {
+ g_last_tcp_port += 4096;
+ }
+ }
+
Review comment:
>
>
> You still verify that this port number is unique, right? With this change
there is the real possibility that you could generate duplicate port numbers.
Logic must be included to avoid that.
Has does that avoid duplicate port numbers?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]