Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Change DNS to dynamic sort for IPv6-only network (option) (IDFGH-12204) #13258

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sgryphon
Copy link

@sgryphon sgryphon commented Feb 25, 2024

NOTE: Cannot be merged until corresponding change in ESP-LWIP is made.

Currently DNS resolution, as used in the TLS component, does not work for a dual-stack destination from an IPv6-only network (when both IPv4 and IPv6 are enabled). See issue: #13255

A change has been made, with and option flag, in LWIP to support dynamic ordering based on whether an IPv6 global address is present or not, allowing DNS lookup to work in all networks IPv4-only, IPv6-only, and dual-stack, with all reachable destination types. The ESP-LWIP change PR is: espressif/esp-lwip#65

(Once merged, the commit reference will need to be updated to the branch with the relevant change)

This change adds a Kconfig option to match the flag, and then configures the protocol examples to enable the flag.

With these changes the https_request example now works:

I (821) example_connect: Connecting to Wildspace...
I (821) example_connect: Waiting for IP(s)
I (3231) wifi:new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
I (3491) wifi:state: init -> auth (b0)
I (3591) wifi:state: auth -> assoc (0)
I (3611) wifi:state: assoc -> run (10)
I (3621) wifi:connected with Wildspace, aid = 1, channel 1, BW20, bssid = 02:25:9c:13:92:ab
I (3621) wifi:security: WPA2-PSK, phy: bgn, rssi: -53
I (3631) wifi:pm start, type: 1

I (3631) wifi:dp: 1, bi: 102400, li: 3, scale listen interval from 307200 us to 307200 us
I (3721) wifi:dp: 2, bi: 102400, li: 4, scale listen interval from 307200 us to 409600 us
I (3721) wifi:AP's beacon interval = 102400 us, DTIM period = 2
I (5621) example_connect: Got IPv6 event: Interface "example_netif_sta" address: fe80:0000:0000:0000:0a3a:f2ff:fe65:db28, type: ESP_IP6_ADDR_IS_LINK_LOCAL
I (11621) example_connect: Got IPv6 event: Interface "example_netif_sta" address: 2407:8800:bc61:1300:0a3a:f2ff:fe65:db28, type: ESP_IP6_ADDR_IS_GLOBAL
I (11621) example_connect: Got IPv6 event: Interface "example_netif_sta" address: fd7c:e25e:67e8:0000:0a3a:f2ff:fe65:db28, type: ESP_IP6_ADDR_IS_UNIQUE_LOCAL
I (11631) example_common: Connected to example_netif_sta
I (11641) example_common: - IPv4 address: 0.0.0.0,
I (11651) example_common: - IPv6 address: fe80:0000:0000:0000:0a3a:f2ff:fe65:db28, type: ESP_IP6_ADDR_IS_LINK_LOCAL
I (11661) example_common: - IPv6 address: 2407:8800:bc61:1300:0a3a:f2ff:fe65:db28, type: ESP_IP6_ADDR_IS_GLOBAL
I (11671) example_common: - IPv6 address: fd7c:e25e:67e8:0000:0a3a:f2ff:fe65:db28, type: ESP_IP6_ADDR_IS_UNIQUE_LOCAL
I (11681) example: Updating time from NVS
I (11681) example: Start https_request example
I (11691) example: https_request using crt bundle
dns_enqueue: "v4v6.ipv6-test.com": use DNS entry 0
dns_enqueue: "v4v6.ipv6-test.com": use DNS pcb 0
dns_send: dns_servers[0] "v4v6.ipv6-test.com": request
sending DNS request ID 42552 for name "v4v6.ipv6-test.com" to server 0
I (11721) main_task: Returned from app_main()
dns_recv: "v4v6.ipv6-test.com": response = 2001:41d0:701:1100:0:0:0:29c8
dns_enqueue: "v4v6.ipv6-test.com": use DNS entry 1
dns_enqueue: "v4v6.ipv6-test.com": use DNS pcb 0
dns_send: dns_servers[0] "v4v6.ipv6-test.com": request
sending DNS request ID 14817 for name "v4v6.ipv6-test.com" to server 0
dns_recv: "v4v6.ipv6-test.com": response = 51.75.78.103
dns_select: selecting from 2 candidates
dns_select: precedence labels flags 0x2013, ipv6 scopes flags 0x4004, ipv4 scopes flags 0x0004
dns_select: rule 2, cand_0 scope (14) match 1, cand_1 scope (14) match 0
E (11811) esp-tls: [sock=54] Resolved IPv6 address: 2001:41D0:701:1100::29C8
dns_tmr: dns_check_entries
I (13161) esp-x509-crt-bundle: Certificate validated
dns_tmr: dns_check_entries
I (14691) example: Connection established...
I (14691) example: 113 bytes written
I (14691) example: Reading HTTP response...
dns_tmr: dns_check_entries
HTTP/1.1 200 OK
Date: Tue, 27 Feb 2024 21:33:20 GMT
Server: Apache/2.4.25 (Debian)
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

26
2407:8800:bc61:1300:a3a:f2ff:fe65:db28
0


dns_tmr: dns_check_entries
dns_tmr: dns_check_entries
dns_tmr: dns_check_entries
dns_tmr: dns_check_entries
dns_tmr: dns_check_entries
I (20211) example: connection closed
I (20211) example: 10...
dns_tmr: dns_check_entries
I (21211) example: 9...

Copy link

github-actions bot commented Feb 25, 2024

Messages
📖 🎉 Good Job! All checks are passing!

👋 Hello sgryphon, we appreciate your contribution to this project!


📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more.

🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project.

Click to see more instructions ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests via this public GitHub repository.

This GitHub project is public mirror of our internal git repository

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved, we synchronize it into our internal git repository.
4. In the internal git repository we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
5. If the change is approved and passes the tests it is merged into the default branch.
5. On next sync from the internal git repository merged change will appear in this public GitHub repository.

Generated by 🚫 dangerJS against 83335fe

@espressif-bot espressif-bot added the Status: Opened Issue is new label Feb 25, 2024
@github-actions github-actions bot changed the title Fix: Change DNS to dynamic sort for IPv6-only network (option) Fix: Change DNS to dynamic sort for IPv6-only network (option) (IDFGH-12204) Feb 25, 2024
@sgryphon sgryphon force-pushed the sgryphon/fix-dns-sort-ipv6-only-network branch from fd85a79 to b5e4240 Compare February 27, 2024 22:20
@sgryphon sgryphon force-pushed the sgryphon/fix-dns-sort-ipv6-only-network branch 2 times, most recently from 2e3bcc8 to 8ab0c56 Compare March 13, 2024 12:50
@espressif-abhikroy
Copy link
Collaborator

@sgryphon Thanks, for your contribution. We saw the PR and will need some time to evaluate it.

@sgryphon sgryphon force-pushed the sgryphon/fix-dns-sort-ipv6-only-network branch from 8ab0c56 to ff83b75 Compare April 1, 2024 10:09
…nly network

This fix adds a KConfig option to enable the LWIP dynamic DNS selection,
based on the addresses available on the device, allowing a device
with both IPv4 and IPv6 enabled to work in any network configuration,
including IPv4-only, IPv6-only, and dual-stack.

The example is also updated with instructions to turn on TLS and DNS logging,
and example output updated to show the IPv4 and IPv6 addresses being used.
@sgryphon sgryphon force-pushed the sgryphon/fix-dns-sort-ipv6-only-network branch from ff83b75 to 83335fe Compare April 3, 2024 10:53
@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: In Progress Work is in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants