1. 08 Sep, 2016 26 commits
    • David Howells's avatar
      rxrpc: Rewrite the data and ack handling code · 248f219c
      David Howells authored
      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: default avatarDavid Howells <dhowells@redhat.com>
      248f219c
    • David Howells's avatar
      rxrpc: Preallocate peers, conns and calls for incoming service requests · 00e90712
      David Howells authored
      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: default avatarDavid Howells <dhowells@redhat.com>
      00e90712
    • David Howells's avatar
      rxrpc: Add tracepoints to record received packets and end of data_ready · 49e19ec7
      David Howells authored
      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: default avatarDavid Howells <dhowells@redhat.com>
      49e19ec7
    • David Howells's avatar
      rxrpc: Remove skb_count from struct rxrpc_call · 2ab27215
      David Howells authored
      Remove the sk_buff count from the rxrpc_call struct as it's less useful
      once we stop queueing sk_buffs.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      2ab27215
    • David Howells's avatar
      rxrpc: Convert rxrpc_local::services to an hlist · de8d6c74
      David Howells authored
      Convert the rxrpc_local::services list to an hlist so that it can be
      accessed under RCU conditions more readily.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      de8d6c74
    • David Howells's avatar
      rxrpc: Update protocol definitions slightly · 18f1387c
      David Howells authored
      Update the protocol definitions in include/rxrpc/packet.h slightly:
      
       (1) Get rid of RXRPC_PROCESS_MAXCALLS as it's redundant (same as
           RXRPC_MAXCALLS).
      
       (2) In struct rxrpc_jumbo_header, put _rsvd in a union with a field called
           cksum to match struct rxrpc_wire_header.
      
       (3) Provide RXRPC_JUMBO_SUBPKTLEN which is the total of the amount of data
           in a non-terminal subpacket plus the following secondary header for
           the next packet included in the jumbo packet.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      18f1387c
    • David Howells's avatar
      rxrpc: Fix ASSERTCMP and ASSERTIFCMP to handle signed values · cf13258f
      David Howells authored
      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: default avatarDavid Howells <dhowells@redhat.com>
      cf13258f
    • subashab@codeaurora.org's avatar
      net: xfrm: Change u32 sysctl entries to use proc_douintvec · 0f76d256
      subashab@codeaurora.org authored
      proc_dointvec limits the values to INT_MAX in u32 sysctl entries.
      proc_douintvec allows to write upto UINT_MAX.
      Signed-off-by: default avatarSubash Abhinov Kasiviswanathan <subashab@codeaurora.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0f76d256
    • David S. Miller's avatar
      Merge branch 'be2net-error-recovery-and-bug-fixes' · 015777be
      David S. Miller authored
      Sriharsha Basavapatna says:
      
      ====================
      be2net: patch-set
      
      The following patch set contains an error recovery feature and a few
      bug fixes. Please consider applying this to the net-next tree. Thanks.
      
      Patch-1 Supports HW error recovery in Skyhawk/BEx adapters
      Patch-2 Fixes driver unload to issue function reset FW command
      Patch-3 Avoids issuing GET_EXT_FAT_CAPABILITIES command for VFs
      Patch-4 Avoids redundant addition of mac address in HW
      Patch-5 Fixes mac address collision in some configurations
      Patch-6 Updates driver version
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      015777be
    • Sriharsha Basavapatna's avatar
    • Suresh Reddy's avatar
      be2net: Fix mac address collision in some configurations · c27ebf58
      Suresh Reddy authored
      If the device mac address is updated using ndo_set_mac_address(),
      while the same mac address is already programmed, the driver does not
      detect this condition if its netdev->dev_addr has been changed. The
      driver tries to add the same mac address resulting in mac address
      collision error. This has been observed in bonding mode-5 configuration.
      
      To fix this, store the mac address configured in HW in the adapter
      structure. Use this to compare against the new address being updated
      to avoid collision.
      Signed-off-by: default avatarSuresh Reddy <Suresh.Reddy@broadcom.com>
      Signed-off-by: default avatarSathya Perla <sathya.perla@broadcom.com>
      Signed-off-by: default avatarSriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c27ebf58
    • Suresh Reddy's avatar
      be2net: Avoid redundant addition of mac address in HW · 988d44b1
      Suresh Reddy authored
      If a mac address is added to the uc_list and later the same mac address
      is added via ndo_set_mac_address() or vice versa, the driver does not
      detect this condition and tries to add it again. This results in a mac
      address collision error when the FW rejects it.
      
      Fix this by checking if the given mac address is present in uc_list while
      setting the device mac address and vice versa. Similarly skip deletion if
      the address is still in use in the other form.
      Signed-off-by: default avatarSuresh Reddy <Suresh.Reddy@broadcom.com>
      Signed-off-by: default avatarSathya Perla <sathya.perla@broadcom.com>
      Signed-off-by: default avatarSriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      988d44b1
    • Somnath Kotur's avatar
      be2net: Add privilege level check for OPCODE_COMMON_GET_EXT_FAT_CAPABILITIES SLI cmd. · 62259ac4
      Somnath Kotur authored
      Driver issues OPCODE_COMMON_GET_EXT_FAT_CAPABILITIES cmd during init which
      when issued by VFs results in the logging of a cmd failure message since
      they don't have the required privilege for this cmd. Fix by checking
      privilege before issuing the cmd.
      
      Also fixed typo in CAPABILITIES.
      Signed-off-by: default avatarSomnath Kotur <somnath.kotur@broadcom.com>
      Signed-off-by: default avatarSriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      62259ac4
    • Somnath Kotur's avatar
      be2net: Issue COMMON_RESET_FUNCTION cmd during driver unload · f72099e0
      Somnath Kotur authored
      As per SLI guideline, drivers need to issue COMMON_RESET_FUNCTION SLI
      cmd during driver unload to clean up any non-persistent state
      information.
      Issue this cmd only if VFs are not assigned to VMs as it is possible
      for PF driver to unload while it\'s VF remains functional and assigned
      to a VM.
      Signed-off-by: default avatarSomnath Kotur <somnath.kotur@broadcom.com>
      Signed-off-by: default avatarSriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f72099e0
    • Sriharsha Basavapatna's avatar
      be2net: Support UE recovery in BEx/Skyhawk adapters · 710f3e59
      Sriharsha Basavapatna authored
      This patch supports recovery from UEs caused due to Transient Parity
      Errors (TPE), in BE2, BE3 and Skyhawk adapters. This change avoids
      system reboot when such errors occur. The driver recovers from these
      errors such that the adapter resumes full operational status as prior
      to the UE.
      
      Following is the list of changes in the driver to support this:
      
      o The driver registers its UE recoverable capability with ARM FW at init
      time. This also allows the driver to know if the feature is supported in
      the FW.
      
      o As the UE recovery requires precise time bound processing, the driver
      creates its own error recovery work queue with a single worker thread (per
      module, shared across functions).
      
      o Each function runs an error detection task at an interval of 1 second as
      required by the FW. The error detection logic already exists for BEx/SH,
      but it now runs in the context of a separate worker thread.
      
      o When an error is detected by the task, if it is recoverable, the PF0
      driver instance initiates a soft reset, while other PF driver instances
      wait for the reset to complete and the chip to become ready. Once
      the chip is ready, all driver instances including PF0, resume to
      reinitialize the respective functions.
      
      o The PF0 driver checks for some recovery criteria, to determine if the
      recovery can be initiated. If the criteria is not met, the PF0 driver does
      not initiate a soft reset, it retains the existing behavior to stop
      further processing and requires a reboot to get the chip to operational
      state again.
      
      o To allow each function to share the workq, while also making progress in
      its recovery process, a per-function recovery state machine is used.
      The per-function tasks avoid blocking operations like msleep() while in
      this state machine (until reinit state) and instead reschedule for the
      required delay.
      
      o With these changes, the existing error recovery code for Lancer also
      runs in the context of the new worker thread.
      Signed-off-by: default avatarSriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      710f3e59
    • Linus Walleij's avatar
      net: smsc911x: request and deassert optional RESET GPIO · dd0cb7db
      Linus Walleij authored
      On some systems (such as the Qualcomm APQ8060 Dragonboard) the
      RESET signal of the SMSC911x is not pulled up by a resistor (or
      the internal pull-up that will pull it up if the pin is not
      even connected) but instead connected to a GPIO line, so that
      the operating system must explicitly deassert RESET before use.
      
      Support this in the SMSC911x driver so this ethernet connector
      can be used on such targets.
      
      Notice that we request the line to go logical low (deassert)
      whilst the line on the actual component is active low. This
      is managed in the respective hardware description when
      specifying the GPIO line with e.g. device tree or ACPI. With
      device tree it looks like this in one case:
      
        reset-gpios = <&tlmm 30 GPIO_ACTIVE_LOW>;
      
      Which means that logically requesting the RESET line to be
      deasserted will result in the line being driven high, taking
      the device out of reset.
      
      Cc: Jeremy Linton <jeremy.linton@arm.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Reviewed-by: default avatarJeremy Linton <jeremy.linton@arm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      dd0cb7db
    • Linus Walleij's avatar
      net: smsc911x: augment device tree bindings · 216559d9
      Linus Walleij authored
      This adds device tree bindings for:
      
      - An optional GPIO line for releasing the RESET signal to the
        SMSC911x devices
      
      - An optional PME (power management event) interrupt line that
        can be utilized to wake up the system on network activity.
        This signal exist on all the SMSC911x devices, it is just not
        very often routed.
      
      Both these lines are routed to the SoC on the Qualcomm APQ8060
      Dragonboard and thus needs to be bound in the device tree.
      
      Cc: devicetree@vger.kernel.org
      Cc: Jeremy Linton <jeremy.linton@arm.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      216559d9
    • David S. Miller's avatar
      Merge branch 'qed-debug-data-collection' · e6f3f120
      David S. Miller authored
      Tomer Tayar says:
      
      ====================
      qed*: Debug data collection
      
      This patch series adds the support of debug data collection in the qed driver,
      and the means to extract it in the qede driver via the get_regs operation.
      
      Changes from V1:
      - Respin of the series after rebasing next-next.
      - Remove the first patch as it seems that its V1 version was already applied
        (commit '4102426f').
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e6f3f120
    • Tomer Tayar's avatar
    • Tomer Tayar's avatar
      qed: Add support for debug data collection · c965db44
      Tomer Tayar authored
      This patch adds the support for dumping and formatting the HW/FW debug data.
      Signed-off-by: default avatarTomer Tayar <Tomer.Tayar@qlogic.com>
      Signed-off-by: default avatarYuval Mintz <Yuval.Mintz@qlogic.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c965db44
    • Oliver Neukum's avatar
      kaweth: remove obsolete debugging statements · 936f0600
      Oliver Neukum authored
      SOme statements in the driver only served to inform
      which functions were entered. Ftrace can do that just as good without
      needing memory. Remove the statements.
      Signed-off-by: default avatarOliver Neukum <oneukum@suse.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      936f0600
    • Baoyou Xie's avatar
      qed: add missing header dependencies · 72e8d5fd
      Baoyou Xie authored
      We get 4 warnings when building kernel with W=1:
      drivers/net/ethernet/qlogic/qed/qed_selftest.c:6:5: warning: no previous prototype for 'qed_selftest_memory' [-Wmissing-prototypes]
      drivers/net/ethernet/qlogic/qed/qed_selftest.c:19:5: warning: no previous prototype for 'qed_selftest_interrupt' [-Wmissing-prototypes]
      drivers/net/ethernet/qlogic/qed/qed_selftest.c:32:5: warning: no previous prototype for 'qed_selftest_register' [-Wmissing-prototypes]
      drivers/net/ethernet/qlogic/qed/qed_selftest.c:55:5: warning: no previous prototype for 'qed_selftest_clock' [-Wmissing-prototypes]
      
      In fact, these functions are declared in qed_selftest.h, so this patch
      add missing header dependencies.
      Signed-off-by: default avatarBaoyou Xie <baoyou.xie@linaro.org>
      Acked-by: default avatarYuval Mintz <Yuval.Mintz@qlogic.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      72e8d5fd
    • Lorenzo Colitti's avatar
      net: diag: make udp_diag_destroy work for mapped addresses. · f95bf346
      Lorenzo Colitti authored
      udp_diag_destroy does look up the IPv4 UDP hashtable for mapped
      addresses, but it gets the IPv4 address to look up from the
      beginning of the IPv6 address instead of the end.
      
      Tested: https://android-review.googlesource.com/269874
      Fixes: 5d77dca8 ("net: diag: support SOCK_DESTROY for UDP sockets")
      Signed-off-by: default avatarLorenzo Colitti <lorenzo@google.com>
      Acked-by: default avatarEric Dumazet <edumazet@google.com>
      Acked-by: default avatarDavid Ahern <dsa@cumulusnetworks.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f95bf346
    • Andrey Vagin's avatar
      netlink: don't forget to release a rhashtable_iter structure · 733ade23
      Andrey Vagin authored
      This bug was detected by kmemleak:
      unreferenced object 0xffff8804269cc3c0 (size 64):
        comm "criu", pid 1042, jiffies 4294907360 (age 13.713s)
        hex dump (first 32 bytes):
          a0 32 cc 2c 04 88 ff ff 00 00 00 00 00 00 00 00  .2.,............
          00 01 00 00 00 00 ad de 00 02 00 00 00 00 ad de  ................
        backtrace:
          [<ffffffff8184dffa>] kmemleak_alloc+0x4a/0xa0
          [<ffffffff8124720f>] kmem_cache_alloc_trace+0x10f/0x280
          [<ffffffffa02864cc>] __netlink_diag_dump+0x26c/0x290 [netlink_diag]
      
      v2: don't remove a reference on a rhashtable_iter structure to
          release it from netlink_diag_dump_done
      
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Fixes: ad202074 ("netlink: Use rhashtable walk interface in diag dump")
      Signed-off-by: default avatarAndrei Vagin <avagin@openvz.org>
      Acked-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      733ade23
    • David S. Miller's avatar
      Merge tag 'rxrpc-rewrite-20160907-2' of... · 457b4139
      David S. Miller authored
      Merge tag 'rxrpc-rewrite-20160907-2' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs
      
      David Howells says:
      
      ====================
      rxrpc: Local abort tracepoint
      
      Here are two patches.  They need to be applied on top of the just-posted
      call refcount overhaul patch:
      
       (1) Fix the return value of some call completion helpers.
      
       (2) Add a tracepoint that allows local aborts to be debugged.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      457b4139
    • David S. Miller's avatar
      Merge tag 'rxrpc-rewrite-20160907-1' of... · 9103e04b
      David S. Miller authored
      Merge tag 'rxrpc-rewrite-20160907-1' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs
      
      David Howells says:
      
      ====================
      rxrpc: Overhaul call refcounting
      
      Here's a set of mostly small patches leading up to one big one.
      
      The big patch at the end of the series overhauls how rxrpc_call refcounting
      is handled, making it more sane so that calls bound to user IDs are _only_
      released from socket operations or kernel API functions.  Further, the
      patch stops calls from holding refs on their parent socket - which can
      prevent the socket from being cleaned up.
      
      The second largest patch improves the call tracking tracepoint by providing
      extra information about the situation in which gets and puts occur.  This
      allows distinctions to be drawn between refs held by the socket user ID
      tree, refs held by the work queue (to be implemented by a future patch) and
      other refs.
      
      The other patches include a couple of cleanups and some simple alterations
      to avoid NULL pointer dereferences in the big patch.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9103e04b
  2. 07 Sep, 2016 10 commits
    • David Howells's avatar
      rxrpc: Add tracepoint for working out where aborts happen · 5a42976d
      David Howells authored
      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: default avatarDavid Howells <dhowells@redhat.com>
      5a42976d
    • David Howells's avatar
      rxrpc: Fix returns of call completion helpers · e8d6bbb0
      David Howells authored
      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: default avatarDavid Howells <dhowells@redhat.com>
      e8d6bbb0
    • David Howells's avatar
      rxrpc: Calls shouldn't hold socket refs · 8d94aa38
      David Howells authored
      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: default avatarDavid Howells <dhowells@redhat.com>
      8d94aa38
    • David Howells's avatar
      rxrpc: Use rxrpc_is_service_call() rather than rxrpc_conn_is_service() · 6543ac52
      David Howells authored
      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: default avatarDavid Howells <dhowells@redhat.com>
      6543ac52
    • David Howells's avatar
      rxrpc: Pass the connection pointer to rxrpc_post_packet_to_call() · 8b7fac50
      David Howells authored
      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: default avatarDavid Howells <dhowells@redhat.com>
      8b7fac50
    • David Howells's avatar
      rxrpc: Cache the security index in the rxrpc_call struct · 278ac0cd
      David Howells authored
      Cache the security index in the rxrpc_call struct so that we can get at it
      even when the call has been disconnected and the connection pointer
      cleared.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      278ac0cd
    • David Howells's avatar
      rxrpc: Use call->peer rather than call->conn->params.peer · f4fdb352
      David Howells authored
      Use call->peer rather than call->conn->params.peer to avoid the possibility
      of call->conn being NULL and, whilst we're at it, check it for NULL before we
      access it.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      f4fdb352
    • David Howells's avatar
      rxrpc: Improve the call tracking tracepoint · fff72429
      David Howells authored
      Improve the call tracking tracepoint by showing more differentiation
      between some of the put and get events, including:
      
        (1) Getting and putting refs for the socket call user ID tree.
      
        (2) Getting and putting refs for queueing and failing to queue the call
            processor work item.
      
      Note that these aren't necessarily used in this patch, but will be taken
      advantage of in future patches.
      
      An enum is added for the event subtype numbers rather than coding them
      directly as decimal numbers and a table of 3-letter strings is provided
      rather than a sequence of ?: operators.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      fff72429
    • David Howells's avatar
      rxrpc: Delete unused rxrpc_kernel_free_skb() · e796cb41
      David Howells authored
      Delete rxrpc_kernel_free_skb() as it's unused.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      e796cb41
    • David Howells's avatar
      rxrpc: Whitespace cleanup · 71a17de3
      David Howells authored
      Remove some whitespace.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      71a17de3
  3. 06 Sep, 2016 4 commits