From 0f08a5b1231800a2684b2639b9ba6cb664be0e47 Mon Sep 17 00:00:00 2001 From: Abhik Roy Date: Wed, 17 Apr 2024 23:56:11 +1000 Subject: [PATCH] feat(lwip): Added multiple dns ip support (v5.3) LWIP submodule update on v5.3: git log --oneline f7922143..f1746813 - feat(lwip): Added multiple dns ip support (espressif/esp-lwip@f1746813) - api_msg: Fix crash to fail-safe error if cannot get semaphore (espressif/esp-lwip@a1bd9e44) --- components/lwip/Kconfig | 14 ++++++++++---- components/lwip/lwip | 2 +- components/lwip/port/include/lwipopts.h | 6 +++++- docs/en/api-guides/lwip.rst | 4 ++++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index 1904ba5b70..5d80561043 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -669,7 +669,7 @@ menu "LWIP" LWIP_TCP_RECCVMBOX_SIZE packets for each TCP socket, so the maximum possible cached TCP packets for all TCP sockets is LWIP_TCP_RECCVMBOX_SIZE multiples the maximum TCP socket number. In other words, the bigger LWIP_TCP_RECVMBOX_SIZE means more memory. - On the other hand, if the receiv mail box is too small, the mail box may be full. If the + On the other hand, if the receive mail box is too small, the mail box may be full. If the mail box is full, the LWIP drops the packets. So generally we need to make sure the TCP receive mail box is big enough to avoid packet drop between LWIP core and application. @@ -813,7 +813,7 @@ menu "LWIP" UDP_RECCVMBOX_SIZE packets for each UDP socket, so the maximum possible cached UDP packets for all UDP sockets is UDP_RECCVMBOX_SIZE multiples the maximum UDP socket number. In other words, the bigger UDP_RECVMBOX_SIZE means more memory. - On the other hand, if the receiv mail box is too small, the mail box may be full. If the + On the other hand, if the receive mail box is too small, the mail box may be full. If the mail box is full, the LWIP drops the packets. So generally we need to make sure the UDP receive mail box is big enough to avoid packet drop between LWIP core and application. @@ -1060,12 +1060,12 @@ menu "LWIP" SNTP callback for such replies should be set accordingly (see sntp_servermode_dhcp() func.) config LWIP_DHCP_MAX_NTP_SERVERS - int "Maximum number of NTP servers aquired via DHCP" + int "Maximum number of NTP servers acquired via DHCP" default 1 range 1 16 depends on LWIP_DHCP_GET_NTP_SRV help - Set maximum number of NTP servers aquired via DHCP-offer. + Set maximum number of NTP servers acquired via DHCP-offer. Should be less or equal to "Maximum number of NTP servers", any extra servers would be just ignored. config LWIP_SNTP_UPDATE_DELAY @@ -1101,6 +1101,12 @@ menu "LWIP" menu "DNS" + config LWIP_DNS_MAX_HOST_IP + int "Maximum number of IP addresses per host" + default 1 + help + Maximum number of IP addresses that can be returned by DNS queries for a single host. + config LWIP_DNS_MAX_SERVERS int "Maximum number of DNS servers" default 3 diff --git a/components/lwip/lwip b/components/lwip/lwip index f79221431f..f174681317 160000 --- a/components/lwip/lwip +++ b/components/lwip/lwip @@ -1 +1 @@ -Subproject commit f79221431fa9042b3572d271d687de66da7560c4 +Subproject commit f174681317a00d209e374c66d9691ef79b4195de diff --git a/components/lwip/port/include/lwipopts.h b/components/lwip/port/include/lwipopts.h index 51e3c3c3d0..e95d647029 100644 --- a/components/lwip/port/include/lwipopts.h +++ b/components/lwip/port/include/lwipopts.h @@ -470,6 +470,10 @@ static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min) */ #define LWIP_DNS 1 +/** The maximum number of IP addresses per host + */ +#define DNS_MAX_HOST_IP CONFIG_LWIP_DNS_MAX_HOST_IP + /** The maximum of DNS servers */ #define DNS_MAX_SERVERS CONFIG_LWIP_DNS_MAX_SERVERS @@ -1103,7 +1107,7 @@ static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min) /** * PPP_MAXIDLEFLAG: Max Xmit idle time (in ms) before resend flag char. * TODO: If PPP_MAXIDLEFLAG > 0 and next package is send during PPP_MAXIDLEFLAG time, - * then 0x7E is not added at the begining of PPP package but 0x7E termination + * then 0x7E is not added at the beginning of PPP package but 0x7E termination * is always at the end. This behaviour brokes PPP dial with GSM (PPPoS). * The PPP package should always start and end with 0x7E. */ diff --git a/docs/en/api-guides/lwip.rst b/docs/en/api-guides/lwip.rst index 56e9c54f67..462ded4e9e 100644 --- a/docs/en/api-guides/lwip.rst +++ b/docs/en/api-guides/lwip.rst @@ -459,6 +459,10 @@ Limitations ESP-IDF additions to lwIP still suffer from the global DNS limitation, described in :ref:`lwip-dns-limitation`. To address this limitation from application code, the ``FALLBACK_DNS_SERVER_ADDRESS()`` macro can be utilized to define a global DNS fallback server accessible from all interfaces. Alternatively, you have the option to maintain per-interface DNS servers and reconfigure them whenever the default interface changes. +The number of IP addresses returned by network database APIs such as ``getaddrinfo()`` and ``gethostbyname()`` is restricted by the macro ``DNS_MAX_HOST_IP``. By default, the value of this macro is set to 1. + +In the implementation of ``getaddrinfo()``, the canonical name is not available. Therefore, the ``ai_canonname`` field of the first returned ``addrinfo`` structure will always refer to the ``nodename`` argument or a string with the same contents. + Calling ``send()`` or ``sendto()`` repeatedly on a UDP socket may eventually fail with ``errno`` equal to ``ENOMEM``. This failure occurs due to the limitations of buffer sizes in the lower-layer network interface drivers. If all driver transmit buffers are full, the UDP transmission will fail. For applications that transmit a high volume of UDP datagrams and aim to avoid any dropped datagrams by the sender, it is advisable to implement error code checking and employ a retransmission mechanism with a short delay. .. only:: esp32