dns: fix dns failed when ipv4/6 dual stack enable
The ipv6 address filled the cache, and the ipv4 address did not have a place to store it, causing the resolution to fail. so if IPV6 has already filled the buffer, rewrite ipv4 DNS results from half of the buffer. Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
parent
4f25c287d2
commit
a41f68da84
@ -712,6 +712,11 @@ static int dns_query_callback(FAR void *arg, FAR struct sockaddr *addr,
|
||||
{
|
||||
/* Obtain the IPv4 response */
|
||||
|
||||
if (next >= *query->naddr)
|
||||
{
|
||||
next = *query->naddr / 2;
|
||||
}
|
||||
|
||||
ret = dns_recv_response(sd, &query->addr[next],
|
||||
*query->naddr - next, &qdata->qinfo,
|
||||
&query->ttl, qdata->buffer);
|
||||
|
@ -502,16 +502,16 @@ static int lib_dns_lookup(FAR const char *name, FAR struct hostent_s *host,
|
||||
|
||||
naddr = (buflen - (namelen + 1)) / sizeof(union dns_addr_u);
|
||||
DEBUGASSERT(naddr >= 1);
|
||||
|
||||
/* We can read more than maximum, limit here. */
|
||||
|
||||
naddr = MIN(naddr, CONFIG_NETDB_MAX_IPADDR);
|
||||
ret = lib_dns_query(name, (FAR union dns_addr_u *)ptr, &naddr);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* We can read more than maximum, limit here. */
|
||||
|
||||
naddr = MIN(naddr, CONFIG_NETDB_MAX_IPADDR);
|
||||
|
||||
for (i = 0; i < naddr; i++)
|
||||
{
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
|
Loading…
x
Reference in New Issue
Block a user