[erlang-patches] [PATCH] Fix SCTP multihoming for IPv6
Tomas Abrahamsson
tomas.abrahamsson@REDACTED
Tue Aug 21 11:06:10 CEST 2012
>> Hi, please refetch!
> I think you missed one clause, see below.
Hmm.. I fail to see why that clause would be needed.
Every element in the list is already expected to be
tuples of {Ip,Port}, as returned by the set_bindx_port
function, which was unfortunately not included in full
in the diff output -- maybe I ought to have increased the
number of context lines.
Below is the entire snippet of code. Is the extra clause
to change_bindx_0_port still needed?
https://github.com/tomas-abrahamsson/otp/compare/sctp-multihoming.patch
+bindx(S, [Addr], Port0) ->
+ {IP, Port} = set_bindx_port(Addr, Port0),
+ prim_inet:bind(S, IP, Port);
+bindx(S, Addrs, Port0) ->
+ [{IP, Port} | Rest] = [set_bindx_port(Addr, Port0) || Addr <- Addrs],
+ case prim_inet:bind(S, IP, Port) of
+ {ok, AssignedPort} when Port =:= 0 ->
+ %% On newer Linux kernels, Solaris and FreeBSD, calling
+ %% bindx with port 0 is ok, but on SuSE 10, it results in einval
+ Rest2 = [change_bindx_0_port(Addr, AssignedPort) || Addr <- Rest],
+ prim_inet:bind(S, add, Rest2);
+ {ok, _} ->
+ prim_inet:bind(S, add, Rest);
+ Error ->
+ Error
+ end.
+
+set_bindx_port({_IP, _Port}=Addr, _OtherPort) ->
+ Addr;
+set_bindx_port(IP, Port) ->
+ {IP, Port}.
+
+change_bindx_0_port({IP, 0}, AssignedPort) ->
+ {IP, AssignedPort};
+change_bindx_0_port({_IP, _Port}=Addr, _AssignedPort) ->
+ Addr.
(For completeness: change_bindx_0_port with the extra clause:
>> +change_bindx_0_port({IP, 0}, AssignedPort) ->
>> + {IP, AssignedPort};
>> +change_bindx_0_port({_IP, _Port}=Addr, _AssignedPort) ->
> + Addr;
> +change_bindx_0_port(Addr, AssignedPort) ->
> + {Addr, AssignedPort}.
)
BRs
Tomas
More information about the erlang-patches
mailing list