From 75b4fb5a663b92a29cf7bf19bd5884a7731db22c Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Thu, 25 Jan 2024 11:05:53 +0800 Subject: [PATCH] feat(lwip): add fall back dns config in menuconfig Closes https://github.com/espressif/esp-idf/issues/12530 --- components/lwip/Kconfig | 31 +++++++++++++++++-- components/lwip/lwip | 2 +- components/lwip/port/esp32/include/lwipopts.h | 15 +++++++-- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index 779b3c8ffc..13a78a2f43 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -656,8 +656,8 @@ menu "LWIP" cause Wi-Fi/Ethernet fail to release RX buffer in time. It is possible that all RX buffers for MAC layer are used by OOSEQ. - Control the number of out-of-order pbufs to ensure that the MAC layer has enough RX buffer - to receive packets. + Control the number of out-of-order pbufs to ensure that the MAC layer has + enough RX buffer to receive packets. In the Wi-Fi scenario, recommended OOSEQ PBUFS Range: 0 <= TCP_OOSEQ_MAX_PBUFS <= CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM/(MAX_TCP_NUMBER + 1) @@ -1010,6 +1010,33 @@ menu "LWIP" endmenu # SNTP + menu "DNS" + + config LWIP_DNS_MAX_SERVERS + int "Maximum number of DNS servers" + default 3 + range 1 4 + help + Set maximum number of DNS servers. + If fallback DNS servers are supported, + the number of DNS servers needs to be greater than or equal to 3. + + config LWIP_FALLBACK_DNS_SERVER_SUPPORT + bool "Enable DNS fallback server support" + default n + depends on LWIP_DNS_MAX_SERVERS >= 3 + help + Enable this feature to support DNS fallback server. + + config LWIP_FALLBACK_DNS_SERVER_ADDRESS + string "DNS fallback server address" + default "114.114.114.114" + depends on LWIP_FALLBACK_DNS_SERVER_SUPPORT + help + This option allows you to config dns fallback server address. + + endmenu # DNS + config LWIP_ESP_LWIP_ASSERT bool "Enable LWIP ASSERT checks" default y diff --git a/components/lwip/lwip b/components/lwip/lwip index 1de11efadd..a45be9e438 160000 --- a/components/lwip/lwip +++ b/components/lwip/lwip @@ -1 +1 @@ -Subproject commit 1de11efadd0083469f26c8782be3d55073829767 +Subproject commit a45be9e438f6cf9c54ec150581819c3b95d5af6b diff --git a/components/lwip/port/esp32/include/lwipopts.h b/components/lwip/port/esp32/include/lwipopts.h index ece4fe337d..ef838b65a7 100644 --- a/components/lwip/port/esp32/include/lwipopts.h +++ b/components/lwip/port/esp32/include/lwipopts.h @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: BSD-3-Clause * - * SPDX-FileContributor: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2015-2024 Espressif Systems (Shanghai) CO LTD */ #ifndef __LWIPOPTS_H__ @@ -375,8 +375,16 @@ static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min) */ #define LWIP_DNS 1 -#define DNS_MAX_SERVERS 3 -#define DNS_FALLBACK_SERVER_INDEX (DNS_MAX_SERVERS - 1) +#define DNS_MAX_SERVERS CONFIG_LWIP_DNS_MAX_SERVERS +#define DNS_FALLBACK_SERVER_INDEX (DNS_MAX_SERVERS - 1) + +#ifdef CONFIG_LWIP_FALLBACK_DNS_SERVER_SUPPORT +#define FALLBACK_DNS_SERVER_ADDRESS(address) \ + do { ip_addr_t *server_dns = address; \ + char server_ip[] = CONFIG_LWIP_FALLBACK_DNS_SERVER_ADDRESS; \ + ipaddr_aton(server_ip, server_dns); \ + } while (0) +#endif /* CONFIG_LWIP_FALLBACK_DNS_SERVER_SUPPORT */ /* --------------------------------- @@ -1123,6 +1131,7 @@ static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min) #define ESP_LWIP_LOCK 1 #define ESP_THREAD_PROTECTION 1 #define ESP_IP_FORWARD 1 +#define ESP_LWIP_FALLBACK_DNS_PREFER_IPV4 0 #ifdef CONFIG_LWIP_IPV6_AUTOCONFIG #define ESP_IPV6_AUTOCONFIG CONFIG_LWIP_IPV6_AUTOCONFIG