From ec63da0753ef908ae804b56103be5b23a8facfdd Mon Sep 17 00:00:00 2001 From: xueyunfei Date: Mon, 14 Aug 2023 17:54:13 +0800 Subject: [PATCH] Backport some lwip bugs for 5.0 * Update submodule: git log --oneline 6bf7044c0368d587f70f7083e39e0a619b4d5788..542ba2997f6cc14fe9c3d781bf9b0d890cd70bb1 Detailed description of the changes: - fix router forwarding flag set (esp-lwip@542ba299) - optimize add TCP ooseq buf timeout configuration (esp-lwip@4a8286ab) --- components/lwip/Kconfig | 57 ++++++++++++++++++- components/lwip/lwip | 2 +- components/lwip/port/esp32/include/lwipopts.h | 34 +++++++++++ 3 files changed, 89 insertions(+), 4 deletions(-) diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index 3fa5456060..2d100df55b 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -518,7 +518,7 @@ menu "LWIP" Can be set lower to save RAM, the default value 1460(ipv4)/1440(ipv6) will give best throughput. IPv4 TCP_MSS Range: 576 <= TCP_MSS <= 1460 - IPv6 TCP_MSS Range: 1220<= TCP_mSS <= 1440 + IPv6 TCP_MSS Range: 1220<= TCP_MSS <= 1440 config LWIP_TCP_TMR_INTERVAL int "TCP timer interval(ms)" @@ -543,7 +543,7 @@ menu "LWIP" config LWIP_TCP_SND_BUF_DEFAULT int "Default send buffer size" - default 5744 # 4 * default MSS + default 5760 # 4 * default MSS range 2440 65535 if !LWIP_WND_SCALE range 2440 1024000 if LWIP_WND_SCALE help @@ -560,7 +560,7 @@ menu "LWIP" config LWIP_TCP_WND_DEFAULT int "Default receive window size" - default 5744 # 4 * default MSS + default 5760 # 4 * default MSS range 2440 65535 if !LWIP_WND_SCALE range 2440 1024000 if LWIP_WND_SCALE help @@ -602,6 +602,40 @@ menu "LWIP" Disable this option to save some RAM during TCP sessions, at the expense of increased retransmissions if segments arrive out of order. + config LWIP_TCP_OOSEQ_TIMEOUT + int "Timeout for each pbuf queued in TCP OOSEQ, in RTOs." + depends on LWIP_TCP_QUEUE_OOSEQ + range 1 30 + default 6 + help + The timeout value is TCP_OOSEQ_TIMEOUT * RTO. + + config LWIP_TCP_OOSEQ_MAX_PBUFS + int "The maximum number of pbufs queued on OOSEQ per pcb" + depends on LWIP_TCP_QUEUE_OOSEQ + range 0 12 + default 4 + help + If LWIP_TCP_OOSEQ_MAX_PBUFS = 0, TCP will not control the number of OOSEQ pbufs. + + In a poor network environment, many out-of-order tcp pbufs will be received. + These out-of-order pbufs will be cached in the TCP out-of-order queue which will + 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. + + 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) + + In the Ethernet scenario,recommended Ethernet OOSEQ PBUFS Range: + 0 <= TCP_OOSEQ_MAX_PBUFS <= CONFIG_ETH_DMA_RX_BUFFER_NUM/(MAX_TCP_NUMBER + 1) + + Within the recommended value range, the larger the value, the better the performance. + + MAX_TCP_NUMBER represent Maximum number of TCP connections in Wi-Fi(STA+SoftAP) and Ethernet scenario. + config LWIP_TCP_SACK_OUT bool "Support sending selective acknowledgements" default n @@ -783,6 +817,23 @@ menu "LWIP" help Config max number of entries in IPv6 neighbor cache + config LWIP_ND6 + bool "LWIP NDP6 Enable/Disable" + default y + depends on LWIP_IPV6 + help + This option is used to disable the Network Discovery Protocol (NDP) if it is not required. + Please use this option with caution, as the NDP is essential for IPv6 functionality within a local network. + + config LWIP_FORCE_ROUTER_FORWARDING + bool "LWIP Force Router Forwarding Enable/Disable" + default n + depends on LWIP_ND6 + help + This option is used to set the the router flag for the NA packets. + When enabled, the router flag in NA packet will always set to 1, + otherwise, never set router flag for NA packets. + config LWIP_PPP_NOTIFY_PHASE_SUPPORT bool "Enable Notify Phase Callback" depends on LWIP_PPP_SUPPORT diff --git a/components/lwip/lwip b/components/lwip/lwip index 6bf7044c03..542ba2997f 160000 --- a/components/lwip/lwip +++ b/components/lwip/lwip @@ -1 +1 @@ -Subproject commit 6bf7044c0368d587f70f7083e39e0a619b4d5788 +Subproject commit 542ba2997f6cc14fe9c3d781bf9b0d890cd70bb1 diff --git a/components/lwip/port/esp32/include/lwipopts.h b/components/lwip/port/esp32/include/lwipopts.h index e588949166..9298224adc 100644 --- a/components/lwip/port/esp32/include/lwipopts.h +++ b/components/lwip/port/esp32/include/lwipopts.h @@ -530,6 +530,21 @@ static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min) #define TCP_QUEUE_OOSEQ 0 #endif +/** + * TCP_OOSEQ_MAX_PBUFS: The maximum number of pbufs + * queued on ooseq per pcb + */ +#if TCP_QUEUE_OOSEQ +#define TCP_OOSEQ_MAX_PBUFS CONFIG_LWIP_TCP_OOSEQ_MAX_PBUFS +#endif + +/** + * TCP_OOSEQ_TIMEOUT: Timeout for each pbuf queued in TCP OOSEQ, in RTOs. + */ +#if TCP_QUEUE_OOSEQ +#define TCP_OOSEQ_TIMEOUT CONFIG_LWIP_TCP_OOSEQ_TIMEOUT +#endif + /** * LWIP_TCP_SACK_OUT==1: TCP will support sending selective acknowledgements (SACKs). */ @@ -1130,6 +1145,25 @@ static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min) #define LWIP_IPV6 0 #endif +/** + * LWIP_ND6==1: Enable ND6 protocol in IPv6 + */ +#ifdef CONFIG_LWIP_ND6 +#define LWIP_ND6 1 +#else +#define LWIP_ND6 0 +#endif + +/** + * LWIP_FORCE_ROUTER_FORWARDING==1: the router flag in NA packet will always set to 1, + * otherwise, never set router flag for NA packets. + */ +#ifdef CONFIG_LWIP_FORCE_ROUTER_FORWARDING +#define LWIP_FORCE_ROUTER_FORWARDING 1 +#else +#define LWIP_FORCE_ROUTER_FORWARDING 0 +#endif + /** * LWIP_IPV6_NUM_ADDRESSES: Number of IPv6 addresses per netif. */