diff options
author | Anders Svensson <anders@erlang.org> | 2017-06-12 23:49:43 +0200 |
---|---|---|
committer | Anders Svensson <anders@erlang.org> | 2017-06-13 00:03:47 +0200 |
commit | 69c5a74179e13e145da3da70e02dd43881a82008 (patch) | |
tree | c6b385719c581a469128c180a4a0a9b9fb6593d1 | |
parent | 2994dfc0357c5c1b6f3a9c28bdfdafb482183536 (diff) | |
download | otp-69c5a74179e13e145da3da70e02dd43881a82008.tar.gz otp-69c5a74179e13e145da3da70e02dd43881a82008.tar.bz2 otp-69c5a74179e13e145da3da70e02dd43881a82008.zip |
Capitulate on SCTP vs sparc-sun-solaris2.10
Despite the efforts of commits 1df74351 and 111261d1 to salvage it, SCTP
is just flakey on sparc-sun-solaris2.10. In addition to the woes of the
loopback address, even connect on other addresses sporadically returns
{error, eafnosupport}, so the initial check for a working SCTP (aka
resistance) is futile. Revert both commits.
-rw-r--r-- | lib/diameter/test/diameter_examples_SUITE.erl | 6 | ||||
-rw-r--r-- | lib/diameter/test/diameter_transport_SUITE.erl | 44 | ||||
-rw-r--r-- | lib/diameter/test/diameter_util.erl | 57 |
3 files changed, 44 insertions, 63 deletions
diff --git a/lib/diameter/test/diameter_examples_SUITE.erl b/lib/diameter/test/diameter_examples_SUITE.erl index 680ce4f366..fad54d62b2 100644 --- a/lib/diameter/test/diameter_examples_SUITE.erl +++ b/lib/diameter/test/diameter_examples_SUITE.erl @@ -70,8 +70,6 @@ %% Transport protocols over which the example Diameter nodes are run. -define(PROTS, [tcp, sctp]). --define(ADDR, diameter_util:ip4()). - %% =========================================================================== suite() -> @@ -348,7 +346,7 @@ top(Dir, LibDir) -> start({server, Prot}) -> ok = diameter:start(), ok = server:start(), - {ok, Ref} = server:listen({Prot, ?ADDR, 3868}), + {ok, Ref} = server:listen(Prot), [_] = ?util:lport(Prot, Ref), ok; @@ -356,7 +354,7 @@ start({client = Svc, Prot}) -> ok = diameter:start(), true = diameter:subscribe(Svc), ok = client:start(), - {ok, Ref} = client:connect({Prot, ?ADDR, ?ADDR, 3868}), + {ok, Ref} = client:connect(Prot), receive #diameter_event{info = {up, Ref, _, _, _}} -> ok end; start(Config) -> diff --git a/lib/diameter/test/diameter_transport_SUITE.erl b/lib/diameter/test/diameter_transport_SUITE.erl index 14c748ad20..9d981d0a2b 100644 --- a/lib/diameter/test/diameter_transport_SUITE.erl +++ b/lib/diameter/test/diameter_transport_SUITE.erl @@ -56,10 +56,8 @@ -define(RECV(Pat, Ret), receive Pat -> Ret end). -define(RECV(Pat), ?RECV(Pat, diameter_lib:now())). -%% Address to open sockets on. --define(ADDR(Prot), if sctp == Prot -> diameter_util:ip4(); - true -> {127,0,0,1} - end). +%% Sockets are opened on the loopback address. +-define(ADDR, {127,0,0,1}). %% diameter_tcp doesn't use anything but host_ip_address, and that %% only is a local address isn't configured as at transport start. @@ -351,14 +349,13 @@ rand_bytes(N) -> %% start_connect/3 start_connect(Prot, PortNr, Ref) -> - Addr = ?ADDR(Prot), - {ok, TPid, [_]} = start_connect(Prot, - {connect, Ref}, - ?SVC([]), - [{raddr, Addr}, - {rport, PortNr}, - {ip, Addr}, - {port, 0}]), + {ok, TPid, [?ADDR]} = start_connect(Prot, + {connect, Ref}, + ?SVC([]), + [{raddr, ?ADDR}, + {rport, PortNr}, + {ip, ?ADDR}, + {port, 0}]), ?RECV(?TMSG({TPid, connected, _})), TPid. @@ -371,9 +368,9 @@ start_connect(tcp, T, Svc, Opts) -> start_accept(Prot, Ref) -> {Mod, Opts} = tmod(Prot), - {ok, TPid, [_]} = Mod:start({accept, Ref}, - ?SVC([?ADDR(Prot)]), - [{port, 0} | Opts]), + {ok, TPid, [?ADDR]} = Mod:start({accept, Ref}, + ?SVC([?ADDR]), + [{port, 0} | Opts]), ?RECV(?TMSG({TPid, connected})), TPid. @@ -387,20 +384,19 @@ tmod(tcp) -> %% gen_connect/2 gen_connect(sctp = P, PortNr) -> - Addr = ?ADDR(P), - {ok, Sock} = Ok = gen_sctp:open([{ip, Addr}, {port, 0} | ?SCTP_OPTS]), - ok = gen_sctp:connect_init(Sock, Addr, PortNr, []), + {ok, Sock} = Ok = gen_sctp:open([{ip, ?ADDR}, {port, 0} | ?SCTP_OPTS]), + ok = gen_sctp:connect_init(Sock, ?ADDR, PortNr, []), Ok = gen_accept(P, Sock); -gen_connect(tcp = P, PortNr) -> - gen_tcp:connect(?ADDR(P), PortNr, ?TCP_OPTS). +gen_connect(tcp, PortNr) -> + gen_tcp:connect(?ADDR, PortNr, ?TCP_OPTS). %% gen_listen/1 -gen_listen(sctp = P) -> - {ok, Sock} = gen_sctp:open([{ip, ?ADDR(P)}, {port, 0} | ?SCTP_OPTS]), +gen_listen(sctp) -> + {ok, Sock} = gen_sctp:open([{ip, ?ADDR}, {port, 0} | ?SCTP_OPTS]), {gen_sctp:listen(Sock, true), Sock}; -gen_listen(tcp = P) -> - gen_tcp:listen(0, [{ip, ?ADDR(P)} | ?TCP_OPTS]). +gen_listen(tcp) -> + gen_tcp:listen(0, [{ip, ?ADDR} | ?TCP_OPTS]). %% gen_accept/2 diff --git a/lib/diameter/test/diameter_util.erl b/lib/diameter/test/diameter_util.erl index 7266d3678c..03f79096ac 100644 --- a/lib/diameter/test/diameter_util.erl +++ b/lib/diameter/test/diameter_util.erl @@ -32,8 +32,7 @@ foldl/3, scramble/1, unique_string/0, - have_sctp/0, - ip4/0]). + have_sctp/0]). %% diameter-specific -export([lport/2, @@ -185,13 +184,19 @@ unique_string() -> %% have_sctp/0 have_sctp() -> + have_sctp(erlang:system_info(system_architecture)). + +%% Don't run SCTP on platforms where it's either known to be flakey or +%% isn't available. + +have_sctp("sparc-sun-solaris2.10") -> + false; + +have_sctp(_) -> case gen_sctp:open() of {ok, Sock} -> - RC = gen_sctp:connect(Sock, ip4(), 3868, []), gen_sctp:close(Sock), - %% Connect has been seen to return eafnosupport on at least - %% one SunOS 10 Sparc host, for reasons unknown. - RC /= {error, eafnosupport}; + true; {error, E} when E == eprotonosupport; E == esocktnosupport -> %% fail on any other reason false @@ -360,8 +365,7 @@ tmod(any) -> opts([Prot | Opts], T) -> tmo(T, lists:append([[{transport_module, M}, {transport_config, C ++ Opts}] || M <- tmod(Prot), - C <- [buf(M,T) ++ [{ip, addr(M)}, {port, 0}] - ++ remote(M,T)]])); + C <- [cfg(M,T) ++ cfg(M) ++ cfg(T)]])); opts(Prot, T) -> opts([Prot], T). @@ -380,38 +384,21 @@ tmo([M, C | Opts]) -> %% Listening SCTP socket need larger-than-default buffers to avoid %% resends on some platforms (eg. SLES 11). -buf(diameter_sctp, listen) -> +cfg(diameter_sctp, listen) -> [{recbuf, 1 bsl 16}, {sndbuf, 1 bsl 16}]; -buf(_, _) -> + +cfg(_, _) -> []. -addr(diameter_tcp) -> - {127,0,0,1}; -addr(diameter_sctp) -> - ip4(). +cfg(M) + when M == diameter_tcp; + M == diameter_sctp -> + [{ip, ?ADDR}, {port, 0}]; -remote(_, listen) -> +cfg(listen) -> [{accept, M} || M <- [{256,0,0,1}, ["256.0.0.1", ["^.+$"]]]]; -remote(Mod, PortNr) -> - [{raddr, addr(Mod)}, {rport, PortNr}]. - -%% Try to use something other than the loopback address where this -%% address is known to be problematic for gen_sctp. -ip4() -> - try - "sparc-sun-solaris2.10" = erlang:system_info(system_architecture), - {ok, List} = inet:getifaddrs(), - hd(lists:flatmap(fun ip4/1, List)) - catch - error:_ -> - ?ADDR - end. - -ip4({_, Opts}) -> - {flags, Flags} = lists:keyfind(flags, 1, Opts), - [A || lists:member(up, Flags), - not lists:member(loopback, Flags), - {addr, {_,_,_,_} = A} <- Opts]. +cfg(PortNr) -> + [{raddr, ?ADDR}, {rport, PortNr}]. %% --------------------------------------------------------------------------- %% info/0 |