-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
epmd: support IPv6 node registration #864
Conversation
Patch has passed first testings and has been assigned to be reviewed I am a script, I am not human |
Any reason this hasn't been merged? |
afaik this is next in line of a series of changes to this area, that had to be done in the right order. |
The code has now passed the first code review step, but failed at the build step. DEPMD_PORT_NO=4369 -o /c/sebastian_jenkins/workspace/compile-opu-win32/erts/obj/win32/epmd_srv.o -c epmd_srv.c |
Note, we rebased the branch on 18.2 and tried to build it, and it fails on win 32. |
What version of Windows does the build machine run? I tested on Windows 2012. I'll add a version of inet_pton() for Windows pre-2008 and double check the other functions are supported. |
9d2e0cf
to
ba27977
Compare
I reverted back to the old behaviour of testing for inet_pton() and rebased the patch to maint. Systems that support IPv6 but don't have inet_pton() (just very old versions of windows?) won't be able to specify an IPv6 address to bind on the command line or through the ERL_EPMD_ADDRESS environment variable. I can fix that in another pull request. |
Patch has passed first testings and has been assigned to be reviewed I am a script, I am not human |
Ok, we will try it out. Some of our windows machines run rather old windows versions as they still need to be supported. We are having some other build issues at the moment, I will let you know when there is a result. |
Our windows 7 machine is still failing make[4]: Entering directory |
Do you have the possibility to test window 7? We need to try find a way forward for this PR. |
I don't have a Windows machine to test on, but I'm interested in seeing this get in. I think I see where the problem is, so I submitted #941 with my fix. |
@IngelaAndin I haven't been able to find a service that hosts Windows 7 virtual machines so I set up a Windows 2008 R2 VM on Azure for testing on the weekend. So far I haven't been able to get the stock erlang maint branch to build (some compilation errors and the resulting erlc binary segfaults). I'll ask for help on erlang-questions if I don't make any progress. Agreed about moving the PR forward. Not sure if this would be acceptable, so I wanted to do some testing first, but we could disable IPv6 support for Windows in this patch and enable it later. If legoscia's changes work ( @legoscia thanks!), it'll give me time to get a windows environment running. |
@legoscia I think we will probably have to disable IPv6 in the same way as your patch does in all the places epmd checks for IPv6 support, since the IPv6 sockaddr will be used. Running the tests now. About inet_pton() on Windows, my experience has been:
|
<tag><c>inet_ssl</c></tag> | ||
<item> | ||
<p>distribution over SSL</p> | ||
</item> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed this: the module was renamed from inet_ssl
to inet_tls
in R15. Also the description should probably say "distribution over TLS/SSL".
ba27977
to
127a198
Compare
Branch updated:
|
Patch has passed first testings and has been assigned to be reviewed I am a script, I am not human |
127a198
to
3bb8514
Compare
This change now compiles and has been confirmed to bind the IPv6 address on Windows 2008 R2 and Windows 2012 R2. It should also work on Windows 7. The issue was that the Makefile was defining _WIN32_WINNT to 0x501 (win xp) while inet_pton() and some of the other IPv6 functionality was only available in Vista and above (0x600). Hard coding _WIN32_WINNT caused even the stock main/master branches to error out when linking epmd on Windows 2008+. Tests run on Ubuntu. Couldn't run the tests on Windows since erlc is still segfaulting for me. |
Patch has passed first testings and has been assigned to be reviewed I am a script, I am not human |
Now it builds and does not seem to break things :) We have had a discussion about overriding the Here are the places to make the change: |
bf24afc
to
40695d0
Compare
Done! Also rebased to maint and tested on Windows 2008 and Windows 2012. |
Patch has passed first testings and has been assigned to be reviewed I am a script, I am not human |
PR is now in testing again. If it passed the test it will be accepted. |
Sigh, the test case register_name_ipv6 fails on our windows 8 test machine with the following log connect: error: timeout *** CT Error Notification 2016-02-22 06:27:03.304 *** We are currently trying to decide if it is a show stopper or not. |
Any chance the old IPv4 epmd is still running? If I start up the IPv4 epmd:
The test will fail with a timeout error: 29> epmd_SUITE:register_name_ipv6("foobar6").
connect: error: timeout
connect: error: timeout
connect: error: timeout
Connect failed when sending [120,[3,232],77,0,[0,5],[0,5],[0,7],[102,111,111,98,97,114,54],[0,0],[]]: timeout
** exception error: no match of right hand side value error
in function epmd_SUITE:register_name_ipv6/1 (epmd_SUITE.erl, line 189) Re-running the test using the IPv6 epmd: 30> epmd_SUITE:register_name_ipv6("foobar6").
ok netstat confirms that the client connected using IPv6:
|
Humm there has been a mistake and it was the wrong version of your PR that was in the test suites, sorry about that. We will have to wait another day and hope that is what caused the problem. |
switch (errno) { | ||
case EAFNOSUPPORT: | ||
case EPROTONOSUPPORT: | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this error case, a negative file descriptor is now saved at listensock[i], which leads to a buffer overflow later on at https://github.com/msantos/otp/blob/epmd-IPv6-node-reg2/erts/epmd/src/epmd_srv.c#L498 when calling FD_ISSET(listensock[i],&read_mask)
.
To reproduce this:
- Completely disable IPv6 with ipv6.disable=1 on the kernel command line
- Build with fortified code (RHEL/CentOS default): CFLAGS='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fno-strict-aliasing'
And you get:
[jeckersb@centos7 ~]$ ./epmd -d
epmd: Fri Feb 26 15:28:53 2016: epmd running - daemon = 0
*** buffer overflow detected ***: ./epmd terminated
======= Backtrace: =========
/lib64/libc.so.6(__fortify_fail+0x37)[0x7fd54f093b37]
/lib64/libc.so.6(+0x10bcf0)[0x7fd54f091cf0]
/lib64/libc.so.6(+0x10daa7)[0x7fd54f093aa7]
./epmd[0x40387a]
./epmd[0x401765]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7fd54efa7b15]
./epmd[0x401b41]
======= Memory map: ========
00400000-0040c000 r-xp 00000000 fd:03 407457 /home/jeckersb/epmd
0060b000-0060c000 r--p 0000b000 fd:03 407457 /home/jeckersb/epmd
0060c000-0060d000 rw-p 0000c000 fd:03 407457 /home/jeckersb/epmd
01c8d000-01cae000 rw-p 00000000 00:00 0 [heap]
7fd54ed70000-7fd54ed85000 r-xp 00000000 fd:03 136225 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7fd54ed85000-7fd54ef84000 ---p 00015000 fd:03 136225 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7fd54ef84000-7fd54ef85000 r--p 00014000 fd:03 136225 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7fd54ef85000-7fd54ef86000 rw-p 00015000 fd:03 136225 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7fd54ef86000-7fd54f13c000 r-xp 00000000 fd:03 135341 /usr/lib64/libc-2.17.so
7fd54f13c000-7fd54f33c000 ---p 001b6000 fd:03 135341 /usr/lib64/libc-2.17.so
7fd54f33c000-7fd54f340000 r--p 001b6000 fd:03 135341 /usr/lib64/libc-2.17.so
7fd54f340000-7fd54f342000 rw-p 001ba000 fd:03 135341 /usr/lib64/libc-2.17.so
7fd54f342000-7fd54f347000 rw-p 00000000 00:00 0
7fd54f347000-7fd54f448000 r-xp 00000000 fd:03 135349 /usr/lib64/libm-2.17.so
7fd54f448000-7fd54f647000 ---p 00101000 fd:03 135349 /usr/lib64/libm-2.17.so
7fd54f647000-7fd54f648000 r--p 00100000 fd:03 135349 /usr/lib64/libm-2.17.so
7fd54f648000-7fd54f649000 rw-p 00101000 fd:03 135349 /usr/lib64/libm-2.17.so
7fd54f649000-7fd54f64c000 r-xp 00000000 fd:03 135347 /usr/lib64/libdl-2.17.so
7fd54f64c000-7fd54f84b000 ---p 00003000 fd:03 135347 /usr/lib64/libdl-2.17.so
7fd54f84b000-7fd54f84c000 r--p 00002000 fd:03 135347 /usr/lib64/libdl-2.17.so
7fd54f84c000-7fd54f84d000 rw-p 00003000 fd:03 135347 /usr/lib64/libdl-2.17.so
7fd54f84d000-7fd54f84f000 r-xp 00000000 fd:03 135375 /usr/lib64/libutil-2.17.so
7fd54f84f000-7fd54fa4e000 ---p 00002000 fd:03 135375 /usr/lib64/libutil-2.17.so
7fd54fa4e000-7fd54fa4f000 r--p 00001000 fd:03 135375 /usr/lib64/libutil-2.17.so
7fd54fa4f000-7fd54fa50000 rw-p 00002000 fd:03 135375 /usr/lib64/libutil-2.17.so
7fd54fa50000-7fd54fa71000 r-xp 00000000 fd:03 135334 /usr/lib64/ld-2.17.so
7fd54fc60000-7fd54fc64000 rw-p 00000000 00:00 0
7fd54fc6f000-7fd54fc71000 rw-p 00000000 00:00 0
7fd54fc71000-7fd54fc72000 r--p 00021000 fd:03 135334 /usr/lib64/ld-2.17.so
7fd54fc72000-7fd54fc73000 rw-p 00022000 fd:03 135334 /usr/lib64/ld-2.17.so
7fd54fc73000-7fd54fc74000 rw-p 00000000 00:00 0
7fff581e1000-7fff58202000 rw-p 00000000 00:00 0 [stack]
7fff58306000-7fff58308000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Aborted
Great catch, thanks! I'll have a look at this. |
40695d0
to
14dab9b
Compare
Allow IPv6 nodes to register with and query epmd. On systems with IPv6 support: * epmd listens on both the IPv4 and IPv6 ANY or loopback sockets * the epmd cli client connects to epmd over the IPv6 loopback * distributed nodes started with "-proto_dist inet6_tcp" will register with epmd over IPv6 To work on IPv6 capable systems that have IPv6 support disabled, epmd ignores errors opening the socket if the protocol is not supported. Similarly, the epmd client will fall back to IPv4 if the IPv6 socket is not available. Update the minimum supported version of Windows to Windows Vista to support IPv6.
The patch now skips any sockets with unsupported protocols. Tested on:
Thanks @jeckersb!
|
There are still a few problems with one windows 8 machine, but we managed to test it on another windows 8 machine and are satisfied that problems are related to test case issues, and we aim to improve the test suite in a near future. For now I have merged this PR, however I missed the last update, I will make my own branch to include it as we are getting close to 18.3 deadline. |
Allow IPv6 nodes to register with and query epmd. On systems with
IPv6 support:
with epmd over IPv6
To work on IPv6 capable systems that have IPv6 support disabled,
epmd ignores errors opening the socket if the protocol is not
supported. Similarly, the epmd client will fall back to IPv4 if the IPv6
socket is not available.
The interaction between IPv4 and IPv6 sockets depends on the platform:
FreeBSD allows multiple "specific" sockets to bind the same port (such
as 2 sockets listening to the same port on ANY and the loopback).
Binding port 4369 to IPv4 and IPv6 sockets simulataneously is allowed.
Linux does not allow the same port to be bound by different sockets.
Setting the IPV6_V6ONLY socket option is required.
Windows
The behaviour differs depending on the version of Windows:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb513665(v=vs.85).aspx
According to the site, sockets on Windows XP with Service Pack 1 (SP1)
and Windows Server 2003 will only listen on either IPv4 or IPv6, so
creating two sockets is required to service IPv4 and IPv6 traffic on
the same port. The IPV6_V6ONLY socket option is not supported.
For Windows Vista and later, a single socket can handle IPv4 and IPv6
traffic for the same port. The IPV6_V6ONLY socket option is supported
and is enabled for IPv6 sockets by default.