From ee6d1b9a61d8f2f087f0f3bf3ea2b933b5c3a93a Mon Sep 17 00:00:00 2001 From: Raimo Niskanen Date: Tue, 13 Feb 2018 10:14:22 +0100 Subject: Stop returning V4MAPPED addresses --- erts/etc/common/inet_gethost.c | 4 ++-- lib/kernel/doc/src/inet.xml | 4 +--- lib/kernel/doc/src/inet_res.xml | 6 ++---- lib/kernel/src/inet.erl | 4 +--- lib/kernel/src/inet_res.erl | 25 ++----------------------- 5 files changed, 8 insertions(+), 35 deletions(-) diff --git a/erts/etc/common/inet_gethost.c b/erts/etc/common/inet_gethost.c index b746487668..4fc7a93348 100644 --- a/erts/etc/common/inet_gethost.c +++ b/erts/etc/common/inet_gethost.c @@ -1,7 +1,7 @@ /* * %CopyrightBegin% * - * Copyright Ericsson AB 1998-2017. All Rights Reserved. + * Copyright Ericsson AB 1998-2018. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1770,7 +1770,7 @@ static int worker_loop(void) } #elif defined(HAVE_GETIPNODEBYNAME) /*#ifdef HAVE_GETADDRINFO */ DEBUGF(5,("Starting getipnodebyname(%s)",data)); - he = getipnodebyname(data, AF_INET6, AI_DEFAULT, &error_num); + he = getipnodebyname(data, AF_INET6, 0, &error_num); if (he) { free_he = 1; error_num = 0; diff --git a/lib/kernel/doc/src/inet.xml b/lib/kernel/doc/src/inet.xml index 5c56247820..9552332948 100644 --- a/lib/kernel/doc/src/inet.xml +++ b/lib/kernel/doc/src/inet.xml @@ -277,9 +277,7 @@ fe80::204:acff:fe17:bf38

Returns a hostent record for the host with the specified hostname.

If resolver option inet6 is true, - an IPv6 address is looked up. If that fails, - the IPv4 address is looked up and returned on - IPv6-mapped IPv4 format.

+ an IPv6 address is looked up.

diff --git a/lib/kernel/doc/src/inet_res.xml b/lib/kernel/doc/src/inet_res.xml index 3454e3c6f9..351d86a93a 100644 --- a/lib/kernel/doc/src/inet_res.xml +++ b/lib/kernel/doc/src/inet_res.xml @@ -4,7 +4,7 @@
- 20092015 + 20092018 Ericsson AB. All Rights Reserved. @@ -230,9 +230,7 @@ inet_dns:record_type(_) -> undefined. getbyname/2,3.

If resolver option inet6 is true, - an IPv6 address is looked up. If that fails, - the IPv4 address is looked up and returned on - IPv6-mapped IPv4 format.

+ an IPv6 address is looked up.

diff --git a/lib/kernel/src/inet.erl b/lib/kernel/src/inet.erl index fd26a88d42..4bad523dff 100644 --- a/lib/kernel/src/inet.erl +++ b/lib/kernel/src/inet.erl @@ -1253,9 +1253,7 @@ gethostbyname_string(Name, Type) inet -> inet_parse:ipv4_address(Name); inet6 -> - %% XXX should we really translate IPv4 addresses here - %% even if we do not know if this host can do IPv6? - inet_parse:ipv6_address(Name) + inet_parse:ipv6strict_address(Name) end of {ok,IP} -> {ok,make_hostent(Name, [IP], [], Type)}; diff --git a/lib/kernel/src/inet_res.erl b/lib/kernel/src/inet_res.erl index 49aa5f8bda..58017c62fb 100644 --- a/lib/kernel/src/inet_res.erl +++ b/lib/kernel/src/inet_res.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2016. All Rights Reserved. +%% Copyright Ericsson AB 1997-2018. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -431,28 +431,7 @@ gethostbyname(Name,Family,Timeout) -> gethostbyname_tm(Name,inet,Timer) -> getbyname_tm(Name,?S_A,Timer); gethostbyname_tm(Name,inet6,Timer) -> - case getbyname_tm(Name,?S_AAAA,Timer) of - {ok,HEnt} -> {ok,HEnt}; - {error,nxdomain} -> - case getbyname_tm(Name, ?S_A,Timer) of - {ok, HEnt} -> - %% rewrite to a ipv4 only ipv6 address - {ok, - HEnt#hostent { - h_addrtype = inet6, - h_length = 16, - h_addr_list = - lists:map( - fun({A,B,C,D}) -> - {0,0,0,0,0,16#ffff,A*256+B,C*256+D} - end, HEnt#hostent.h_addr_list) - }}; - Error -> - Error - end; - Error -> - Error - end; + getbyname_tm(Name,?S_AAAA,Timer); gethostbyname_tm(_Name, _Family, _Timer) -> {error, einval}. -- cgit v1.2.3