lwIP - A Lightweight TCP/IP stack - Bugs: bug #61230, Improve Dual-Stack support for...
You are not allowed to post comments on this tracker with your current authentication level.
bug #61230: Improve Dual-Stack support for getaddrinfo, return both IPv4 and IPv6 results
Submitter: | Simon Kueppers <skuep2> | ||
Submitted: | Mon 27 Sep 2021 07:37:20 AM UTC | ||
Category: | sockets/netconn | Severity: | 3 - Normal |
Item Group: | Change Request | Status: | None |
Privacy: | Public | Assigned to: | None |
Open/Closed: | Open | Planned Release: | None |
lwIP version: | git head |
Wed 06 Oct 2021 07:53:40 PM UTC, comment #2: |
Simon Kueppers <skuep2> |
Wed 06 Oct 2021 07:43:09 PM UTC, comment #1: I have been busy and I think I have a good solution.
|
Simon Kueppers <skuep2> |
Mon 27 Sep 2021 07:37:20 AM UTC, original submission:
Currently getaddrinfo only returns a single struct addrinfo with either an IPv4 or IPv6 address (with IPv4 being preferred if AF_UNSPEC is given). This is true for either server application usage (i.e. getaddrinfo(NULL, 1234, IPPROTO_TCP, AI_PASSIVE)) or client application usage (i.e. getaddrinfo("hostname.domain", 1234, IPPROTO_TCP, 0)).
This is the intended behaviour and it would be best if LWIP's implementation of getaddrinfo could be closer to this behaviour.
getaddrinfo should return both IPv4 and IPv6 listen addresses (e.g. "0.0.0.0" and "::") to support dual-stack server applications that listen on each of the returned sockets separately and use IPV6_V6ONLY on the IPv6 socket.
This is probably a bit harder to solve, since we rely on netconn_gethostbyname_addrtype calling dns_gethostbyname which is only able to return a single address at once. It may be possible, but wasteful to run two successive calls to netconn_gethostbyname_addrtype to retrieve both IPv4 and IPv6 addresses.
|
Simon Kueppers <skuep2> |
Depends on the following items: None found
Items that depend on this one: None found
There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.
Follow 6 latest changes.
Date | Changed by | Updated Field | Previous Value | => | Replaced by |
---|---|---|---|---|---|
2021-10-06 | skuep2 | Attached File | - | Added getaddrinfo.py, #52061 | |
Attached File | - | Added getaddrinfo.c, #52062 | |||
2021-10-06 | skuep2 | Attached File | - | Added lwip_getaddrinfo.patch, #52057 | |
Attached File | - | Added getaddrinfo.pc.txt, #52058 | |||
Attached File | - | Added getaddrinfo.lwip-old.txt, #52059 | |||
Attached File | - | Added getaddrinfo.lwip-new.txt, #52060 |
Powered by Savane 3.13-758e.
Corresponding source code
Some further notes regarding my first post:
getaddrinfo in server applications (AI_PASSIVE) now works exactly as it should. The order of AF_INET/AF_INET6 in dual-stack applications can be set with LWIP_DNS_API_FAMILIES_LOCAL (netdb.h).
In client applications, I now implemented the version where two successive DNS calls to the DNS server are done, when no family is specified in the hints and lwIP is compiled as dual-stack.
This is wasteful, yes, but I think this is only an edge case. Additionally, this is something that a more-aware version of the DNS api could work around by caching both IPv4 and IPv6 addresses when a request to the DNS server is made.
The order of returned IP addresses can be set with LWIP_DNS_API_FAMILIES (netdb.h)
In the attachment is now the Python script that I used to create the reference file. I also added the C-code I used to print the results from lwIP.
(file #52061, file #52062)