diff options
author | Anders Svensson <[email protected]> | 2017-06-12 23:49:43 +0200 |
---|---|---|
committer | Anders Svensson <[email protected]> | 2017-06-13 00:03:47 +0200 |
commit | 69c5a74179e13e145da3da70e02dd43881a82008 (patch) | |
tree | c6b385719c581a469128c180a4a0a9b9fb6593d1 /lib/diameter/test/diameter_util.erl | |
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.
Diffstat (limited to 'lib/diameter/test/diameter_util.erl')
-rw-r--r-- | lib/diameter/test/diameter_util.erl | 57 |
1 files changed, 22 insertions, 35 deletions
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 |