Skip to content

Commit d1c7e18

Browse files
SPRESENSEpkarashchenko
authored andcommitted
libc/netdb: Separate IPv4 and IPv6 cache size limit
Some domains have a lot of IPv6 addresses. Because of that, it is not possible to get the IPv4 address with getaddrinfo. This change separate IPv4 and IPv6 cache size limit to enable to get both IP addresses.
1 parent 63ed723 commit d1c7e18

File tree

9 files changed

+33
-13
lines changed

9 files changed

+33
-13
lines changed

boards/arm/tiva/lm3s6965-ek/configs/qemu-flat/defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ CONFIG_NET=y
4444
CONFIG_NETDB_DNSCLIENT=y
4545
CONFIG_NETDB_DNSCLIENT_NAMESIZE=64
4646
CONFIG_NETDB_DNSSERVER_NOADDR=y
47-
CONFIG_NETDB_MAX_IPADDR=2
4847
CONFIG_NETINIT_DHCPC=y
4948
CONFIG_NETINIT_NOMAC=y
5049
CONFIG_NETUTILS_NETCAT=y

boards/arm/tiva/lm3s6965-ek/configs/qemu-nxflat/defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ CONFIG_NET=y
2525
CONFIG_NETDB_DNSCLIENT=y
2626
CONFIG_NETDB_DNSCLIENT_NAMESIZE=64
2727
CONFIG_NETDB_DNSSERVER_NOADDR=y
28-
CONFIG_NETDB_MAX_IPADDR=2
2928
CONFIG_NETUTILS_NETCAT=y
3029
CONFIG_NETUTILS_TELNETD=y
3130
CONFIG_NETUTILS_TFTPC=y

boards/arm/tiva/lm3s6965-ek/configs/qemu-protected/defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ CONFIG_NET=y
4747
CONFIG_NETDB_DNSCLIENT=y
4848
CONFIG_NETDB_DNSCLIENT_NAMESIZE=64
4949
CONFIG_NETDB_DNSSERVER_NOADDR=y
50-
CONFIG_NETDB_MAX_IPADDR=2
5150
CONFIG_NETINIT_DHCPC=y
5251
CONFIG_NETINIT_NOMAC=y
5352
CONFIG_NETUTILS_NETCAT=y

boards/sim/sim/sim/configs/matter/defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ CONFIG_MATTER=y
5858
CONFIG_NET=y
5959
CONFIG_NETDB_DNSCLIENT=y
6060
CONFIG_NETDB_DNSSERVER_IPv4ADDR=0x771d1d1d
61-
CONFIG_NETDB_MAX_IPADDR=1
6261
CONFIG_NETDEV_HPWORK_THREAD=y
6362
CONFIG_NETINIT_IPADDR=0x0a000102
6463
CONFIG_NETLINK_ROUTE=y

boards/sim/sim/sim/configs/usbdev/defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ CONFIG_LIBUV=y
4545
CONFIG_NETDB_DNSCLIENT=y
4646
CONFIG_NETDB_DNSCLIENT_MAXRESPONSE=1024
4747
CONFIG_NETDB_DNSSERVER_IPv4ADDR=0xDF050505
48-
CONFIG_NETDB_MAX_IPADDR=1
4948
CONFIG_NETDEV_PHY_IOCTL=y
5049
CONFIG_NETDOWN_NOTIFIER=y
5150
CONFIG_NETINIT_DRIPADDR=0x0a000101

libs/libc/netdb/Kconfig

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,30 @@ config NETDB_BUFSIZE
3333
depends on LIBC_NETDB
3434
default 256
3535

36-
config NETDB_MAX_IPADDR
37-
int "Max number of IP addresses per host"
36+
if NET_IPv4
37+
38+
config NETDB_MAX_IPv4ADDR
39+
int "Max number of IPv4 addresses per host"
3840
depends on LIBC_NETDB
39-
default 2 if NET_IPv4 && NET_IPv6
4041
default 1
4142
---help---
42-
This setting determines the maximum number of IP addresses
43+
This setting determines the maximum number of IPv4 addresses
4344
stored to the name resolution cache for a given host.
4445

46+
endif # NET_IPv4
47+
48+
if NET_IPv6
49+
50+
config NETDB_MAX_IPv6ADDR
51+
int "Max number of IPv6 addresses per host"
52+
depends on LIBC_NETDB
53+
default 1
54+
---help---
55+
This setting determines the maximum number of IPv6 addresses
56+
stored to the name resolution cache for a given host.
57+
58+
endif # NET_IPv6
59+
4560
menuconfig NETDB_HOSTFILE
4661
bool "Network host file support"
4762
default n

libs/libc/netdb/lib_dnscache.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <debug.h>
3333

3434
#include "netdb/lib_dns.h"
35+
#include "netdb/lib_netdb.h"
3536

3637
#if CONFIG_NETDB_DNSCLIENT_ENTRIES > 0
3738

libs/libc/netdb/lib_dnsquery.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,8 @@ static int dns_query_callback(FAR void *arg, FAR struct sockaddr *addr,
669669
/* Obtain the IPv6 response */
670670

671671
ret = dns_recv_response(sd, &query->addr[next],
672-
*query->naddr - next, &qdata->qinfo,
672+
CONFIG_NETDB_MAX_IPv6ADDR,
673+
&qdata->qinfo,
673674
&query->ttl, qdata->buffer);
674675
if (ret >= 0)
675676
{
@@ -718,7 +719,8 @@ static int dns_query_callback(FAR void *arg, FAR struct sockaddr *addr,
718719
}
719720

720721
ret = dns_recv_response(sd, &query->addr[next],
721-
*query->naddr - next, &qdata->qinfo,
722+
CONFIG_NETDB_MAX_IPv4ADDR,
723+
&qdata->qinfo,
722724
&query->ttl, qdata->buffer);
723725
if (ret >= 0)
724726
{

libs/libc/netdb/lib_netdb.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,17 @@
5656
# define CONFIG_NETDB_BUFSIZE 128
5757
#endif
5858

59-
#ifndef CONFIG_NETDB_MAX_IPADDR
60-
# define CONFIG_NETDB_MAX_IPADDR 1
59+
#ifndef CONFIG_NETDB_MAX_IPv4ADDR
60+
# define CONFIG_NETDB_MAX_IPv4ADDR 1
6161
#endif
6262

63+
#ifndef CONFIG_NETDB_MAX_IPv6ADDR
64+
# define CONFIG_NETDB_MAX_IPv6ADDR 1
65+
#endif
66+
67+
#define CONFIG_NETDB_MAX_IPADDR (CONFIG_NETDB_MAX_IPv4ADDR + \
68+
CONFIG_NETDB_MAX_IPv6ADDR)
69+
6370
/****************************************************************************
6471
* Public Types
6572
****************************************************************************/

0 commit comments

Comments
 (0)