This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit ddd6594d59bd8c4a42942824ec7613ffa5417712 Author: Marco Casaroli <[email protected]> AuthorDate: Sat Nov 21 17:20:01 2026 +0100 net/tcp: Connect an IPv6 socket to ::1 for the address ::. tcp_connect() maps the remote address :: to ::1, as 0.0.0.0 goes to 127.0.0.1. But it compares the start of the sockaddr (family, port, flow information) with ::, not sin6_addr, so the test is never true. connect() to [::]:port then sends the SYN to :: on a network device. Compare sin6_addr, as udp_connect() does. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- net/tcp/tcp_conn.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/net/tcp/tcp_conn.c b/net/tcp/tcp_conn.c index 5211e1df21a..98d3c1c6641 100644 --- a/net/tcp/tcp_conn.c +++ b/net/tcp/tcp_conn.c @@ -1562,12 +1562,9 @@ int tcp_connect(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr) * Note: ::0 is mapped to ::1 by convention. */ - if (net_ipv6addr_cmp(addr, g_ipv6_unspecaddr)) + if (net_ipv6addr_cmp(inaddr->sin6_addr.s6_addr16, g_ipv6_unspecaddr)) { - struct in6_addr loopback_sin6_addr = IN6ADDR_LOOPBACK_INIT; - - net_ipv6addr_copy(conn->u.ipv6.raddr, - loopback_sin6_addr.s6_addr16); + net_ipv6addr_copy(conn->u.ipv6.raddr, g_ipv6_loopback); } else {
