aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src
AgeCommit message (Collapse)Author
2017-06-13Avoid sending answer terms between processes unnecessarilyAnders Svensson
As in commit fb14eac9, but for outgoing answers.
2017-06-13Refactor handling of incoming requestsAnders Svensson
To simplify the call chains and intermediate terms, that had become a little convoluted over time.
2017-06-13Restore diameter_codec:decode/2, update diameter_codec(3)Anders Svensson
The documentation has been out of date since the string_decode option was added in commit 1590920c. The optionless decode/2 was removed in the commit that removed the use of the process dictionary in decode.
2017-06-13Add diameter_codec option ordered_encodeAnders Svensson
To allow list-valued messaged to be encoded in the specified order, instead of in the dictionary order by first converting the list to a record. This is not yet exposed in configuration.
2017-06-13Restore undocumented Failed-AVP setting convenienceAnders Svensson
The parent commit removed the convenience of setting something like the following in the errors field of the diameter_packet of an answer message. [#diameter_avp{} = A2, {5001, #diameter_avp{} = A1}] This results in Result-Code = 5001 and Failed-AVP = [A1,A2], but is currently undocumented. Probably useful, so restore it. Also accept {RC, [#diameter_avp{}]} at encode, which is probably more useful; eg. [{5001, [A || {5001, A} <- Errors]}] Anyone who wants full control can set errors = false and formulate Result-Code/Failed-AVP themselves. (As opposed to not setting a value explicitly, which results in setting from the decoded errors list. A bit quirky, but documented and historical.)
2017-06-13Fix/simplify setting of one Failed-AVPAnders Svensson
When setting the Result-Code/Failed-AVP of an outgoing answer from an errors list either returned from or not discarded by a handle_request callback, more than the AVP paired with the Result-Code in question could be set in Failed-AVP. RFC 6733: 7.5. Failed-AVP AVP The Failed-AVP AVP (AVP Code 279) is of type Grouped and provides debugging information in cases where a request is rejected or not fully processed due to erroneous information in a specific AVP. The value of the Result-Code AVP will provide information on the reason for the Failed-AVP AVP. A Diameter answer message SHOULD contain an instance of the Failed-AVP AVP that corresponds to the error indicated by the Result-Code AVP. For practical purposes, this Failed-AVP would typically refer to the first AVP processing error that a Diameter node encounters.
2017-06-13Avoid recreating recordsAnders Svensson
In this case the diameter_packet of an answer message for encode. The record itself could be avoided, but that requires a new interface in diameter_codec, probably for little gain.
2017-06-13Avoid recreating recordsAnders Svensson
In the theme of the previous two commits, creating the required diameter_header of diameter_packet record only once.
2017-06-13Avoid recreating recordsAnders Svensson
As in the parent commit, recreating the options record is relatively costly.
2017-06-13Avoid recreating recordsAnders Svensson
This old construction is approximately two to four times slower from best (no elements modified) to worst (all modified) case, with the new construction having constant speed.
2017-06-13Simplify diameter_caps constructionAnders Svensson
Replace old macro-based implementation with something more readable.
2017-06-13Don't compute URI defaults unnecessarilyAnders Svensson
2017-06-13Don't deconstruct {TPid, Caps} unnecessarilyAnders Svensson
The tuple is returned from and passed to callbacks, so retain the tuple instead of its elements.
2017-06-13Remove use of process dictionary in decodeAnders Svensson
By passing additional arguments through it.
2017-06-12Remove minor diameter_config bloatAnders Svensson
Folded when I should have mapped.
2017-06-12Add dictionary function avp_arity/1Anders Svensson
2017-06-12Don't prepend bit for sub binary optimizationAnders Svensson
2017-06-12Remove upgrade-related codeAnders Svensson
This and subsequent commits are destined for OTP 20.0.
2017-06-12Remove unnecessary value mappingAnders Svensson
Since value is ignored.
2017-06-12Use dictionary '#new-'/1 when creating CEAAnders Svensson
Which is the equivalent of what was done with '#new-'/1 and '#set-'/2.
2017-06-12Optimize sub binary creationAnders Svensson
2017-06-12Optimize sub binary creationAnders Svensson
base/diameter_codec.erl:716: Warning: OPTIMIZED: creation of sub binary delayed
2017-06-12Optimize sub binary creationAnders Svensson
base/diameter_codec.erl:545: Warning: OPTIMIZED: creation of sub binary delayed
2017-06-12Optimize sub binary creationAnders Svensson
base/diameter_codec.erl:600: Warning: OPTIMIZED: creation of sub binary delayed
2017-06-12Don't match for no useful reasonAnders Svensson
2017-06-12Avoid modifying records during encodeAnders Svensson
2017-06-12Don't create intermediate terms unnecessarily during encodeAnders Svensson
2017-06-12Don't create intermediate binaries unnecessarily during encodeAnders Svensson
Dict:avp(encode, Value, Name) no longer needs to return a binary, only an iolist(). Message encode runs list_to_binary/1 to convert accumulated lists into a message binary.
2017-06-12Fix encode of Grouped AVP as {Dict, Name, Data}Anders Svensson
This is a special case to allow encode of something other than an iolist. Eg. #diameter_avp{data = {diameter_gen_base_rfc6733, 'Proxy-Info', [{'Proxy-Host', "HOST"}, {'Proxy-State', "STATE"}]}} Only worked as expected for AVPs of type other than Grouped.
2017-06-12Make encoding of Diameter header more efficientAnders Svensson
On the same theme as the parent commit, building binaries in fewer steps.
2017-06-12Make encoding of diameter_avp records more efficientAnders Svensson
Prepend the header in a single step. Before: {[{{diameter_codec,pack_avp,1}, 7000, 126.074, 51.058}], { {diameter_codec,pack_avp,2}, 7000, 126.074, 51.058}, % [{{diameter_codec,pack_avp,5}, 7000, 51.144, 25.758}, {{diameter_codec,pad,2}, 7000, 23.844, 23.570}, {suspend, 1, 0.028, 0.000}]}. After: {[{{diameter_codec,pack_avp,1}, 7000, 78.563, 26.986}], { {diameter_codec,pack_avp,2}, 7000, 78.563, 26.986}, % [{{diameter_codec,pack_avp,6}, 7000, 51.459, 26.381}, {suspend, 4, 0.118, 0.000}]}.
2017-06-12Decode message header in a single matchAnders Svensson
2017-06-12Use maps when detecting missing AVPsAnders Svensson
Instead of the slower sets. Bump application dependencies to 17.5, even though earlier versions may do fine.
2017-06-12Make AVP splitting more efficientAnders Svensson
Profiling with fprof showed this prior to this commit: {[{{diameter_codec,decode,3}, 1000, 231.122, 4.092}, {{diameter_codec,collect_avps,1}, 1000, 0.000, 3.929}], { {diameter_codec,collect_avps,1}, 2000, 231.122, 8.021}, % [{{diameter_codec,collect_avps,3}, 1000, 222.932, 11.644}, {garbage_collect, 19, 0.169, 0.169}, {{diameter_codec,collect_avps,1}, 1000, 0.000, 3.929}]}. {[{{diameter_codec,collect_avps,1}, 1000, 222.932, 11.644}, {{diameter_codec,collect_avps,3}, 7000, 0.000, 68.186}], { {diameter_codec,collect_avps,3}, 8000, 222.932, 79.830}, % [{{diameter_codec,split_avp,1}, 7000, 120.886, 72.382}, {{erlang,setelement,3}, 7000, 21.830, 21.830}, {garbage_collect, 48, 0.386, 0.386}, {{diameter_codec,collect_avps,3}, 7000, 0.000, 68.186}]}. Note the time consumed in split_avp/1 and erlang:setelement/3. This commit does more matching in one go, without intermediate results, giving this: {[{{diameter_codec,decode,3}, 1000, 42.512, 3.701}, {{diameter_codec,collect_avps,1}, 1000, 0.000, 3.594}], { {diameter_codec,collect_avps,1}, 2000, 42.512, 7.295}, % [{{diameter_codec,collect_avps,3}, 1000, 35.217, 4.577}, {{diameter_codec,collect_avps,1}, 1000, 0.000, 3.594}]}. {[{{diameter_codec,collect_avps,1}, 1000, 35.217, 4.577}, {{diameter_codec,collect_avps,3}, 7000, 0.000, 27.754}], { {diameter_codec,collect_avps,3}, 8000, 35.217, 32.331}, % [{garbage_collect, 262, 2.647, 2.647}, {suspend, 9, 0.239, 0.000}, {{diameter_codec,collect_avps,3}, 7000, 0.000, 27.754}]}.
2017-06-12Remove bloat from zero encodeAnders Svensson
Don't call a function when we know the result, and consistently return a binary.
2017-06-12Fix comment typosAnders Svensson
2017-06-12Add diameter_sctp option packetAnders Svensson
To determine the wrapping of messages passed to recv callbacks and into diameter. The default passing of the input stream in transport_data is probably of no practical use, but has been set since time immemorial.
2017-06-12Add diameter_sctp send/recv callbacksAnders Svensson
Corresponding to diameter_tcp callbacks a few commits back. Exercise the callbacks in the traffic suite.
2017-06-12Let diameter_tcp send/recv callbacks deal in diameter_packetAnders Svensson
To let a recv callback for an incoming request set transport_data and have it returned in a send callback.
2017-06-12Remove upgrade from diameter_trafficAnders Svensson
2017-06-12Add diameter_tcp send/recv callbacksAnders Svensson
From the receiver process, that can return binaries to send/receive and stop the transport process from reading on the socket. This is still undocumented, and may change.
2017-06-11Make diameter_{tcp,sctp} sender configurableAnders Svensson
With sends still from the receiving process by default, since changing the default behaviour may well have negative effects. A separate sender probably implies a greater need for some form of load regulation for one, since a blocking send would no longer imply that incoming messages are no longer recevied. Dealing with this could result in the same deadlock that the sending process intends to avoid, but the user should be in control over how/when incoming traffic is regulated.
2017-06-11Remove upgrade from diameter_sctp; tweak diameter_tcp to matchAnders Svensson
Added in commit 2afd1fe5. Only rename variables in diameter_tcp, no functional change.
2017-06-11Fix incomprehensible dialyzer warningAnders Svensson
This: diameter_tcp.erl:241: Record construction #transport{parent::'false',ssl::boolean() | maybe_improper_list(),frag::<<>>,tref::'false',flush::'false',pending::0,reset::{1 | 4,0 | 2},throttled::boolean(),q::{0,queue:queue(_)},monitor::'undefined' | pid()} violates the declared type of field parent::pid() The problem isn't #transport.pid at all, it's #monitor.pid, and the only relation is that the pid that's assigned to the latter is also (later) assigned to the former. There is no record construction that assigns false to #transport.parent. Introduced in commit 33a535e4.
2017-06-11Simplify acks to transport processesAnders Svensson
What's interesting when implementing some form of load regulation is when an incoming request has been answered or discarded. Acknowledge exactly this, not the identity of handler processes as previously. A transport process can request acks of nonforthcoming answers by sending {diameter, ack} to the parent peer_fsm, a handler processes identifies itself with a {handler, pid()} message, and the peer_fsm monitors on this to be able to send a notification to the transport if the handler dies before sending an answer.
2017-06-11Strip throttling callbacks from diameter_tcpAnders Svensson
Commits starting at 472a080c added a throttle_cb option to diameter_tcp to let a callback apply backpressure when it decides that additional requests should not be read. It didn't provide a hook for knowing that an answer was sent however, which is needed when sends no longer take place in the receiver process, and is more complicated than it should be. Strip it all away, in preparation for a simpler incarnation.
2017-06-11Deal with (another) SCTP association id quirk on SolarisAnders Svensson
Shutdown events have been seen to get a different association id. For example, first incoming message with association id = 0: + {trace_ts,<6421.268.0>,call, {diameter_sctp,handle_info, [{sctp,#Port<6421.2588>, {10,67,16,179}, 44159, {[{sctp_sndrcvinfo,0,0,[],0,0,0,269950872,269950872,0}], <<1,0,0,156,128,0,1,1,0,0,0,0,6,193,40,137,6,193,40,137,0,0, 1,8,64,0,0,30,67,45,49,51,52,50,49,55,52,52,49,46,101,114, 108,97,110,103,46,111,114,103,0,0,0,0,1,40,64,0,0,18,101, 114,108,97,110,103,46,111,114,103,0,0,0,0,1,1,64,0,0,14,0, 1,127,0,0,1,0,0,0,0,1,10,64,0,0,12,0,0,48,57,0,0,1,13,0,0, 0,20,79,84,80,47,100,105,97,109,101,116,101,114,0,0,1,22, 64,0,0,12,0,0,0,1,0,0,1,2,64,0,0,12,0,0,0,0,0,0,1,3,64,0,0, 12,0,0,0,3>>}}, {transport,<6421.252.0>,accept,#Port<6421.2588>,true,undefined, {32,32}, 0,undefined}]}, {1493,21505,577938}} Later, a shutdown event with association id 1536: + {trace_ts,<6421.268.0>,call, {diameter_sctp,handle_info, [{sctp,#Port<6421.2588>, {10,67,16,179}, 44159, {[],{sctp_shutdown_event,1536}}}, {transport,<6421.252.0>,accept,#Port<6421.2588>,0,undefined, {32,32}, 2,<6421.304.0>}]}, {1493,21505,746929}} Both this and the grandparent commit are on this: $ uname -a SunOS beren 5.10 Generic_118833-33 sun4v sparc SUNW,Netra-T2000
2017-06-11Deal with SCTP association id quirk on SolarisAnders Svensson
In particular, that the association id received in messages on a one-to-one socket after peeloff may be different from the id received on the listen socket at comm_up. This seems odd, since it's then not possible to send until the id is discovered by reception of an SCTP message containing it, but it's unclear if this is a bug or a feature, or if it's specific to certain platforms. Treat it as a feature in this commit, and get the association id as mentioned, an incoming CER being expected before anything is sent. Commit da3e5d67 has more history.
2017-06-11Add missing dialyzer typesAnders Svensson
Which dialyzer itself has never complained about.
2017-06-11Don't send from receiving transport processesAnders Svensson
Both diameter_tcp and diameter_sctp are susceptible to deadlock since a peer that blocks send also prevents additional messages from being received. Send from a process that's paired with the transport process to avoid this. Use the existing monitor process in the TCP case, add one in the SCTP case. This has been the reason for many sporadic testcase failures, mostly in diameter_traffic_SUITE.