From bfaaa86775f0308fabc574161843cb8d795cd352 Mon Sep 17 00:00:00 2001 From: xueyunfei Date: Wed, 31 Aug 2022 17:28:17 +0800 Subject: [PATCH] Lwip:add TCP Fin2 timeout configuration --- components/lwip/Kconfig | 8 +++++++- components/lwip/lwip | 2 +- components/lwip/port/esp32/include/lwipopts.h | 5 +++++ docs/en/api-guides/lwip.rst | 1 + 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index b0dfd2d979..d26af23c4b 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -481,7 +481,13 @@ menu "LWIP" int "Maximum segment lifetime (MSL)" default 60000 help - Set maximum segment lifetime in in milliseconds. + Set maximum segment lifetime in milliseconds. + + config LWIP_TCP_FIN_WAIT_TIMEOUT + int "Maximum FIN segment lifetime" + default 20000 + help + Set maximum segment lifetime in milliseconds. config LWIP_TCP_SND_BUF_DEFAULT int "Default send buffer size" diff --git a/components/lwip/lwip b/components/lwip/lwip index 316cfc17ce..9bad641bc7 160000 --- a/components/lwip/lwip +++ b/components/lwip/lwip @@ -1 +1 @@ -Subproject commit 316cfc17ce24f2d5d65c9f28251ec43a59a74cb1 +Subproject commit 9bad641bc7378d2eb1ba84834baafaf119135206 diff --git a/components/lwip/port/esp32/include/lwipopts.h b/components/lwip/port/esp32/include/lwipopts.h index b9561a1923..32b66b5eda 100644 --- a/components/lwip/port/esp32/include/lwipopts.h +++ b/components/lwip/port/esp32/include/lwipopts.h @@ -578,6 +578,11 @@ static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min) */ #define TCP_MSL CONFIG_LWIP_TCP_MSL +/** + * TCP_FIN_WAIT_TIMEOUT: The maximum FIN segment lifetime in milliseconds + */ +#define TCP_FIN_WAIT_TIMEOUT CONFIG_LWIP_TCP_FIN_WAIT_TIMEOUT + /** * LWIP_WND_SCALE and TCP_RCV_SCALE: * Set LWIP_WND_SCALE to 1 to enable window scaling. diff --git a/docs/en/api-guides/lwip.rst b/docs/en/api-guides/lwip.rst index caf900f188..139ddc250d 100644 --- a/docs/en/api-guides/lwip.rst +++ b/docs/en/api-guides/lwip.rst @@ -448,6 +448,7 @@ Most lwIP RAM usage is on-demand, as RAM is allocated from the heap as needed. T - Reducing :ref:`CONFIG_LWIP_MAX_SOCKETS` reduces the maximum number of sockets in the system. This will also cause TCP sockets in the ``WAIT_CLOSE`` state to be closed and recycled more rapidly (if needed to open a new socket), further reducing peak RAM usage. - Reducing :ref:`CONFIG_LWIP_TCPIP_RECVMBOX_SIZE`, :ref:`CONFIG_LWIP_TCP_RECVMBOX_SIZE` and :ref:`CONFIG_LWIP_UDP_RECVMBOX_SIZE` reduce memory usage at the expense of throughput, depending on usage. +- Reducing :ref:`CONFIG_LWIP_TCP_MSL`, :ref:`CONFIG_LWIP_TCP_FIN_WAIT_TIMEOUT` reduces the maximum segment lifetime in the system. This will also cause TCP sockets in the ``TIME_WAIT``, ``FIN_WAIT_2`` state to be closed and recycled more rapidly - Disable :ref:`CONFIG_LWIP_IPV6` can save about 39 KB for firmware size and 2KB RAM when system power up and 7KB RAM when TCPIP stack running. If there is no requirement for supporting IPV6 then it can be disabled to save flash and RAM footprint. .. only:: SOC_WIFI_SUPPORTED