mirror of
https://github.com/apache/nuttx.git
synced 2025-05-07 22:01:55 +08:00
net/tcp/tcp_conn.c: optimize the port conflict detection rules
for tcp_listener(). fixed potential conflict between implicit binding and port conflict detection. Implicit binding automatically allocates an interface address during connection,but port conflict detection occurs before binding/connecting. This can cause issues when creating multiple TCP connections in succession. If the first connection uses a random port via implicit binding, subsequent connections might reuse the same port under current filtering rules, leading to connect() failures. Signed-off-by: nuttxs <zhaoqing.zhang@sony.com>
This commit is contained in:
parent
420868d308
commit
da74a5e368
@ -143,7 +143,8 @@ static FAR struct tcp_conn_s *
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
{
|
||||
if (net_ipv4addr_cmp(conn->u.ipv4.laddr, ipaddr->ipv4) ||
|
||||
net_ipv4addr_cmp(conn->u.ipv4.laddr, INADDR_ANY))
|
||||
net_ipv4addr_cmp(conn->u.ipv4.laddr, INADDR_ANY) ||
|
||||
net_ipv4addr_cmp(ipaddr->ipv4, INADDR_ANY))
|
||||
{
|
||||
/* The port number is in use, return the connection */
|
||||
|
||||
@ -158,7 +159,8 @@ static FAR struct tcp_conn_s *
|
||||
#endif /* CONFIG_NET_IPv4 */
|
||||
{
|
||||
if (net_ipv6addr_cmp(conn->u.ipv6.laddr, ipaddr->ipv6) ||
|
||||
net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_unspecaddr))
|
||||
net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_unspecaddr) ||
|
||||
net_ipv6addr_cmp(ipaddr->ipv6, g_ipv6_unspecaddr))
|
||||
{
|
||||
/* The port number is in use, return the connection */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user