lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-devel] DNS destination address selection improvements for IPv6


From: Sly Gryphon
Subject: Re: [lwip-devel] DNS destination address selection improvements for IPv6
Date: Sat, 27 Apr 2024 16:57:18 +1000

I have a branch with my code from ESP-LWIP moved across. Rather than a simple compare, I put in the structure of a full sort, and added the RFC 6724 examples as test cases.

It still takes a few short cuts and only properly handles the LWIP case of at most 2 results (one IPv6 and one IPv4), so not all the example will work (e.g. can't have 2x IPv6, so comparing precedence only counts v4 vs v6).

`getaddrinfo()` now returns both results (linked; which is handled by `freeaddrinfo()`), so you may get up to two results (e.g. could be used for fallback/happy eyeballs in a dual stack environment).

I still need to run a test app to check it works; I couldn't see anything in LWIP (did find some unit test though, which I used).

I will try and getting it running with my ESP-IDF setup.

Branch is here, if anyone is interested:
https://github.com/sgryphon/lwip/tree/sgryphon/dns-dynamic-sort-rfc6724


On 13/3/24 22:18, Sly Gryphon wrote:
Hi,

I have been working on IPv6 in ESP32 Arduino, which led back to ESP-IDF, and then some changes in ESP-LWIP.

As ESP-LWIP is based on LWIP, I thought it would be best to contribute those changes upstream, as they will benefit/apply to all users of LWIP.

The problem was certain specific scenarios don't work, e.g. with both protocols enabled, looking up a dual-stack server from an IPv6 only network, doesn't work.

The client has IPv6 enabled, the network supports IPv6, and the destination supports IPv6, but DNS lookup gives the wrong result.

If you don't have IPv4 enabled, then it works fine; i.e. enabling IPv4 breaks the IPv6 scenario.

An example of the problem (ESP-IDF example) is detailed here: https://github.com/espressif/esp-idf/issues/13255

Ultimately it came down to the current static ordering of IPv4 vs IPv6 in LWIP DNS. (Changing the static ordering would have the same problem in reverse.)

So, I have a working solution, using RFC 6724 destination address selection, which dynamically selects which destination address to use based on available source addresses. i.e. if an IPv6 global scope address (and not IPv4) is available it will return IPv6 and vice-versa. Posix/linux getaddrinfo() has a similar sorting documented (RFC 6724 replaces RFC 3484): https://man7.org/linux/man-pages/man3/getaddrinfo.3.html

So rather than a static order it has dynamic ordering. I put the changes behind an option flag so that the old behaviour can be preserved. The functions are also written in such a way that we could easily add a hook to replace the default ordering if we want to add that. The current code knows you currently only get one result from DNS lookup, so maximum of 2 (one IPv6, one IPv4), so is simplified for that case, but could be extended in the future to compare multiple and keep the best (or even sort results).

Note that RFC 6724 _source_ address selection is already implemented in `ip6_select_source_address()` in `ip6.c`; this code implementing destination address selection.

Proposed implementation of RFC 6724 destination address selection (this is what I would like to contribute): https://github.com/espressif/esp-lwip/pull/66

I am not sure how to raise a pull request against upstream LWIP.

Sly Gryphon


_______________________________________________
lwip-devel mailing list
lwip-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-devel

_______________________________________________
lwip-devel mailing list
lwip-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-devel

_______________________________________________
lwip-devel mailing list
lwip-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-devel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]