You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "xiaoxiang781216 (via GitHub)" <gi...@apache.org> on 2023/01/27 13:07:41 UTC

[GitHub] [nuttx] xiaoxiang781216 opened a new pull request, #8297: tcp/udp_connect: If the remote addr is ANY, change it to LOOPBACK

xiaoxiang781216 opened a new pull request, #8297:
URL: https://github.com/apache/nuttx/pull/8297

   ## Summary
   
   Behavior alignment to Linux
   
   ## Impact
   
   connect
   
   ## Testing
   
   


-- 
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


[GitHub] [nuttx] acassis commented on a diff in pull request #8297: tcp/udp_connect: If the remote addr is ANY, change it to LOOPBACK

Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on code in PR #8297:
URL: https://github.com/apache/nuttx/pull/8297#discussion_r1089307963


##########
net/tcp/tcp_conn.c:
##########
@@ -1242,7 +1242,14 @@ int tcp_connect(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr)
 
       /* The sockaddr address is 32-bits in network order. */
 
-      net_ipv4addr_copy(conn->u.ipv4.raddr, inaddr->sin_addr.s_addr);
+      if (inaddr->sin_addr.s_addr == INADDR_ANY)
+        {
+          net_ipv4addr_copy(conn->u.ipv4.raddr, HTONL(INADDR_LOOPBACK));
+        }
+      else
+        {
+          net_ipv4addr_copy(conn->u.ipv4.raddr, inaddr->sin_addr.s_addr);
+        }

Review Comment:
   So, 0.0.0.0 means 127.0.0.1? Is that the idea? Maybe should be a good idea include a comment.



-- 
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


[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #8297: tcp/udp_connect: If the remote addr is ANY, change it to LOOPBACK

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #8297:
URL: https://github.com/apache/nuttx/pull/8297#discussion_r1089350957


##########
net/tcp/tcp_conn.c:
##########
@@ -1242,7 +1242,14 @@ int tcp_connect(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr)
 
       /* The sockaddr address is 32-bits in network order. */
 
-      net_ipv4addr_copy(conn->u.ipv4.raddr, inaddr->sin_addr.s_addr);
+      if (inaddr->sin_addr.s_addr == INADDR_ANY)
+        {
+          net_ipv4addr_copy(conn->u.ipv4.raddr, HTONL(INADDR_LOOPBACK));
+        }
+      else
+        {
+          net_ipv4addr_copy(conn->u.ipv4.raddr, inaddr->sin_addr.s_addr);
+        }

Review Comment:
   Done.



-- 
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


[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #8297: tcp/udp_connect: If the remote addr is ANY, change it to LOOPBACK

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #8297:
URL: https://github.com/apache/nuttx/pull/8297#discussion_r1089327913


##########
net/tcp/tcp_conn.c:
##########
@@ -1242,7 +1242,14 @@ int tcp_connect(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr)
 
       /* The sockaddr address is 32-bits in network order. */
 
-      net_ipv4addr_copy(conn->u.ipv4.raddr, inaddr->sin_addr.s_addr);
+      if (inaddr->sin_addr.s_addr == INADDR_ANY)
+        {
+          net_ipv4addr_copy(conn->u.ipv4.raddr, HTONL(INADDR_LOOPBACK));
+        }
+      else
+        {
+          net_ipv4addr_copy(conn->u.ipv4.raddr, inaddr->sin_addr.s_addr);
+        }

Review Comment:
   Here has some dissussion:
   https://unix.stackexchange.com/questions/419880/connecting-to-ip-0-0-0-0-succeeds-how-why
   



-- 
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


[GitHub] [nuttx] anchao merged pull request #8297: tcp/udp_connect: If the remote addr is ANY, change it to LOOPBACK

Posted by "anchao (via GitHub)" <gi...@apache.org>.
anchao merged PR #8297:
URL: https://github.com/apache/nuttx/pull/8297


-- 
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