[erlang-patches] [PATCH] Fix SCTP multihoming for IPv6

Raimo Niskanen raimo+erlang-patches@REDACTED
Tue Aug 21 11:23:12 CEST 2012


On Tue, Aug 21, 2012 at 11:06:10AM +0200, Tomas Abrahamsson wrote:
> >> 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

Nope. You are right.
I missed that set_bindx_port/2 had been run on the list...

> 
> +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

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-patches mailing list