From 1857a4a3c85cd2959381883daaf5d440ec11e88b Mon Sep 17 00:00:00 2001 From: zhanghongyu Date: Wed, 24 Aug 2022 15:06:59 +0800 Subject: [PATCH] udp: Ipv4/6 can be bound to the same port Signed-off-by: zhanghongyu --- net/udp/udp_conn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/udp/udp_conn.c b/net/udp/udp_conn.c index 51c5bc86ee..0484b6abec 100644 --- a/net/udp/udp_conn.c +++ b/net/udp/udp_conn.c @@ -124,7 +124,7 @@ static FAR struct udp_conn_s *udp_find_conn(uint8_t domain, if (domain == PF_INET) #endif { - if (conn->lport == portno && + if (conn->domain == PF_INET && conn->lport == portno && (net_ipv4addr_cmp(conn->u.ipv4.laddr, ipaddr->ipv4.laddr) || net_ipv4addr_cmp(conn->u.ipv4.laddr, INADDR_ANY))) { @@ -138,7 +138,7 @@ static FAR struct udp_conn_s *udp_find_conn(uint8_t domain, else #endif { - if (conn->lport == portno && + if (conn->domain == PF_INET6 && conn->lport == portno && (net_ipv6addr_cmp(conn->u.ipv6.laddr, ipaddr->ipv6.laddr) || net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_unspecaddr))) {