linux-stable/net/rxrpc
David Howells a1399f8bb0 rxrpc: Call channels should have separate call number spaces
Each channel on a connection has a separate, independent number space from
which to allocate callNumber values.  It is entirely possible, for example,
to have a connection with four active calls, each with call number 1.

Note that the callNumber values for any particular channel don't have to
start at 1, but they are supposed to increment monotonically for that
channel from a client's perspective and may not be reused once the call
number is transmitted (until the epoch cycles all the way back round).

Currently, however, call numbers are allocated on a per-connection basis
and, further, are held in an rb-tree.  The rb-tree is redundant as the four
channel pointers in the rxrpc_connection struct are entirely capable of
pointing to all the calls currently in progress on a connection.

To this end, make the following changes:

 (1) Handle call number allocation independently per channel.

 (2) Get rid of the conn->calls rb-tree.  This is overkill as a connection
     may have a maximum of four calls in progress at any one time.  Use the
     pointers in the channels[] array instead, indexed by the channel
     number from the packet.

 (3) For each channel, save the result of the last call that was in
     progress on that channel in conn->channels[] so that the final ACK or
     ABORT packet can be replayed if necessary.  Any call earlier than that
     is just ignored.  If we've seen the next call number in a packet, the
     last one is most definitely defunct.

 (4) When generating a RESPONSE packet for a connection, the call number
     counter for each channel must be included in it.

 (5) When parsing a RESPONSE packet for a connection, the call number
     counters contained therein should be used to set the minimum expected
     call numbers on each channel.

To do in future commits:

 (1) Replay terminal packets based on the last call stored in
     conn->channels[].

 (2) Connections should be retired before the callNumber space on any
     channel runs out.

 (3) A server is expected to disregard or reject any new incoming call that
     has a call number less than the current call number counter.  The call
     number counter for that channel must be advanced to the new call
     number.

     Note that the server cannot just require that the next call that it
     sees on a channel be exactly the call number counter + 1 because then
     there's a scenario that could cause a problem: The client transmits a
     packet to initiate a connection, the network goes out, the server
     sends an ACK (which gets lost), the client sends an ABORT (which also
     gets lost); the network then reconnects, the client then reuses the
     call number for the next call (it doesn't know the server already saw
     the call number), but the server thinks it already has the first
     packet of this call (it doesn't know that the client doesn't know that
     it saw the call number the first time).

Signed-off-by: David Howells <dhowells@redhat.com>
2016-07-06 10:43:52 +01:00
..
af_rxrpc.c rxrpc: Add RCU destruction for connections and calls 2016-07-06 10:43:51 +01:00
ar-internal.h rxrpc: Call channels should have separate call number spaces 2016-07-06 10:43:52 +01:00
call_accept.c rxrpc: Move usage count getting into rxrpc_queue_conn() 2016-07-06 10:43:51 +01:00
call_event.c rxrpc: Access socket accept queue under right lock 2016-07-06 10:43:51 +01:00
call_object.c rxrpc: Call channels should have separate call number spaces 2016-07-06 10:43:52 +01:00
conn_client.c rxrpc: Check that the client conns cache is empty before module removal 2016-07-06 10:43:51 +01:00
conn_event.c rxrpc: Call channels should have separate call number spaces 2016-07-06 10:43:52 +01:00
conn_object.c rxrpc: Call channels should have separate call number spaces 2016-07-06 10:43:52 +01:00
input.c rxrpc: Move usage count getting into rxrpc_queue_conn() 2016-07-06 10:43:51 +01:00
insecure.c rxrpc: Avoid using stack memory in SG lists in rxkad 2016-07-06 10:43:05 +01:00
Kconfig rxrpc: Absorb the rxkad security module 2016-04-11 15:34:41 -04:00
key.c rxrpc: Use structs to hold connection params and protocol info 2016-06-22 09:09:59 +01:00
local_event.c rxrpc: Rework local endpoint management 2016-06-15 15:38:17 +01:00
local_object.c rxrpc: Add RCU destruction for connections and calls 2016-07-06 10:43:51 +01:00
Makefile rxrpc: Kill off the rxrpc_transport struct 2016-06-22 14:00:23 +01:00
misc.c rxrpc: Limit the listening backlog 2016-06-10 18:14:47 -07:00
output.c rxrpc: Kill off the rxrpc_transport struct 2016-06-22 14:00:23 +01:00
peer_event.c rxrpc: Use the peer record to distribute network errors 2016-06-15 10:15:16 +01:00
peer_object.c rxrpc: Kill off the rxrpc_transport struct 2016-06-22 14:00:23 +01:00
proc.c rxrpc: Call channels should have separate call number spaces 2016-07-06 10:43:52 +01:00
recvmsg.c rxrpc: Replace conn->trans->{local,peer} with conn->params.{local,peer} 2016-06-22 09:10:00 +01:00
rxkad.c rxrpc: Call channels should have separate call number spaces 2016-07-06 10:43:52 +01:00
security.c rxrpc: Replace conn->trans->{local,peer} with conn->params.{local,peer} 2016-06-22 09:10:00 +01:00
skbuff.c rxrpc: Rename files matching ar-*.c to git rid of the "ar-" prefix 2016-06-13 12:16:05 +01:00
sysctl.c rxrpc: Kill off the rxrpc_transport struct 2016-06-22 14:00:23 +01:00
utils.c rxrpc: Rework peer object handling to use hash table and RCU 2016-06-15 10:12:33 +01:00