summaryrefslogtreecommitdiff
path: root/lib/diameter
diff options
context:
space:
mode:
authorAnders Svensson <anders@erlang.org>2021-05-03 12:22:08 +0200
committerAnders Svensson <anders@erlang.org>2021-05-04 11:11:09 +0200
commit1cf647698614382f14d896a96a626910ca56ffed (patch)
treefbc9adb394735ca897be9ed91f6509b2eae32e61 /lib/diameter
parentda9acf209201f4795de7811ad672822edcde96fd (diff)
downloaderlang-1cf647698614382f14d896a96a626910ca56ffed.tar.gz
Fix association id of unordered send setopts in diameter_sctp
The call to inet:setopts/2 to request unordered delivery did not set assoc_id, and gen_sctp(3) documents the default 0 in this case as meaning the whole endpoint, which was not the intention. The result was either too much unordered or too little, depending on the use case, but exactly what the behaviour is on different OSes is a little unclear. What's clear is that it was wrong. RFC 6458 defines constants SCTP_FUTURE_ASSOC, SCTP_CURRENT_ASSOC, and SCTP_ALL_ASSOC here: https://tools.ietf.org/html/rfc6458#section-7.2 It doesn't assign numeric values however, so 0 in gen_sctp doesn't necessarily have the same meaning as the 0 that Linux (for one) defines as SCTP_FUTURE_ASSOC for example. Besides, association ids are documented as opaque by gen_sctp(3), so even setting 0 explicitly is questionable. Better to simply specify the association id that gen_sctp has communicated in the sctp_assoc_change comm_up event. Last visited in commit d3829525. Originally bungled in commit 0447bd6e. Thanks to Andreas Schultz.
Diffstat (limited to 'lib/diameter')
-rw-r--r--lib/diameter/src/transport/diameter_sctp.erl12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/diameter/src/transport/diameter_sctp.erl b/lib/diameter/src/transport/diameter_sctp.erl
index cda7af695d..0f20cda95f 100644
--- a/lib/diameter/src/transport/diameter_sctp.erl
+++ b/lib/diameter/src/transport/diameter_sctp.erl
@@ -813,23 +813,25 @@ recv(#transport{rotate = B} = S)
recv(#transport{rotate = 0,
streams = {_,OS},
socket = Sock,
+ assoc_id = Id,
unordered = B}
= S) ->
- ok = unordered(Sock, OS, B),
+ ok = unordered(Sock, Id, OS, B),
S#transport{rotate = 1 < OS};
recv(#transport{rotate = N} = S) ->
S#transport{rotate = N-1}.
-%% unordered/3
+%% unordered/4
-unordered(Sock, OS, B)
+unordered(Sock, Id, OS, B)
when B;
is_integer(B), OS =< B ->
inet:setopts(Sock, [{sctp_default_send_param,
- #sctp_sndrcvinfo{flags = [unordered]}}]);
+ #sctp_sndrcvinfo{flags = [unordered],
+ assoc_id = Id}}]);
-unordered(_, OS, B)
+unordered(_, _, OS, B)
when not B;
is_integer(B), B < OS ->
ok.