You need to sign in or sign up before continuing.
  1. 17 9月, 2016 15 次提交
    • D
      rxrpc: Fix the basic transmit DATA packet content size at 1412 bytes · 182f5056
      David Howells 提交于
      Fix the basic transmit DATA packet content size at 1412 bytes so that they
      can be arbitrarily assembled into jumbo packets.
      
      In the future, I'm thinking of moving to keeping a jumbo packet header at
      the beginning of each packet in the Tx queue and creating the packet header
      on the spot when kernel_sendmsg() is invoked.  That way, jumbo packets can
      be assembled on the spur of the moment for (re-)transmission.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      182f5056
    • D
      rxrpc: Be consistent about switch value in rxrpc_send_call_packet() · 2311e327
      David Howells 提交于
      rxrpc_send_call_packet() should use type in both its switch-statements
      rather than using pkt->whdr.type.  This might give the compiler an easier
      job of uninitialised variable checking.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      2311e327
    • D
      rxrpc: Don't transmit an ACK if there's no reason set · 27d0fc43
      David Howells 提交于
      Don't transmit an ACK if call->ackr_reason in unset.  There's the
      possibility of a race between recvmsg() sending an ACK and the background
      processing thread trying to send the same one.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      27d0fc43
    • D
      rxrpc: Fix retransmission algorithm · dfa7d920
      David Howells 提交于
      Make the retransmission algorithm use for-loops instead of do-loops and
      move the counter increments into the for-statement increment slots.
      
      Though the do-loops are slighly more efficient since there will be at least
      one pass through the each loop, the counter increments are harder to get
      right as the continue-statements skip them.
      
      Without this, if there are any positive acks within the loop, the do-loop
      will cycle forever because the counter increment is never done.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      dfa7d920
    • D
      rxrpc: Fix the parsing of soft-ACKs · d01dc4c3
      David Howells 提交于
      The soft-ACK parser doesn't increment the pointer into the soft-ACK list,
      resulting in the first ACK/NACK value being applied to all the relevant
      packets in the Tx queue.  This has the potential to miss retransmissions
      and cause excessive retransmissions.
      
      Fix this by incrementing the pointer.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      d01dc4c3
    • D
      rxrpc: Fix unexposed client conn release · 78883793
      David Howells 提交于
      If the last call on a client connection is release after the connection has
      had a bunch of calls allocated but before any DATA packets are sent (so
      that it's not yet marked RXRPC_CONN_EXPOSED), an assertion will happen in
      rxrpc_disconnect_client_call().
      
      	af_rxrpc: Assertion failed - 1(0x1) >= 2(0x2) is false
      	------------[ cut here ]------------
      	kernel BUG at ../net/rxrpc/conn_client.c:753!
      
      This is because it's expecting the conn to have been exposed and to have 2
      or more refs - but this isn't necessarily the case.
      
      Simply remove the assertion.  This allows the conn to be moved into the
      inactive state and deleted if it isn't resurrected before the final put is
      called.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      78883793
    • D
      rxrpc: Call rxrpc_release_call() on error in rxrpc_new_client_call() · 357f5ef6
      David Howells 提交于
      Call rxrpc_release_call() on getting an error in rxrpc_new_client_call()
      rather than trying to do the cleanup ourselves.  This isn't a problem,
      provided we set RXRPC_CALL_HAS_USERID only if we actually add the call to
      the calls tree as cleanup code fragments that would otherwise cause
      problems are conditional.
      
      Without this, we miss some of the cleanup.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      357f5ef6
    • D
      rxrpc: Fix the putting of client connections · 66d58af7
      David Howells 提交于
      In rxrpc_put_one_client_conn(), if a connection has RXRPC_CONN_COUNTED set
      on it, then it's accounted for in rxrpc_nr_client_conns and may be on
      various lists - and this is cleaned up correctly.
      
      However, if the connection doesn't have RXRPC_CONN_COUNTED set on it, then
      the put routine returns rather than just skipping the extra bit of cleanup.
      
      Fix this by making the extra bit of clean up conditional instead and always
      killing off the connection.
      
      This manifests itself as connections with a zero usage count hanging around
      in /proc/net/rxrpc_conns because the connection allocated, but discarded,
      due to a race with another process that set up a parallel connection, which
      was then shared instead.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      66d58af7
    • D
      rxrpc: Purge the to_be_accepted queue on socket release · 0360da6d
      David Howells 提交于
      Purge the queue of to_be_accepted calls on socket release.  Note that
      purging sock_calls doesn't release the ref owned by to_be_accepted.
      
      Probably the sock_calls list is redundant given a purges of the recvmsg_q,
      the to_be_accepted queue and the calls tree.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      0360da6d
    • D
      rxrpc: Record calls that need to be accepted · e6f3afb3
      David Howells 提交于
      Record calls that need to be accepted using sk_acceptq_added() otherwise
      the backlog counter goes negative because sk_acceptq_removed() is called.
      This causes the preallocator to malfunction.
      
      Calls that are preaccepted by AFS within the kernel aren't affected by
      this.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      e6f3afb3
    • D
      rxrpc: Fix handling of the last packet in rxrpc_recvmsg_data() · 816c9fce
      David Howells 提交于
      The code for determining the last packet in rxrpc_recvmsg_data() has been
      using the RXRPC_CALL_RX_LAST flag to determine if the rx_top pointer points
      to the last packet or not.  This isn't a good idea, however, as the input
      code may be running simultaneously on another CPU and that sets the flag
      *before* updating the top pointer.
      
      Fix this by the following means:
      
       (1) Restrict the use of RXRPC_CALL_RX_LAST to the input routines only.
           There's otherwise a synchronisation problem between detecting the flag
           and checking tx_top.  This could probably be dealt with by appropriate
           application of memory barriers, but there's a simpler way.
      
       (2) Set RXRPC_CALL_RX_LAST after setting rx_top.
      
       (3) Make rxrpc_rotate_rx_window() consult the flags header field of the
           DATA packet it's about to discard to see if that was the last packet.
           Use this as the basis for ending the Rx phase.  This shouldn't be a
           problem because the recvmsg side of things is guaranteed to see the
           packets in order.
      
       (4) Make rxrpc_recvmsg_data() return 1 to indicate the end of the data if:
      
           (a) the packet it has just processed is marked as RXRPC_LAST_PACKET
      
           (b) the call's Rx phase has been ended.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      816c9fce
    • D
      rxrpc: Check the return value of rxrpc_locate_data() · 2e2ea51d
      David Howells 提交于
      Check the return value of rxrpc_locate_data() in rxrpc_recvmsg_data().
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      2e2ea51d
    • D
      rxrpc: Move the check of rx_pkt_offset from rxrpc_locate_data() to caller · 4b22457c
      David Howells 提交于
      Move the check of rx_pkt_offset from rxrpc_locate_data() to the caller,
      rxrpc_recvmsg_data(), so that it's more clear what's going on there.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      4b22457c
    • D
      rxrpc: Remove some whitespace. · fabf9201
      David Howells 提交于
      Remove a tab that's on a line that should otherwise be blank.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      fabf9201
    • D
      rxrpc: Make IPv6 support conditional on CONFIG_IPV6 · d1912747
      David Howells 提交于
      Add CONFIG_AF_RXRPC_IPV6 and make the IPv6 support code conditional on it.
      This is then made conditional on CONFIG_IPV6.
      
      Without this, the following can be seen:
      
         net/built-in.o: In function `rxrpc_init_peer':
      >> peer_object.c:(.text+0x18c3c8): undefined reference to `ip6_route_output_flags'
      Reported-by: Nkbuild test robot <fengguang.wu@intel.com>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d1912747
  2. 14 9月, 2016 14 次提交
    • D
      rxrpc: Add IPv6 support · 75b54cb5
      David Howells 提交于
      Add IPv6 support to AF_RXRPC.  With this, AF_RXRPC sockets can be created:
      
      	service = socket(AF_RXRPC, SOCK_DGRAM, PF_INET6);
      
      instead of:
      
      	service = socket(AF_RXRPC, SOCK_DGRAM, PF_INET);
      
      The AFS filesystem doesn't support IPv6 at the moment, though, since that
      requires upgrades to some of the RPC calls.
      
      Note that a good portion of this patch is replacing "%pI4:%u" in print
      statements with "%pISpc" which is able to handle both protocols and print
      the port.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      75b54cb5
    • D
      rxrpc: Use rxrpc_extract_addr_from_skb() rather than doing this manually · 1c2bc7b9
      David Howells 提交于
      There are two places that want to transmit a packet in response to one just
      received and manually pick the address to reply to out of the sk_buff.
      Make them use rxrpc_extract_addr_from_skb() instead so that IPv6 is handled
      automatically.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      1c2bc7b9
    • D
      rxrpc: Don't specify protocol to when creating transport socket · aaa31cbc
      David Howells 提交于
      Pass 0 as the protocol argument when creating the transport socket rather
      than IPPROTO_UDP.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      aaa31cbc
    • D
      rxrpc: Create an address for sendmsg() to bind unbound socket with · cd5892c7
      David Howells 提交于
      Create an address for sendmsg() to bind unbound socket with rather than
      using a completely blank address otherwise the transport socket creation
      will fail because it will try to use address family 0.
      
      We use the address family specified in the protocol argument when the
      AF_RXRPC socket was created and SOCK_DGRAM as the default.  For anything
      else, bind() must be used.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      cd5892c7
    • D
      rxrpc: Correctly initialise, limit and transmit call->rx_winsize · 75e42126
      David Howells 提交于
      call->rx_winsize should be initialised to the sysctl setting and the sysctl
      setting should be limited to the maximum we want to permit.  Further, we
      need to place this in the ACK info instead of the sysctl setting.
      
      Furthermore, discard the idea of accepting the subpackets of a jumbo packet
      that lie beyond the receive window when the first packet of the jumbo is
      within the window.  Just discard the excess subpackets instead.  This
      allows the receive window to be opened up right to the buffer size less one
      for the dead slot.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      75e42126
    • D
      rxrpc: Fix prealloc refcounting · 3432a757
      David Howells 提交于
      The preallocated call buffer holds a ref on the calls within that buffer.
      The ref was being released in the wrong place - it worked okay for incoming
      calls to the AFS cache manager service, but doesn't work right for incoming
      calls to a userspace service.
      
      Instead of releasing an extra ref service calls in rxrpc_release_call(),
      the ref needs to be released during the acceptance/rejectance process.  To
      this end:
      
       (1) The prealloc ref is now normally released during
           rxrpc_new_incoming_call().
      
       (2) For preallocated kernel API calls, the kernel API's ref needs to be
           released when the call is discarded on socket close.
      
       (3) We shouldn't take a second ref in rxrpc_accept_call().
      
       (4) rxrpc_recvmsg_new_call() needs to get a ref of its own when it adds
           the call to the to_be_accepted socket queue.
      
      In doing (4) above, we would prefer not to put the call's refcount down to
      0 as that entails doing cleanup in softirq context, but it's unlikely as
      there are several refs held elsewhere, at least one of which must be put by
      someone in process context calling rxrpc_release_call().  However, it's not
      a problem if we do have to do that.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      3432a757
    • D
      rxrpc: Adjust the call ref tracepoint to show kernel API refs · cbd00891
      David Howells 提交于
      Adjust the call ref tracepoint to show references held on a call by the
      kernel API separately as much as possible and add an additional trace to at
      the allocation point from the preallocation buffer for an incoming call.
      
      Note that this doesn't show the allocation of a client call for the kernel
      separately at the moment.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      cbd00891
    • D
      rxrpc: Allow tx_winsize to grow in response to an ACK · 01fd0742
      David Howells 提交于
      Allow tx_winsize to grow when the ACK info packet shows a larger receive
      window at the other end rather than only permitting it to shrink.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      01fd0742
    • D
      rxrpc: Use skb->len not skb->data_len · 89a80ed4
      David Howells 提交于
      skb->len should be used rather than skb->data_len when referring to the
      amount of data in a packet.  This will only cause a malfunction in the
      following cases:
      
       (1) We receive a jumbo packet (validation and splitting both are wrong).
      
       (2) We see if there's extra ACK info in an ACK packet (we think it's not
           there and just ignore it).
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      89a80ed4
    • D
      rxrpc: Add missing unlock in rxrpc_call_accept() · b25de360
      David Howells 提交于
      Add a missing unlock in rxrpc_call_accept() in the path taken if there's no
      call to wake up.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      b25de360
    • D
      rxrpc: Requeue call for recvmsg if more data · 33b603fd
      David Howells 提交于
      rxrpc_recvmsg() needs to make sure that the call it has just been
      processing gets requeued for further attention if the buffer has been
      filled and there's more data to be consumed.  The softirq producer only
      queues the call and wakes the socket if it fills the first slot in the
      window, so userspace might end up sleeping forever otherwise, despite there
      being data available.
      
      This is not a problem provided the userspace buffer is big enough or it
      empties the buffer completely before more data comes in.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      33b603fd
    • D
      rxrpc: The IDLE ACK packet should use rxrpc_idle_ack_delay · 91c2c7b6
      David Howells 提交于
      The IDLE ACK packet should use the rxrpc_idle_ack_delay setting when the
      timer is set for it.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      91c2c7b6
    • D
      rxrpc: Add missing wakeup on Tx window rotation · bc4abfcf
      David Howells 提交于
      We need to wake up the sender when Tx window rotation due to an incoming
      ACK makes space in the buffer otherwise the sender is liable to just hang
      endlessly.
      
      This problem isn't noticeable if the Tx phase transfers no more than will
      fit in a single window or the Tx window rotates fast enough that it doesn't
      get full.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      bc4abfcf
    • D
      rxrpc: Make sure we initialise the peer hash key · 08a39685
      David Howells 提交于
      Peer records created for incoming connections weren't getting their hash
      key set.  This meant that incoming calls wouldn't see more than one DATA
      packet - which is not a problem for AFS CM calls with small request data
      blobs.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      08a39685
  3. 08 9月, 2016 6 次提交
    • D
      rxrpc: Rewrite the data and ack handling code · 248f219c
      David Howells 提交于
      Rewrite the data and ack handling code such that:
      
       (1) Parsing of received ACK and ABORT packets and the distribution and the
           filing of DATA packets happens entirely within the data_ready context
           called from the UDP socket.  This allows us to process and discard ACK
           and ABORT packets much more quickly (they're no longer stashed on a
           queue for a background thread to process).
      
       (2) We avoid calling skb_clone(), pskb_pull() and pskb_trim().  We instead
           keep track of the offset and length of the content of each packet in
           the sk_buff metadata.  This means we don't do any allocation in the
           receive path.
      
       (3) Jumbo DATA packet parsing is now done in data_ready context.  Rather
           than cloning the packet once for each subpacket and pulling/trimming
           it, we file the packet multiple times with an annotation for each
           indicating which subpacket is there.  From that we can directly
           calculate the offset and length.
      
       (4) A call's receive queue can be accessed without taking locks (memory
           barriers do have to be used, though).
      
       (5) Incoming calls are set up from preallocated resources and immediately
           made live.  They can than have packets queued upon them and ACKs
           generated.  If insufficient resources exist, DATA packet #1 is given a
           BUSY reply and other DATA packets are discarded).
      
       (6) sk_buffs no longer take a ref on their parent call.
      
      To make this work, the following changes are made:
      
       (1) Each call's receive buffer is now a circular buffer of sk_buff
           pointers (rxtx_buffer) rather than a number of sk_buff_heads spread
           between the call and the socket.  This permits each sk_buff to be in
           the buffer multiple times.  The receive buffer is reused for the
           transmit buffer.
      
       (2) A circular buffer of annotations (rxtx_annotations) is kept parallel
           to the data buffer.  Transmission phase annotations indicate whether a
           buffered packet has been ACK'd or not and whether it needs
           retransmission.
      
           Receive phase annotations indicate whether a slot holds a whole packet
           or a jumbo subpacket and, if the latter, which subpacket.  They also
           note whether the packet has been decrypted in place.
      
       (3) DATA packet window tracking is much simplified.  Each phase has just
           two numbers representing the window (rx_hard_ack/rx_top and
           tx_hard_ack/tx_top).
      
           The hard_ack number is the sequence number before base of the window,
           representing the last packet the other side says it has consumed.
           hard_ack starts from 0 and the first packet is sequence number 1.
      
           The top number is the sequence number of the highest-numbered packet
           residing in the buffer.  Packets between hard_ack+1 and top are
           soft-ACK'd to indicate they've been received, but not yet consumed.
      
           Four macros, before(), before_eq(), after() and after_eq() are added
           to compare sequence numbers within the window.  This allows for the
           top of the window to wrap when the hard-ack sequence number gets close
           to the limit.
      
           Two flags, RXRPC_CALL_RX_LAST and RXRPC_CALL_TX_LAST, are added also
           to indicate when rx_top and tx_top point at the packets with the
           LAST_PACKET bit set, indicating the end of the phase.
      
       (4) Calls are queued on the socket 'receive queue' rather than packets.
           This means that we don't need have to invent dummy packets to queue to
           indicate abnormal/terminal states and we don't have to keep metadata
           packets (such as ABORTs) around
      
       (5) The offset and length of a (sub)packet's content are now passed to
           the verify_packet security op.  This is currently expected to decrypt
           the packet in place and validate it.
      
           However, there's now nowhere to store the revised offset and length of
           the actual data within the decrypted blob (there may be a header and
           padding to skip) because an sk_buff may represent multiple packets, so
           a locate_data security op is added to retrieve these details from the
           sk_buff content when needed.
      
       (6) recvmsg() now has to handle jumbo subpackets, where each subpacket is
           individually secured and needs to be individually decrypted.  The code
           to do this is broken out into rxrpc_recvmsg_data() and shared with the
           kernel API.  It now iterates over the call's receive buffer rather
           than walking the socket receive queue.
      
      Additional changes:
      
       (1) The timers are condensed to a single timer that is set for the soonest
           of three timeouts (delayed ACK generation, DATA retransmission and
           call lifespan).
      
       (2) Transmission of ACK and ABORT packets is effected immediately from
           process-context socket ops/kernel API calls that cause them instead of
           them being punted off to a background work item.  The data_ready
           handler still has to defer to the background, though.
      
       (3) A shutdown op is added to the AF_RXRPC socket so that the AFS
           filesystem can shut down the socket and flush its own work items
           before closing the socket to deal with any in-progress service calls.
      
      Future additional changes that will need to be considered:
      
       (1) Make sure that a call doesn't hog the front of the queue by receiving
           data from the network as fast as userspace is consuming it to the
           exclusion of other calls.
      
       (2) Transmit delayed ACKs from within recvmsg() when we've consumed
           sufficiently more packets to avoid the background work item needing to
           run.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      248f219c
    • D
      rxrpc: Preallocate peers, conns and calls for incoming service requests · 00e90712
      David Howells 提交于
      Make it possible for the data_ready handler called from the UDP transport
      socket to completely instantiate an rxrpc_call structure and make it
      immediately live by preallocating all the memory it might need.  The idea
      is to cut out the background thread usage as much as possible.
      
      [Note that the preallocated structs are not actually used in this patch -
       that will be done in a future patch.]
      
      If insufficient resources are available in the preallocation buffers, it
      will be possible to discard the DATA packet in the data_ready handler or
      schedule a BUSY packet without the need to schedule an attempt at
      allocation in a background thread.
      
      To this end:
      
       (1) Preallocate rxrpc_peer, rxrpc_connection and rxrpc_call structs to a
           maximum number each of the listen backlog size.  The backlog size is
           limited to a maxmimum of 32.  Only this many of each can be in the
           preallocation buffer.
      
       (2) For userspace sockets, the preallocation is charged initially by
           listen() and will be recharged by accepting or rejecting pending
           new incoming calls.
      
       (3) For kernel services {,re,dis}charging of the preallocation buffers is
           handled manually.  Two notifier callbacks have to be provided before
           kernel_listen() is invoked:
      
           (a) An indication that a new call has been instantiated.  This can be
           	 used to trigger background recharging.
      
           (b) An indication that a call is being discarded.  This is used when
           	 the socket is being released.
      
           A function, rxrpc_kernel_charge_accept() is called by the kernel
           service to preallocate a single call.  It should be passed the user ID
           to be used for that call and a callback to associate the rxrpc call
           with the kernel service's side of the ID.
      
       (4) Discard the preallocation when the socket is closed.
      
       (5) Temporarily bump the refcount on the call allocated in
           rxrpc_incoming_call() so that rxrpc_release_call() can ditch the
           preallocation ref on service calls unconditionally.  This will no
           longer be necessary once the preallocation is used.
      
      Note that this does not yet control the number of active service calls on a
      client - that will come in a later patch.
      
      A future development would be to provide a setsockopt() call that allows a
      userspace server to manually charge the preallocation buffer.  This would
      allow user call IDs to be provided in advance and the awkward manual accept
      stage to be bypassed.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      00e90712
    • D
      rxrpc: Add tracepoints to record received packets and end of data_ready · 49e19ec7
      David Howells 提交于
      Add two tracepoints:
      
       (1) Record the RxRPC protocol header of packets retrieved from the UDP
           socket by the data_ready handler.
      
       (2) Record the outcome of the data_ready handler.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      49e19ec7
    • D
      rxrpc: Remove skb_count from struct rxrpc_call · 2ab27215
      David Howells 提交于
      Remove the sk_buff count from the rxrpc_call struct as it's less useful
      once we stop queueing sk_buffs.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      2ab27215
    • D
      rxrpc: Convert rxrpc_local::services to an hlist · de8d6c74
      David Howells 提交于
      Convert the rxrpc_local::services list to an hlist so that it can be
      accessed under RCU conditions more readily.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      de8d6c74
    • D
      rxrpc: Fix ASSERTCMP and ASSERTIFCMP to handle signed values · cf13258f
      David Howells 提交于
      Fix ASSERTCMP and ASSERTIFCMP to be able to handle signed values by casting
      both parameters to the type of the first before comparing.  Without this,
      both values are cast to unsigned long, which means that checks for values
      less than zero don't work.
      
      The downside of this is that the state enum values in struct rxrpc_call and
      struct rxrpc_connection can't be bitfields as __typeof__ can't handle them.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      cf13258f
  4. 07 9月, 2016 5 次提交
    • D
      rxrpc: Add tracepoint for working out where aborts happen · 5a42976d
      David Howells 提交于
      Add a tracepoint for working out where local aborts happen.  Each
      tracepoint call is labelled with a 3-letter code so that they can be
      distinguished - and the DATA sequence number is added too where available.
      
      rxrpc_kernel_abort_call() also takes a 3-letter code so that AFS can
      indicate the circumstances when it aborts a call.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      5a42976d
    • D
      rxrpc: Fix returns of call completion helpers · e8d6bbb0
      David Howells 提交于
      rxrpc_set_call_completion() returns bool, not int, so the ret variable
      should match this.
      
      rxrpc_call_completed() and __rxrpc_call_completed() should return the value
      of rxrpc_set_call_completion().
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      e8d6bbb0
    • D
      rxrpc: Calls shouldn't hold socket refs · 8d94aa38
      David Howells 提交于
      rxrpc calls shouldn't hold refs on the sock struct.  This was done so that
      the socket wouldn't go away whilst the call was in progress, such that the
      call could reach the socket's queues.
      
      However, we can mark the socket as requiring an RCU release and rely on the
      RCU read lock.
      
      To make this work, we do:
      
       (1) rxrpc_release_call() removes the call's call user ID.  This is now
           only called from socket operations and not from the call processor:
      
      	rxrpc_accept_call() / rxrpc_kernel_accept_call()
      	rxrpc_reject_call() / rxrpc_kernel_reject_call()
      	rxrpc_kernel_end_call()
      	rxrpc_release_calls_on_socket()
      	rxrpc_recvmsg()
      
           Though it is also called in the cleanup path of
           rxrpc_accept_incoming_call() before we assign a user ID.
      
       (2) Pass the socket pointer into rxrpc_release_call() rather than getting
           it from the call so that we can get rid of uninitialised calls.
      
       (3) Fix call processor queueing to pass a ref to the work queue and to
           release that ref at the end of the processor function (or to pass it
           back to the work queue if we have to requeue).
      
       (4) Skip out of the call processor function asap if the call is complete
           and don't requeue it if the call is complete.
      
       (5) Clean up the call immediately that the refcount reaches 0 rather than
           trying to defer it.  Actual deallocation is deferred to RCU, however.
      
       (6) Don't hold socket refs for allocated calls.
      
       (7) Use the RCU read lock when queueing a message on a socket and treat
           the call's socket pointer according to RCU rules and check it for
           NULL.
      
           We also need to use the RCU read lock when viewing a call through
           procfs.
      
       (8) Transmit the final ACK/ABORT to a client call in rxrpc_release_call()
           if this hasn't been done yet so that we can then disconnect the call.
           Once the call is disconnected, it won't have any access to the
           connection struct and the UDP socket for the call work processor to be
           able to send the ACK.  Terminal retransmission will be handled by the
           connection processor.
      
       (9) Release all calls immediately on the closing of a socket rather than
           trying to defer this.  Incomplete calls will be aborted.
      
      The call refcount model is much simplified.  Refs are held on the call by:
      
       (1) A socket's user ID tree.
      
       (2) A socket's incoming call secureq and acceptq.
      
       (3) A kernel service that has a call in progress.
      
       (4) A queued call work processor.  We have to take care to put any call
           that we failed to queue.
      
       (5) sk_buffs on a socket's receive queue.  A future patch will get rid of
           this.
      
      Whilst we're at it, we can do:
      
       (1) Get rid of the RXRPC_CALL_EV_RELEASE event.  Release is now done
           entirely from the socket routines and never from the call's processor.
      
       (2) Get rid of the RXRPC_CALL_DEAD state.  Calls now end in the
           RXRPC_CALL_COMPLETE state.
      
       (3) Get rid of the rxrpc_call::destroyer work item.  Calls are now torn
           down when their refcount reaches 0 and then handed over to RCU for
           final cleanup.
      
       (4) Get rid of the rxrpc_call::deadspan timer.  Calls are cleaned up
           immediately they're finished with and don't hang around.
           Post-completion retransmission is handled by the connection processor
           once the call is disconnected.
      
       (5) Get rid of the dead call expiry setting as there's no longer a timer
           to set.
      
       (6) rxrpc_destroy_all_calls() can just check that the call list is empty.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      8d94aa38
    • D
      rxrpc: Use rxrpc_is_service_call() rather than rxrpc_conn_is_service() · 6543ac52
      David Howells 提交于
      Use rxrpc_is_service_call() rather than rxrpc_conn_is_service() if the call
      is available just in case call->conn is NULL.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      6543ac52
    • D
      rxrpc: Pass the connection pointer to rxrpc_post_packet_to_call() · 8b7fac50
      David Howells 提交于
      Pass the connection pointer to rxrpc_post_packet_to_call() as the call
      might get disconnected whilst we're looking at it, but the connection
      pointer determined by rxrpc_data_read() is guaranteed by RCU for the
      duration of the call.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      8b7fac50