|Anonymous | Login||2017-11-20 00:55 EST|
|Main | My View | View Issues | Change Log | Roadmap | My Account|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0002387||graphviz||Dotty/Lneato/Lefty||public||2013-10-30 13:24||2013-12-04 18:01|
|Priority||normal||Severity||minor||Reproducibility||have not tried|
|Summary||0002387: io.c uses obsoleted function gethostbyname|
|Description||From the manual page:|
> The gethostbyname*() and gethostbyaddr*() functions are obsolete. Applications should use getaddrinfo(3) and getnameinfo(3) instead.
AFAIK, among the others, the getaddrinfo implements the RFC 3484, so it may be better for IPv6 or dual stack machines.
|Steps To Reproduce||Check the code.|
|Additional Information||The code from the attached patch tries to connect to the first IP the OS things is the most suitable for the connection. In practice on dual stack machines this mostly means: if the hostname resolves to both IPv4 and IPv6 IPs and IPv6 is up, the IPv6 IP is taken.|
Such approach can fail if there is e.g. internal IPv6 connectivity but no external IPv6 connectivity and the AAAA records of external hostnames are still resolvable. For such cases we could retry all the returned IPs one by one in a simple loop. This would be more robust approach, but it could cause big timeouts if the network connection suddenly drops after the getaddrinfo call.
|Tags||No tags attached.|
|Attached Files||graphviz-2.34.0-lefty-getaddrinfo.patch [^] (1,716 bytes) 2013-10-30 13:24 [Show Content]|
Coincidentally, we applied a fix for this just yesterday. It appears equivalent to your patch, except it does loop and it uses hints.ai_flags = AI_PASSIVE; rather than hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICSERV;
If you feel there are problems with the new version, please let us know. Thanks.
Jaroslav Skarvada (reporter)
I am not sure whether the AI_PASSIVE is correct. From the man page (relying that the manual page is correct and complete):
If the AI_PASSIVE flag is specified in hints.ai_flags, and node is NULL, then the returned socket addresses will be suitable for bind(2)ing a socket that
will accept(2) connections. The returned socket address will contain the "wildcard address" (INADDR_ANY for IPv4 addresses, IN6ADDR_ANY_INIT for IPv6
address). The wildcard address is used by applications (typically servers) that intend to accept connections on any of the hosts's network addresses. If
node is not NULL, then the AI_PASSIVE flag is ignored.
If the AI_PASSIVE flag is not set in hints.ai_flags, then the returned socket addresses will be suitable for use with connect(2), sendto(2), or
So the AI_PASSIVE flag can be used only for servers calling bind (which doesn't seem to be your case), otherwise, for not NULL hosts, the flag is ignored, which I think is your case, so you probably do not need to specify it at all.
On the other hand, the AI_ADDRCONFIG causes the IPv4 addresses to be returned only if the local system has at least one IPv4 address configured, and IPv6 addresses are returned only if the local system has at least one IPv6 address configured. This means no delay / overhead or invalid/unreachable addresses returned (e.g. in case there is no IPv6 connectivity, but AAAA records exist on DNS servers) / the machine doesn't have configured IPv4 or IPv6 stack.
The AI_NUMERICSERV is used to inhibit the invocation of a name resolution service in cases where it is known not to be required. It's our case, the port is numeric and known, so I guess there is no need for the overhead with the service lookup.
|Okay, I will replace AI_PASSIVE with the flags you suggest.|
|2013-10-30 13:24||Jaroslav Skarvada||New Issue|
|2013-10-30 13:24||Jaroslav Skarvada||File Added: graphviz-2.34.0-lefty-getaddrinfo.patch|
|2013-10-30 13:55||erg||Note Added: 0000590|
|2013-11-28 06:38||Jaroslav Skarvada||Note Added: 0000607|
|2013-12-04 18:01||erg||Note Added: 0000621|
|2013-12-04 18:01||erg||Assigned To||=> erg|
|2013-12-04 18:01||erg||Status||new => resolved|
|2013-12-04 18:01||erg||Resolution||open => fixed|
|MantisBT 1.2.5[^] Copyright © 2000 - 2011 MantisBT Group|