diff --git a/.github/workflows/cherry-picks.yaml b/.github/workflows/cherry-picks.yaml index a062aa5fcf9b87..5ff341b453fdd0 100644 --- a/.github/workflows/cherry-picks.yaml +++ b/.github/workflows/cherry-picks.yaml @@ -23,7 +23,7 @@ jobs: with: fetch-depth: 0 - name: Cherry-Pick into sve branch - uses: carloscastrojumo/github-cherry-pick-action@v1.0.9 + uses: carloscastrojumo/github-cherry-pick-action@v1.0.10 with: token: ${{ secrets.MATTER_PAT }} branch: 1.3-sve 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 + diff --git a/integrations/docker/images/stage-2/chip-build-esp32/Dockerfile b/integrations/docker/images/stage-2/chip-build-esp32/Dockerfile index b50189201598e1..0745d88e8904ad 100644 --- a/integrations/docker/images/stage-2/chip-build-esp32/Dockerfile +++ b/integrations/docker/images/stage-2/chip-build-esp32/Dockerfile @@ -21,9 +21,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