From 5cd8855f07bd1403d3a9718e1c87ca93c38ae499 Mon Sep 17 00:00:00 2001 From: Shubham Patil Date: Tue, 21 May 2024 12:07:09 +0530 Subject: [PATCH 1/3] Memory leak fix for idf --- ...x-mldv6-report-memory-leak-in-esp_ne.patch | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 integrations/docker/images/stage-2/chip-build-esp32/0001-fix-esp_netif-Fix-mldv6-report-memory-leak-in-esp_ne.patch diff --git a/integrations/docker/images/stage-2/chip-build-esp32/0001-fix-esp_netif-Fix-mldv6-report-memory-leak-in-esp_ne.patch b/integrations/docker/images/stage-2/chip-build-esp32/0001-fix-esp_netif-Fix-mldv6-report-memory-leak-in-esp_ne.patch new file mode 100644 index 00000000000000..0876d34a1189a4 --- /dev/null +++ b/integrations/docker/images/stage-2/chip-build-esp32/0001-fix-esp_netif-Fix-mldv6-report-memory-leak-in-esp_ne.patch @@ -0,0 +1,124 @@ +From b4cd585ea8b8e0fabcc7b7b71ea4bbe84793422a Mon Sep 17 00:00:00 2001 +From: WanqQixiang +Date: Fri, 17 May 2024 15:30:45 +0800 +Subject: [PATCH] fix(esp_netif): Fix mldv6 report memory leak in esp_netif + +--- + components/esp_netif/lwip/esp_netif_lwip.c | 39 +++++++++++-------- + .../esp_netif/lwip/esp_netif_lwip_internal.h | 2 + + 2 files changed, 25 insertions(+), 16 deletions(-) + +diff --git a/components/esp_netif/lwip/esp_netif_lwip.c b/components/esp_netif/lwip/esp_netif_lwip.c +index 7f51aed896..b0bfa50bb1 100644 +--- a/components/esp_netif/lwip/esp_netif_lwip.c ++++ b/components/esp_netif/lwip/esp_netif_lwip.c +@@ -1,5 +1,5 @@ + /* +- * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD ++ * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +@@ -140,8 +140,8 @@ static void esp_netif_internal_dhcpc_cb(struct netif *netif); + #endif + #if LWIP_IPV6 + static void esp_netif_internal_nd6_cb(struct netif *p_netif, uint8_t ip_index); +-static void netif_set_mldv6_flag(struct netif *netif); +-static void netif_unset_mldv6_flag(struct netif *netif); ++static void netif_set_mldv6_flag(esp_netif_t *netif); ++static void netif_unset_mldv6_flag(esp_netif_t *netif); + #endif /* LWIP_IPV6 */ + + static esp_err_t esp_netif_destroy_api(esp_netif_api_msg_t *msg); +@@ -156,7 +156,8 @@ static void netif_callback_fn(struct netif* netif, netif_nsc_reason_t reason, co + #if LWIP_IPV6 + if ((reason & LWIP_NSC_IPV6_ADDR_STATE_CHANGED) && (args != NULL)) { + s8_t addr_idx = args->ipv6_addr_state_changed.addr_index; +- if (netif_ip6_addr_state(netif, addr_idx) & IP6_ADDR_VALID) { ++ if (!(args->ipv6_addr_state_changed.old_state & IP6_ADDR_VALID) && ++ netif_ip6_addr_state(netif, addr_idx) & IP6_ADDR_VALID) { + /* address is valid -> call the callback function */ + esp_netif_internal_nd6_cb(netif, addr_idx); + } +@@ -845,7 +846,7 @@ static void esp_netif_lwip_remove(esp_netif_t *esp_netif) + #endif + #if ESP_MLDV6_REPORT && LWIP_IPV6 + if (esp_netif->flags & ESP_NETIF_FLAG_MLDV6_REPORT) { +- netif_unset_mldv6_flag(esp_netif->lwip_netif); ++ netif_unset_mldv6_flag(esp_netif); + } + #endif + if (esp_netif->flags & ESP_NETIF_DHCP_CLIENT) { +@@ -1693,7 +1694,7 @@ static esp_err_t esp_netif_down_api(esp_netif_api_msg_t *msg) + #if CONFIG_LWIP_IPV6 + #if ESP_MLDV6_REPORT + if (esp_netif->flags & ESP_NETIF_FLAG_MLDV6_REPORT) { +- netif_unset_mldv6_flag(esp_netif->lwip_netif); ++ netif_unset_mldv6_flag(esp_netif); + } + #endif + for(int8_t i = 0 ;i < LWIP_IPV6_NUM_ADDRESSES ;i++) { +@@ -1997,25 +1998,31 @@ esp_err_t esp_netif_get_dns_info(esp_netif_t *esp_netif, esp_netif_dns_type_t ty + + static void netif_send_mldv6(void *arg) + { +- struct netif *netif = arg; +- if (!netif_is_up(netif)) { ++ esp_netif_t *esp_netif = arg; ++ esp_netif->mldv6_report_timer_started = false; ++ if (!netif_is_up(esp_netif->lwip_netif)) { + return; + } +- mld6_report_groups(netif); +- sys_timeout(CONFIG_LWIP_MLDV6_TMR_INTERVAL*1000, netif_send_mldv6, netif); ++ mld6_report_groups(esp_netif->lwip_netif); ++ esp_netif->mldv6_report_timer_started = true; ++ sys_timeout(CONFIG_LWIP_MLDV6_TMR_INTERVAL*1000, netif_send_mldv6, esp_netif); + } + +-static void netif_set_mldv6_flag(struct netif *netif) ++static void netif_set_mldv6_flag(esp_netif_t *esp_netif) + { +- if (!netif_is_up(netif)) { ++ if (!netif_is_up(esp_netif->lwip_netif) || esp_netif->mldv6_report_timer_started) { + return; + } +- sys_timeout(CONFIG_LWIP_MLDV6_TMR_INTERVAL*1000, netif_send_mldv6, netif); ++ esp_netif->mldv6_report_timer_started = true; ++ sys_timeout(CONFIG_LWIP_MLDV6_TMR_INTERVAL*1000, netif_send_mldv6, esp_netif); + } + +-static void netif_unset_mldv6_flag(struct netif *netif) ++static void netif_unset_mldv6_flag(esp_netif_t *esp_netif) + { +- sys_untimeout(netif_send_mldv6, netif); ++ if (esp_netif->mldv6_report_timer_started) { ++ esp_netif->mldv6_report_timer_started = false; ++ sys_untimeout(netif_send_mldv6, esp_netif); ++ } + } + + #endif +@@ -2062,7 +2069,7 @@ static void esp_netif_internal_nd6_cb(struct netif *netif, uint8_t ip_index) + + if (esp_netif->flags&ESP_NETIF_FLAG_MLDV6_REPORT) { + #if ESP_MLDV6_REPORT +- netif_set_mldv6_flag(netif); ++ netif_set_mldv6_flag(esp_netif); + #else + ESP_LOGW(TAG,"CONFIG_LWIP_ESP_MLDV6_REPORT not enabled, but esp-netif configured with ESP_NETIF_FLAG_MLDV6_REPORT"); + #endif +diff --git a/components/esp_netif/lwip/esp_netif_lwip_internal.h b/components/esp_netif/lwip/esp_netif_lwip_internal.h +index f1fc1f8bf8..842fc81735 100644 +--- a/components/esp_netif/lwip/esp_netif_lwip_internal.h ++++ b/components/esp_netif/lwip/esp_netif_lwip_internal.h +@@ -112,4 +112,6 @@ struct esp_netif_obj { + uint16_t max_fdb_sta_entries; + uint8_t max_ports; + #endif // CONFIG_ESP_NETIF_BRIDGE_EN ++ // mldv6 timer ++ bool mldv6_report_timer_started; + }; +-- +2.25.1 + From d1de5312d39bb2ece4b74d550f1d148f20d3aac3 Mon Sep 17 00:00:00 2001 From: Shubham Patil Date: Tue, 21 May 2024 12:10:00 +0530 Subject: [PATCH 2/3] Include the memory leak fix in esp-idf dockerfile --- integrations/docker/images/stage-2/chip-build-esp32/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integrations/docker/images/stage-2/chip-build-esp32/Dockerfile b/integrations/docker/images/stage-2/chip-build-esp32/Dockerfile index 7dd8d382b258ff..200dc764c1e66f 100644 --- a/integrations/docker/images/stage-2/chip-build-esp32/Dockerfile +++ b/integrations/docker/images/stage-2/chip-build-esp32/Dockerfile @@ -20,9 +20,11 @@ ENV IDF_PATH=/opt/espressif/esp-idf/ ENV IDF_TOOLS_PATH=/opt/espressif/tools COPY --from=build /tmp/esp-idf /opt/espressif/esp-idf +COPY 0001-fix-esp_netif-Fix-mldv6-report-memory-leak-in-esp_ne.patch /opt/espressif/esp-idf # Setup the ESP-IDF WORKDIR /opt/espressif/esp-idf RUN set -x \ + && patch -p1 < 0001-fix-esp_netif-Fix-mldv6-report-memory-leak-in-esp_ne.patch \ && ./install.sh \ && : # last line From 866b690a88ed46735f11808cb92775cbab443536 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Aug 2024 08:51:50 +0000 Subject: [PATCH 3/3] Bump docutils from 0.17.1 to 0.21.2 Bumps [docutils](https://docutils.sourceforge.io) from 0.17.1 to 0.21.2. --- updated-dependencies: - dependency-name: docutils dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- docs/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 87799ce782fe65..59502aa6e53e75 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,4 +1,4 @@ -docutils==0.17.1 +docutils==0.21.2 Sphinx>=4.5 sphinx-book-theme myst-parser