From f53fc31f5b9e9868819f90b40375a26b56e7031d Mon Sep 17 00:00:00 2001 From: Arnaud Wetzel Date: Wed, 4 Feb 2015 01:46:43 +0100 Subject: [PATCH] Conf option to have an end to end ipv6 otp release - add support for ipv6 connections to Epmd (removed from PR because added into commit 75bc5bebc with the merge of PR-864/OTP-13364) - add a macro to define the default epmd ip: "::1" or "127.0.0.1" - add a macro to define the default proto_dist: inet_tcp or inet6_tcp - add a configure option to compile the whole otp in ipv6 default mode The option --enable-epmd-ipv6 configures: - the -DEPMD6 CFLAG for epmd compilation - the default proto_dist (without init arg) to "inet6_tcp" - the epmd connection ip to "::1" --- configure.in | 11 +++++++++++ erts/configure.in | 12 ++++++++++++ lib/kernel/src/erl_epmd.erl | 8 +++++++- lib/kernel/src/net_kernel.erl | 10 ++++++++-- make/otp.mk.in | 11 +++++++++++ 5 files changed, 49 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index 40498f2ff96f..e466477ffbef 100644 --- a/configure.in +++ b/configure.in @@ -237,6 +237,10 @@ AC_ARG_ENABLE(native-libs, AS_HELP_STRING([--enable-native-libs], [compile Erlang libraries to native code])) +AC_ARG_ENABLE(epmd-ipv6, +AS_HELP_STRING([--enable-epmd-ipv6], + [enable epmd ipv6 communication instead of ipv4])) + AC_ARG_WITH(dynamic-trace, AS_HELP_STRING([--with-dynamic-trace={dtrace|systemtap}], [specify use of dynamic trace framework, dtrace or systemtap]) @@ -420,6 +424,13 @@ if test X${enable_native_libs} = Xyes -a X${enable_hipe} != Xno; then fi AC_SUBST(NATIVE_LIBS_ENABLED) +EPMD_IPV6_ENABLED= +if test X${enable_epmd_ipv6} = Xyes; then + CFLAGS="-DEPMD6 $CFLAGS" + export CFLAGS + EPMD_IPV6_ENABLED=yes +fi +AC_SUBST(EPMD_IPV6_ENABLED) rm -f $ERL_TOP/lib/SKIP-APPLICATIONS for app in `cd lib && ls -d *`; do diff --git a/erts/configure.in b/erts/configure.in index 4ade3b30860e..10f8008e277f 100644 --- a/erts/configure.in +++ b/erts/configure.in @@ -215,6 +215,10 @@ AC_ARG_ENABLE(native-libs, AS_HELP_STRING([--enable-native-libs], [compile Erlang libraries to native code])) +AC_ARG_ENABLE(epmd-ipv6, +AS_HELP_STRING([--enable-epmd-ipv6], + [enable epmd ipv6 communication instead of ipv4])) + AC_ARG_ENABLE(fp-exceptions, AS_HELP_STRING([--enable-fp-exceptions], [use hardware floating point exceptions (default if hipe enabled)]), @@ -3516,6 +3520,14 @@ if test X${enable_native_libs} = Xyes -a X${HIPE_ENABLED} = Xyes; then fi AC_SUBST(NATIVE_LIBS_ENABLED) +EPMD_IPV6_ENABLED= +if test X${enable_epmd_ipv6} = Xyes; then + CFLAGS="-DEPMD6 $CFLAGS" + export CFLAGS + EPMD_IPV6_ENABLED=yes +fi +AC_SUBST(EPMD_IPV6_ENABLED) + # # Check for working poll(). # diff --git a/lib/kernel/src/erl_epmd.erl b/lib/kernel/src/erl_epmd.erl index c6202dd796c8..48a614f3e484 100644 --- a/lib/kernel/src/erl_epmd.erl +++ b/lib/kernel/src/erl_epmd.erl @@ -29,6 +29,12 @@ -define(port_please_failure2(Term), noop). -endif. +-ifdef(EPMD_IPV6). +-define(DEFAULT_EPMD_IP, {0,0,0,0,0,0,0,1}). +-else. +-define(DEFAULT_EPMD_IP, {127,0,0,1}). +-endif. + %% External exports -export([start/0, start_link/0, stop/0, port_please/2, port_please/3, names/0, names/1, @@ -193,7 +199,7 @@ get_epmd_port() -> %% %% Epmd socket %% -open() -> open({127,0,0,1}). % The localhost IP address. +open() -> open(?DEFAULT_EPMD_IP). % The localhost IP address. open({A,B,C,D}=EpmdAddr) when ?ip(A,B,C,D) -> gen_tcp:connect(EpmdAddr, get_epmd_port(), [inet]); diff --git a/lib/kernel/src/net_kernel.erl b/lib/kernel/src/net_kernel.erl index 35a54f591e97..b75b634a0b01 100644 --- a/lib/kernel/src/net_kernel.erl +++ b/lib/kernel/src/net_kernel.erl @@ -53,6 +53,12 @@ -define(tckr_dbg(X), ok). -endif. +-ifdef(EPMD_IPV6). +-define(DEFAULT_PROTO_DIST, "inet6_tcp"). +-else. +-define(DEFAULT_PROTO_DIST, "inet_tcp"). +-endif. + %% User Interface Exports -export([start/1, start_link/1, stop/0, kernel_apply/3, @@ -1276,7 +1282,7 @@ protocol_childspecs() -> {ok, [Protos]} -> protocol_childspecs(Protos); _ -> - protocol_childspecs(["inet_tcp"]) + protocol_childspecs([?DEFAULT_PROTO_DIST]) end. protocol_childspecs([]) -> @@ -1312,7 +1318,7 @@ start_protos(Name,Node) -> {ok, [Protos]} -> start_protos(Name,Protos, Node); _ -> - start_protos(Name,["inet_tcp"], Node) + start_protos(Name,[?DEFAULT_PROTO_DIST], Node) end. start_protos(Name,Ps, Node) -> diff --git a/make/otp.mk.in b/make/otp.mk.in index 723f83cb45b1..b361e55eb9e8 100644 --- a/make/otp.mk.in +++ b/make/otp.mk.in @@ -61,6 +61,12 @@ DUBIOUS_ORIGINS = /undefined/environment/ HIPE_ENABLED=@HIPE_ENABLED@ NATIVE_LIBS_ENABLED=@NATIVE_LIBS_ENABLED@ +# ---------------------------------------------------- +# Epmd default IPV6 +# ---------------------------------------------------- + +EPMD_IPV6_ENABLED=@EPMD_IPV6_ENABLED@ + # ---------------------------------------------------- # Command macros # ---------------------------------------------------- @@ -99,6 +105,11 @@ else ERL_COMPILE_FLAGS += +debug_info endif endif + +ifeq ($(EPMD_IPV6_ENABLED),yes) +ERL_COMPILE_FLAGS += -DEPMD_IPV6 +endif + ERLC_WFLAGS = -W ERLC = erlc $(ERLC_WFLAGS) $(ERLC_FLAGS) ERL = erl -boot start_clean