Skip to content

Commit 6b66578

Browse files
committed
fix(dns): update esp_dns examples, tests, and CI
Migrate esp_dns_basic to net_connect, make the getaddrinfo worker stack configurable, and enable cross-signed certificate verification in sdkconfig.defaults. Move the concurrent stress app to tests/test_apps/esp_dns_concurrent and add it to esp_dns CI builds.
1 parent 099f926 commit 6b66578

13 files changed

Lines changed: 57 additions & 39 deletions

File tree

.github/workflows/esp_dns__build.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@ jobs:
1313
name: Build
1414
strategy:
1515
matrix:
16-
idf_ver: ["latest", "release-v5.1", "release-v5.2", "release-v5.3", "release-v5.4"]
16+
idf_ver: ["latest", "release-v5.4", "release-v5.5", "release-v6.0"]
1717
idf_target: ["esp32"]
18-
test: [ { app: esp_dns_basic, path: "components/esp_dns/examples"}]
18+
test:
19+
- app: esp_dns_basic
20+
path: components/esp_dns/examples
21+
ci_relpath: ../../../ci/build_apps.py
22+
- app: esp_dns_concurrent
23+
path: components/esp_dns/tests/test_apps
24+
ci_relpath: ../../../../ci/build_apps.py
1925
include:
2026
- idf_ver: "latest"
2127
warning: "the choice symbol ETHERNET_PHY_LAN867X\nis deprecated: Please use smi_gpio instead"
@@ -31,11 +37,12 @@ jobs:
3137
env:
3238
EXPECTED_WARNING: ${{ matrix.warning }}
3339
shell: bash
34-
working-directory: ${{matrix.test.path}}
40+
working-directory: ${{ matrix.test.path }}
3541
run: |
36-
if [[ "${{ matrix.idf_ver }}" == "release-v5.3" || "${{ matrix.idf_ver }}" == "release-v5.4" ]]; then
37-
export EXPECTED_WARNING="unknown kconfig symbol 'LWIP_USE_ESP_GETADDRINFO'"
42+
if [[ "${{ matrix.idf_ver }}" == "release-v5.4" || "${{ matrix.idf_ver }}" == "release-v5.5" ]]; then
43+
export EXPECTED_WARNING="unknown kconfig symbol 'LWIP_USE_ESP_GETADDRINFO'
44+
unknown kconfig symbol 'MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY'"
3845
fi
3946
. ${IDF_PATH}/export.sh
4047
python -m pip install idf-build-apps
41-
python ../../../ci/build_apps.py ./${{ matrix.test.app }} --target ${{ matrix.idf_target }} -vv --preserve-all --pytest-app
48+
python ${{ matrix.test.ci_relpath }} ./${{ matrix.test.app }} --target ${{ matrix.idf_target }} -vv --preserve-all --pytest-app

components/esp_dns/examples/esp_dns_basic/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ See the Getting Started Guide for full steps to configure and use ESP-IDF to bui
6363
Ensure that the network connection details are accurate. For example, verify the Wi-Fi SSID and password or check that the Ethernet connection is secure and not faulty.
6464

6565
* **Memory Issues**:
66-
If you encounter memory-related errors, check the system information output which displays free heap and stack high water mark. You may need to increase task stack sizes for more complex DNS operations.
66+
If you encounter memory-related errors, check the system information output which displays free heap and stack high water mark. You may need to increase task stack sizes for more complex DNS operations. The `getaddrinfo()` worker stack is configurable via menuconfig (**Example Configuration → getaddrinfo worker task stack size**); default is 8192 bytes.
6767

6868
* **Certificate Issues**:
6969
For DoT and DoH protocols, ensure that the certificates are valid for the DNS server you're using. The example includes Google DNS certificates, but these may need to be updated if they expire.
70+
Cross-signed chain verification is enabled by default in this example's `sdkconfig.defaults` (`CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY=y`). If you still see `No matching trusted root certificate found` with the certificate bundle, confirm that option is present in your active `sdkconfig`. To opt out, remove it from `sdkconfig.defaults` or disable it in menuconfig (**Component config → mbedTLS → Certificate Bundle → Support cross-signed certificate verification**).
7071

7172
## Example Output
7273

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
menu "Example Configuration"
2+
3+
config EXAMPLE_DNS_ADDRINFO_TASK_STACK
4+
int "getaddrinfo worker task stack size (bytes)"
5+
range 4096 32768
6+
default 8192
7+
help
8+
Stack size for the FreeRTOS task that runs getaddrinfo() in this example.
9+
DoT/DoH resolution pulls in mbedTLS; 4 KiB is too small on typical builds.
10+
11+
endmenu

components/esp_dns/examples/esp_dns_basic/main/esp_dns_example.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
#include "nvs_flash.h"
1818
#include "esp_event.h"
1919
#include "esp_timer.h"
20+
#include "sdkconfig.h"
2021
#include "lwip/opt.h"
21-
#include "protocol_examples_common.h"
22+
#include "net_connect.h"
2223
#include "esp_dns.h"
2324
#if defined(CONFIG_MBEDTLS_CERTIFICATE_BUNDLE)
2425
#include "esp_crt_bundle.h"
@@ -31,9 +32,6 @@
3132

3233
#define TAG "example_esp_dns"
3334

34-
/* DoH runs TLS + esp_http_client on the caller task; 4 KB overflows on IDF 6.x */
35-
#define ADDR_INFO_TASK_STACK_SIZE (8 * 1024)
36-
3735
extern const char server_root_cert_pem_start[] asm("_binary_cert_google_root_pem_start");
3836
extern const char server_root_cert_pem_end[] asm("_binary_cert_google_root_pem_end");
3937

@@ -140,7 +138,7 @@ static void run_dns_query_task(void)
140138
{
141139
TaskHandle_t task_handle = NULL;
142140
TaskHandle_t parent_handle = xTaskGetCurrentTaskHandle();
143-
xTaskCreate(addr_info_task, "AddressInfo", ADDR_INFO_TASK_STACK_SIZE, parent_handle, 5, &task_handle);
141+
xTaskCreate(addr_info_task, "AddressInfo", CONFIG_EXAMPLE_DNS_ADDRINFO_TASK_STACK, parent_handle, 5, &task_handle);
144142

145143
/* Wait for task to complete */
146144
if (task_handle != NULL) {
@@ -315,7 +313,7 @@ void app_main(void)
315313
* Read "Establishing Wi-Fi or Ethernet Connection" section in
316314
* examples/protocols/README.md for more information about this function.
317315
*/
318-
ESP_ERROR_CHECK(example_connect());
316+
ESP_ERROR_CHECK(net_connect());
319317

320318
/* Test Without ESP_DNS module */
321319
ESP_LOGI(TAG, "Executing DNS without initializing ESP_DNS module");
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
dependencies:
22
idf:
3-
version: ">=5.1"
4-
protocol_examples_common:
5-
path: ${IDF_PATH}/examples/common_components/protocol_examples_common
3+
version: ">=5.4.3"
4+
espressif/net_connect: "^0.1.1"
65
esp_dns:
76
version: "*"
87
override_path: '../../../'

components/esp_dns/examples/esp_dns_basic/sdkconfig.defaults

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
55
CONFIG_LWIP_DNS_MAX_HOST_IP=4
66
CONFIG_LWIP_USE_ESP_GETADDRINFO=y
77
CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM=y
8+
# Google Public DNS (and many other sites) present cross-signed chains; without this,
9+
# esp_crt_bundle may log "No matching trusted root certificate found" while PEM pinning works.
10+
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y
11+
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y
12+
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_CROSS_SIGNED_VERIFY=y
13+
CONFIG_EXAMPLE_DNS_ADDRINFO_TASK_STACK=8192

components/esp_dns/examples/esp_dns_concurrent_test/main/idf_component.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

components/esp_dns/examples/esp_dns_concurrent_test/CMakeLists.txt renamed to components/esp_dns/tests/test_apps/esp_dns_concurrent/CMakeLists.txt

File renamed without changes.

components/esp_dns/examples/esp_dns_concurrent_test/README.md renamed to components/esp_dns/tests/test_apps/esp_dns_concurrent/README.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,15 @@
33
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
44
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- | -------- | -------- |
55

6-
This example stress-tests **`getaddrinfo()`** while the **esp_dns** component owns the lwIP **external resolve** hook. It is meant to surface concurrency bugs documented in [ISSUES_AND_PROGRESS.md](../../ISSUES_AND_PROGRESS.md):
7-
8-
- **Issue 1** — shared singleton resolver state (`response_buffer`, transaction id) under concurrent lookups.
9-
- **Issue 4** — DNS-over-HTTPS builds the response in the same shared handle across overlapping HTTP requests.
6+
This test app stress-tests **`getaddrinfo()`** while the **esp_dns** component owns the lwIP **external resolve** hook. It exercises concurrent DoT/DoH lookups to catch regressions in per-query resolver state.
107

118
## What it does
129

13-
1. Connects Wi-Fi or Ethernet via `protocol_examples_common` (`example_connect()`).
10+
1. Connects Wi-Fi or Ethernet via the **net_connect** component (`net_connect()`).
1411
2. Initializes **Cloudflare** DNS-over-TLS (`1dot1dot1dot1.cloudflare-dns.com:853`) with the **certificate bundle**.
1512
3. Starts several FreeRTOS tasks that call `getaddrinfo()` on real hostnames at the same time; then prints success/failure counts.
1613
4. Repeats the same pattern for **DNS-over-HTTPS** (`1dot1dot1dot1.cloudflare-dns.com:443`, path `dns-query`).
17-
5. Logs explicit lines when failures occur, e.g. **Issue 1 reproduced** (DoT) / **Issue 4 reproduced** (DoH).
14+
5. Logs summary lines when lookup failures occur in a batch.
1815

1916
Tunable defines in `main/esp_dns_concurrent_test.c`:
2017

@@ -30,20 +27,19 @@ Tunable defines in `main/esp_dns_concurrent_test.c`:
3027
## Build and flash
3128

3229
```bash
33-
cd /path/to/esp-protocols/components/esp_dns/examples/esp_dns_concurrent_test
30+
cd /path/to/esp-protocols/components/esp_dns/tests/test_apps/esp_dns_concurrent
3431
idf.py set-target esp32c6
3532
idf.py -p PORT flash monitor
3633
```
3734

3835
## Expected output
3936

40-
- Many successful hostname lines, or intermittent **`getaddrinfo()`** failures (status codes depend on lwIP / LWIP-compatible errno mapping).
37+
- Many successful hostname lines under concurrent DoT/DoH.
4138
- On failure batches, component logs may include **`ESP_DNS_DOT`** / **`ESP_DNS_DOH`** errors (e.g. failed to extract IP).
42-
- Summary ends with **`Issue 1 reproduced`** and/or **`Issue 4 reproduced`** when at least one lookup failed in that mode.
4339

44-
If you see **no failures**, increase **`NUM_WORKERS`** and **`ITERATIONS_PER_TASK`** and run again.
40+
If you see unexpected failures after the concurrency fix, increase **`NUM_WORKERS`** and **`ITERATIONS_PER_TASK`** and run again.
4541

4642
## Troubleshooting
4743

48-
- **Network**: check `example_connect` credentials in `menuconfig` (same as other protocol examples).
49-
- **Certificate**: ensure certificate bundle options in `sdkconfig.defaults` match your IDF version (`menuconfig` → mbedTLS → certificate bundle).
44+
- **Network**: configure Wi-Fi/Ethernet credentials in **net_connect** options in `menuconfig`.
45+
- **Certificate**: ensure certificate bundle options in `sdkconfig.defaults` match your IDF version (`menuconfig` → mbedTLS → certificate bundle). Cross-signed chain verification is enabled by default in this test app's `sdkconfig.defaults`. Disable it in menuconfig only if you do not need cross-signed chain support.

components/esp_dns/examples/esp_dns_concurrent_test/main/CMakeLists.txt renamed to components/esp_dns/tests/test_apps/esp_dns_concurrent/main/CMakeLists.txt

File renamed without changes.

0 commit comments

Comments
 (0)