From: Gustavo Sverzut Barbieri Date: Sat, 22 Oct 2016 11:41:26 +0000 (-0200) Subject: getaddrinfo(): when providing hints, make sure we use addrconfig/v4mapped. X-Git-Tag: upstream/1.20.0~3965 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9ab8f6636a0ba5d9031c34ea10a165a00cfab2ff;p=platform%2Fupstream%2Fefl.git getaddrinfo(): when providing hints, make sure we use addrconfig/v4mapped. if no hints were specified, getaddrinfo() will assume ai_flags as AI_ADDRCONFIG | AI_V4MAPPED, which only reports useful results based on what system supports. For instance AI_ADDRCONFIG will only return IPv4 if IPv4 address exists, likewise IPv6 will only be returned if IPv6 address is configured, avoiding these to be tried and error for most local networks where such address could not be used. AI_V4MAPPED will map IPv4 address over IPv6 if no IPv4 was found. --- diff --git a/src/lib/ecore_con/ecore_con.c b/src/lib/ecore_con/ecore_con.c index 3c90af1..7c057b3 100644 --- a/src/lib/ecore_con/ecore_con.c +++ b/src/lib/ecore_con/ecore_con.c @@ -3546,6 +3546,7 @@ _efl_net_ip_resolve_and_connect(const char *host, const char *port, int type, in .ai_socktype = type, .ai_protocol = protocol, .ai_family = AF_UNSPEC, + .ai_flags = AI_ADDRCONFIG | AI_V4MAPPED, }; Eina_Error ret = EFL_NET_DIALER_ERROR_COULDNT_CONNECT; int r; @@ -3732,6 +3733,7 @@ _efl_net_ip_connect_async_run_socks4(Efl_Net_Ip_Connect_Async_Data *d, const cha .ai_socktype = d->type, .ai_protocol = d->protocol, .ai_family = AF_INET, + .ai_flags = AI_ADDRCONFIG | AI_V4MAPPED, }; int r; @@ -3819,6 +3821,7 @@ _efl_net_ip_connect_async_run_socks4a(Efl_Net_Ip_Connect_Async_Data *d, const ch .ai_socktype = d->type, .ai_protocol = d->protocol, .ai_family = AF_INET, + .ai_flags = AI_ADDRCONFIG | AI_V4MAPPED, }; int r; @@ -4321,6 +4324,7 @@ _efl_net_ip_connect_async_run_socks5(Efl_Net_Ip_Connect_Async_Data *d, const cha .ai_socktype = d->type, .ai_protocol = d->protocol, .ai_family = AF_UNSPEC, + .ai_flags = AI_ADDRCONFIG | AI_V4MAPPED, }; Efl_Net_Socks5_Request_Command cmd; int r; @@ -4466,6 +4470,7 @@ _efl_net_ip_connect_async_run_socks5h(Efl_Net_Ip_Connect_Async_Data *d, const ch .ai_socktype = d->type, .ai_protocol = d->protocol, .ai_family = AF_UNSPEC, + .ai_flags = AI_ADDRCONFIG | AI_V4MAPPED, }; if (strchr(host, ':')) hints.ai_family = AF_INET6; diff --git a/src/lib/ecore_con/efl_net_server_tcp.c b/src/lib/ecore_con/efl_net_server_tcp.c index cdf751f..72be31c 100644 --- a/src/lib/ecore_con/efl_net_server_tcp.c +++ b/src/lib/ecore_con/efl_net_server_tcp.c @@ -160,6 +160,7 @@ _efl_net_server_tcp_efl_net_server_serve(Eo *o, Efl_Net_Server_Tcp_Data *pd, con .ai_socktype = SOCK_STREAM, .ai_protocol = IPPROTO_TCP, .ai_family = AF_UNSPEC, + .ai_flags = AI_ADDRCONFIG | AI_V4MAPPED, }; EINA_SAFETY_ON_NULL_RETURN_VAL(address, EINVAL); diff --git a/src/lib/ecore_con/efl_net_server_udp.c b/src/lib/ecore_con/efl_net_server_udp.c index bc324bc..f5d79fb 100644 --- a/src/lib/ecore_con/efl_net_server_udp.c +++ b/src/lib/ecore_con/efl_net_server_udp.c @@ -164,6 +164,7 @@ _efl_net_server_udp_efl_net_server_serve(Eo *o, Efl_Net_Server_Udp_Data *pd, con .ai_socktype = SOCK_DGRAM, .ai_protocol = IPPROTO_UDP, .ai_family = AF_UNSPEC, + .ai_flags = AI_ADDRCONFIG | AI_V4MAPPED, }; EINA_SAFETY_ON_NULL_RETURN_VAL(address, EINVAL);