lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Behavior of lwip_getaddrinfo(NULL, 1234, AI_PASSIVE) in dua


From: Simon Küppers
Subject: [lwip-users] Behavior of lwip_getaddrinfo(NULL, 1234, AI_PASSIVE) in dual-stack environment
Date: Sat, 25 Sep 2021 12:54:47 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

Hi all,

We are one of many satisfied (commercial) LWIPs users.
Very solid piece of software that is very well configurable!

We have run into a little bit of a snag with the dual-stack environment when using the open62541 Server with FreeRTOS+LWIP architecture (https://github.com/open62541/open62541).

For starting its listen sockets, it uses
getaddrinfo(NULL, 1234, IPPROTO_TCP, AI_PASSIVE)
to retrieve the local addresses that it then starts listening on and from my understanding, that is exactly what AI_PASSIVE (in conjunction with NULL as nodename) is for.

open62541 opens (or tries to anyway) one listen socket for each address returned by the getaddrinfo call. If the socket is an IPv6 socket, open62541 sets the socket option "IPV6_V6ONLY".

This is, as I understand it, one of two ways, how applications can leverage dual-stack operation. (The second one being to only open an IPv6 socket and *dont* set IPV6_V6ONLY, which btw. works very well with LWIP).

Now, when running open62541 on Linux architecture, getaddrinfo returns an IPv4 address ("0.0.0.0") and an IPv6 address("::"). I.e. open62541 listens on IPv4 and IPv6 with one socket for each. I.e. Dual-stack operation is no problem at all.
--
python3 -c "import socket; print(socket.getaddrinfo(None, 1234, proto=socket.IPPROTO_TCP, flags=socket.AI_PASSIVE))"
--

When running with LWIP however, getaddrinfo _always_ returns only a single address (even when called with nodename = NULL in which case there is no limitation due to the dns_gethostbyname call).

Is there any incentive to change this behavior, to be more compatible to PC-based architectures? I could imagine an lwip configuration directive "LWIP_NETDB_PASSIVE_IPV6" to enable returning both sockets.

In general, I could imagine even more configuration directives for getaddrinfo (i.e. priority of IPv4 and IPv6), but at the same time, the getaddrinfo probably should stay simple and lightweight, right?

What do you think? I see there is currently a new release-candidate open. Any chance to get something like this included? I could probably be persuaded into providing code if there is a chance.

Best Regards
Simon



reply via email to

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