Bug 1461190 - inet:gethostbyname returns IPv4 results when IPv6 is configured [OSP-12]
Summary: inet:gethostbyname returns IPv4 results when IPv6 is configured [OSP-12]
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat OpenStack
Classification: Red Hat
Component: erlang
Version: 12.0 (Pike)
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: Upstream M2
: 12.0 (Pike)
Assignee: Peter Lemenkov
QA Contact: pkomarov
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-06-13 19:04 UTC by John Eckersberg
Modified: 2018-02-05 19:07 UTC (History)
8 users (show)

Fixed In Version: erlang-18.3.4.5-3.el7ost
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1461492 1461493 1461494 (view as bug list)
Environment:
Last Closed: 2017-12-13 21:32:50 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github erlang otp pull 1065 0 None None None 2017-06-14 14:52:03 UTC
Red Hat Product Errata RHEA-2017:3462 0 normal SHIPPED_LIVE Red Hat OpenStack Platform 12.0 Enhancement Advisory 2018-02-16 01:43:25 UTC

Description John Eckersberg 2017-06-13 19:04:04 UTC
Description of problem:
If IPv6 is configured via proto_dist and/or inetrc, inet:gethostbyname will still prefer IPv4 addresses.  This breaks epmd lookups if epmd is forced to listen only on IPv6.

Version-Release number of selected component (if applicable):
erlang-erts-18.3.4.4-3.el7ost.x86_64

How reproducible:
Always

Steps to Reproduce:
[root@rhel7 ~]# env | grep ERL                                                                                                                                                                                       
ERL_INET_GETHOST_DEBUG=5
ERL_INETRC=/root/inetrc
ERL_EPMD_ADDRESS=fd00::1
[root@rhel7 ~]# cat /root/inetrc
{inet6, true}.
[root@rhel7 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:13:f6:0e brd ff:ff:ff:ff:ff:ff
    inet 192.168.200.200/24 brd 192.168.200.255 scope global dynamic eth0
       valid_lft 2881sec preferred_lft 2881sec
    inet6 fd00::1/128 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fe13:f60e/64 scope link 
       valid_lft forever preferred_lft forever
[root@rhel7 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
fd00::1     rhel7


Actual results:
[root@rhel7 ~]# erl -sname foo -proto_dist inet6_tcp
Erlang/OTP 18 [erts-7.3.1.2] [source] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V7.3.1.2  (abort with ^G)
(foo@rhel7)1> inet:gethostbyname("rhel7").
inet_gethost[7615] (DEBUG):Saved domainname .
inet_gethost[7615] (DEBUG):Saved domainname .
inet_gethost[7616] (DEBUG):Worker got request, op = 1, proto = 1, data = rhel7.
inet_gethost[7616] (DEBUG):Starting gethostbyname(rhel7)
inet_gethost[7616] (DEBUG):gethostbyname OK
{ok,{hostent,"rhel7.example.org",[],inet,4,
             [{192,168,200,200}]}}


Expected results:
[root@rhel7 ~]# erl -sname foo -proto_dist inet6_tcp
Erlang/OTP 18 [erts-7.3.1.2] [source] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V7.3.1.2  (abort with ^G)
(foo@rhel7)1> inet:gethostbyname("rhel7").
inet_gethost[7694] (DEBUG):Saved domainname .
inet_gethost[7694] (DEBUG):Created worker[7695] with fd 3
inet_gethost[7694] (DEBUG):Saved domainname .
inet_gethost[7695] (DEBUG):Worker got request, op = 1, proto = 2, data = rhel7.
inet_gethost[7695] (DEBUG):Starting getaddrinfo(rhel7, ...)
inet_gethost[7695] (DEBUG):getaddrinfo returned 0
{ok,{hostent,"rhel7",[],inet6,16,[{64768,0,0,0,0,0,0,1}]}}


Additional info:
Upstream fix on OTP 19 - https://github.com/erlang/otp/commit/5d7dcfc2e0de7e93b29d01f07a2f970720d62f9d
Backport for OTP 18.3.4.4 - https://github.com/jeckersb/otp/commit/5ceafb8276b2d920abb3724450e87d8724d21f8e

Comment 6 pkomarov 2017-10-23 14:24:45 UTC
Verified : 

(undercloud) [stack@undercloud ~]$ rhos-release -L
Installed repositories (rhel-7.4):
  12
  rhel-7.4

$ cat core_puddle_version 
2017-10-11.5

[root@controller-0 ~]# ip a show enp5s0f0:
2: enp5s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 44:1e:a1:73:39:90 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::461e:a1ff:fe73:3990/64 scope link 
       valid_lft forever preferred_lft forever

[root@controller-0 ~]#  export ERL_INET_GETHOST_DEBUG=5
[root@controller-0 ~]# export ERL_EPMD_ADDRESS=fd00::1
[root@controller-0 ~]# export ERL_INETRC=/tmp/inetrc
[root@controller-0 ~]# cat >/root/inetrc<<EOF
{inet6, true}.
EOF

[root@controller-0 ~]# cat >>/etc/hosts<<EOF
> fd00::1     rhel7
EOF

#erlang package ver. >=  erlang-18.3.4.5-3.el7ost
[root@controller-0 ~]# rpm -qa|grep erlang
erlang-hipe-18.3.4.5-4.el7ost.x86_64
erlang-tools-18.3.4.5-4.el7ost.x86_64
...

#Actual == Expected results :

[root@controller-0 ~]# erl -sname foo -proto_dist inet6_tcp
inet_gethost[674815] (DEBUG):Saved domainname .
inet_gethost[674815] (DEBUG):Created worker[674816] with fd 3
inet_gethost[674815] (DEBUG):Saved domainname .
inet_gethost[674816] (DEBUG):Worker got request, op = 1, proto = 1, data = controller-0.
inet_gethost[674816] (DEBUG):Starting gethostbyname(controller-0)
inet_gethost[674816] (DEBUG):gethostbyname OK
inet_gethost[674815] (DEBUG):End of file while reading from pipe.
inet_gethost[674815] (DEBUG):Erlang has closed.
Erlang/OTP 18 [erts-7.3.1.3] [source] [64-bit] [smp:12:12] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V7.3.1.3  (abort with ^G)
(foo@controller-0)1> inet:gethostbyname("rhel7").
inet_gethost[675855] (DEBUG):Saved domainname .
inet_gethost[675855] (DEBUG):Created worker[675856] with fd 3
inet_gethost[675855] (DEBUG):Saved domainname .
inet_gethost[675856] (DEBUG):Worker got request, op = 1, proto = 2, data = rhel7.
inet_gethost[675856] (DEBUG):Starting getaddrinfo(rhel7, ...)
inet_gethost[675856] (DEBUG):getaddrinfo returned 0
{ok,{hostent,"rhel7",[],inet6,16,[{64768,0,0,0,0,0,0,1}]}}

Comment 9 errata-xmlrpc 2017-12-13 21:32:50 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2017:3462


Note You need to log in before you can comment on or make changes to this bug.