1. 01 Apr, 2018 28 commits
    • David S. Miller's avatar
      Merge tag 'rxrpc-next-20180330' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs · e2e80c02
      David S. Miller authored
      David Howells says:
      
      ====================
      rxrpc: Fixes and more traces
      
      Here are some patches that add some more tracepoints to AF_RXRPC and fix
      some issues therein:
      
       (1) Fix the use of VERSION packets to keep firewall routes open.
      
       (2) Fix the incorrect current time usage in a tracepoint.
      
       (3) Fix Tx ring annotation corruption.
      
       (4) Fix accidental conversion of call-level abort into connection-level
           abort.
      
       (5) Fix calculation of resend time.
      
       (6) Remove a couple of unused variables.
      
       (7) Fix a bunch of checker warnings and an error.  Note that not all
           warnings can be quashed as checker doesn't seem to correctly handle
           seqlocks.
      
       (8) Fix a potential race between call destruction and socket/net
           destruction.
      
       (9) Add a tracepoint to track rxrpc_local refcounting.
      
      (10) Fix an apparent leak of rxrpc_local objects.
      
      (11) Add a tracepoint to track rxrpc_peer refcounting.
      
      (12) Fix a leak of rxrpc_peer objects.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e2e80c02
    • Haiyang Zhang's avatar
      hv_netvsc: Clean up extra parameter from rndis_filter_receive_data() · 3be9b5fd
      Haiyang Zhang authored
      The variables, msg and data, have the same value. This patch removes
      the extra one.
      Signed-off-by: default avatarHaiyang Zhang <haiyangz@microsoft.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3be9b5fd
    • Joe Perches's avatar
      ethernet: hisilicon: hns: hns_dsaf_mac: Use generic eth_broadcast_addr · 49b44aa2
      Joe Perches authored
      Rather than use an on-stack array to copy a broadcast address, use
      the generic eth_broadcast_addr function to save a trivial amount of
      object code.
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      49b44aa2
    • David S. Miller's avatar
      Merge branch 'net_rwsem-fixes' · b3834acd
      David S. Miller authored
      Kirill Tkhai says:
      
      ====================
      net_rwsem fixes
      
      there is wext_netdev_notifier_call()->wireless_nlevent_flush()
      netdevice notifier, which takes net_rwsem, so we can't take
      net_rwsem in {,un}register_netdevice_notifier().
      
      Since {,un}register_netdevice_notifier() is executed under
      pernet_ops_rwsem, net_namespace_list can't change, while we
      holding it, so there is no need net_rwsem in these functions [1/2].
      
      The same is in [2/2]. We make callers of __rtnl_link_unregister()
      take pernet_ops_rwsem, and close the race with setup_net()
      and cleanup_net(), so __rtnl_link_unregister() does not need it.
      This also fixes the problem of that __rtnl_link_unregister() does
      not see initializing and exiting nets.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b3834acd
    • Kirill Tkhai's avatar
      net: Do not take net_rwsem in __rtnl_link_unregister() · 554873e5
      Kirill Tkhai authored
      This function calls call_netdevice_notifier(), which also
      may take net_rwsem. So, we can't use net_rwsem here.
      
      This patch makes callers of this functions take pernet_ops_rwsem,
      like register_netdevice_notifier() does. This will protect
      the modifications of net_namespace_list, and allows notifiers
      to take it (they won't have to care about context).
      
      Since __rtnl_link_unregister() is used on module load
      and unload (which are not frequent operations), this looks
      for me better, than make all call_netdevice_notifier()
      always executing in "protected net_namespace_list" context.
      
      Also, this fixes the problem we had a deal in 328fbe74
      "Close race between {un, }register_netdevice_notifier and ...",
      and guarantees __rtnl_link_unregister() does not skip
      exitting net.
      Signed-off-by: default avatarKirill Tkhai <ktkhai@virtuozzo.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      554873e5
    • Kirill Tkhai's avatar
      net: Remove net_rwsem from {, un}register_netdevice_notifier() · fc1dd369
      Kirill Tkhai authored
      These functions take net_rwsem, while wireless_nlevent_flush()
      also takes it. But down_read() can't be taken recursive,
      because of rw_semaphore design, which prevents it to be occupied
      by only readers forever.
      
      Since we take pernet_ops_rwsem in {,un}register_netdevice_notifier(),
      net list can't change, so these down_read()/up_read() can be removed.
      
      Fixes: f0b07bb1 "net: Introduce net_rwsem to protect net_namespace_list"
      Signed-off-by: default avatarKirill Tkhai <ktkhai@virtuozzo.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      fc1dd369
    • Wei Yongjun's avatar
      net: hns3: remove unnecessary pci_set_drvdata() and devm_kfree() · c679f6a2
      Wei Yongjun authored
      There is no need for explicit calls of devm_kfree(), as the allocated
      memory will be freed during driver's detach.
      
      The driver core clears the driver data to NULL after device_release.
      Thus, it is not needed to manually clear the device driver data to NULL.
      
      So remove the unnecessary pci_set_drvdata() and devm_kfree().
      Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c679f6a2
    • David Ahern's avatar
      netdevsim: Change nsim_devlink_setup to return error to caller · ef817102
      David Ahern authored
      Change nsim_devlink_setup to return any error back to the caller and
      update nsim_init to handle it.
      Requested-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: default avatarDavid Ahern <dsa@cumulusnetworks.com>
      Acked-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ef817102
    • David S. Miller's avatar
      Merge branch 'tipc-slim-down-name-table' · 6851cf28
      David S. Miller authored
      Jon Maloy says:
      
      ====================
      tipc: slim down name table
      
      We clean up and improve the name binding table:
      
       - Replace the memory consuming 'sub_sequence/service range' array with
         an RB tree.
       - Introduce support for overlapping service sequences/ranges
      
       v2: #1: Fixed a missing initialization reported by David Miller
           #4: Obsoleted and replaced a few more macros to get a consistent
               terminology in the API.
           #5: Added new commit to fix a potential string overflow bug (it
               is still only in net-next) reported by Arnd Bergmann
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6851cf28
    • Jon Maloy's avatar
      tipc: avoid possible string overflow · 7494cfa6
      Jon Maloy authored
      gcc points out that the combined length of the fixed-length inputs to
      l->name is larger than the destination buffer size:
      
      net/tipc/link.c: In function 'tipc_link_create':
      net/tipc/link.c:465:26: error: '%s' directive writing up to 32 bytes
      into a region of size between 26 and 58 [-Werror=format-overflow=]
      sprintf(l->name, "%s:%s-%s:unknown", self_str, if_name, peer_str);
      
      net/tipc/link.c:465:2: note: 'sprintf' output 11 or more bytes
      (assuming 75) into a destination of size 60
      sprintf(l->name, "%s:%s-%s:unknown", self_str, if_name, peer_str);
      
      A detailed analysis reveals that the theoretical maximum length of
      a link name is:
      max self_str + 1 + max if_name + 1 + max peer_str + 1 + max if_name =
      16 + 1 + 15 + 1 + 16 + 1 + 15 = 65
      Since we also need space for a trailing zero we now set MAX_LINK_NAME
      to 68.
      
      Just to be on the safe side we also replace the sprintf() call with
      snprintf().
      
      Fixes: 25b0b9c4 ("tipc: handle collisions of 32-bit node address
      hash values")
      Reported-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarJon Maloy <jon.maloy@ericsson.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7494cfa6
    • Jon Maloy's avatar
      tipc: tipc: rename address types in user api · 7a74d39c
      Jon Maloy authored
      The three address type structs in the user API have names that in
      reality reflect the specific, non-Linux environment where they were
      originally created.
      
      We now give them more intuitive names, in accordance with how TIPC is
      described in the current documentation.
      
      struct tipc_portid   -> struct tipc_socket_addr
      struct tipc_name     -> struct tipc_service_addr
      struct tipc_name_seq -> struct tipc_service_range
      
      To avoid confusion, we also update some commmets and macro names to
       match the new terminology.
      
      For compatibility, we add macros that map all old names to the new ones.
      Signed-off-by: default avatarJon Maloy <jon.maloy@ericsson.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7a74d39c
    • Jon Maloy's avatar
      tipc: permit overlapping service ranges in name table · 37922ea4
      Jon Maloy authored
      With the new RB tree structure for service ranges it becomes possible to
      solve an old problem; - we can now allow overlapping service ranges in
      the table.
      
      When inserting a new service range to the tree, we use 'lower' as primary
      key, and when necessary 'upper' as secondary key.
      
      Since there may now be multiple service ranges matching an indicated
      'lower' value, we must also add the 'upper' value to the functions
      used for removing publications, so that the correct, corresponding
      range item can be found.
      
      These changes guarantee that a well-formed publication/withdrawal item
      from a peer node never will be rejected, and make it possible to
      eliminate the problematic backlog functionality we currently have for
      handling such cases.
      Signed-off-by: default avatarJon Maloy <jon.maloy@ericsson.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      37922ea4
    • Jon Maloy's avatar
      tipc: refactor name table translate function · f20889f7
      Jon Maloy authored
      The function tipc_nametbl_translate() function is ugly and hard to
      follow. This can be improved somewhat by introducing a stack variable
      for holding the publication list to be used and re-ordering the if-
      clauses for selection of algorithm.
      Signed-off-by: default avatarJon Maloy <jon.maloy@ericsson.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f20889f7
    • Jon Maloy's avatar
      tipc: replace name table service range array with rb tree · 218527fe
      Jon Maloy authored
      The current design of the binding table has an unnecessary memory
      consuming and complex data structure. It aggregates the service range
      items into an array, which is expanded by a factor two every time it
      becomes too small to hold a new item. Furthermore, the arrays never
      shrink when the number of ranges diminishes.
      
      We now replace this array with an RB tree that is holding the range
      items as tree nodes, each range directly holding a list of bindings.
      
      This, along with a few name changes, improves both readability and
      volume of the code, as well as reducing memory consumption and hopefully
      improving cache hit rate.
      Signed-off-by: default avatarJon Maloy <jon.maloy@ericsson.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      218527fe
    • David S. Miller's avatar
      Merge branch 'bridge-mtu' · 24197ee2
      David S. Miller authored
      Nikolay Aleksandrov says:
      
      ====================
      net: bridge: MTU handling changes
      
      As previously discussed the recent changes break some setups and could lead
      to packet drops. Thus the first patch reverts the behaviour for the bridge
      to follow the minimum MTU but also keeps the ability to set the MTU to the
      maximum (out of all ports) if vlan filtering is enabled. Patch 02 is the
      bigger change in behaviour - we've always had trouble when configuring
      bridges and their MTU which is auto tuning on port events
      (add/del/changemtu), which means config software needs to chase it and fix
      it after each such event, after patch 02 we allow the user to configure any
      MTU (ETH_MIN/MAX limited) but once that is done the bridge stops auto
      tuning and relies on the user to keep the MTU correct.
      This should be compatible with cases that don't touch the MTU (or set it
      to the same value), while allowing to configure the MTU and not worry
      about it changing afterwards.
      
      The patches are intentionally split like this, so that if they get accepted
      and there are any complaints patch 02 can be reverted.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      24197ee2
    • Nikolay Aleksandrov's avatar
      net: bridge: disable bridge MTU auto tuning if it was set manually · 804b854d
      Nikolay Aleksandrov authored
      As Roopa noted today the biggest source of problems when configuring
      bridge and ports is that the bridge MTU keeps changing automatically on
      port events (add/del/changemtu). That leads to inconsistent behaviour
      and network config software needs to chase the MTU and fix it on each
      such event. Let's improve on that situation and allow for the user to
      set any MTU within ETH_MIN/MAX limits, but once manually configured it
      is the user's responsibility to keep it correct afterwards.
      
      In case the MTU isn't manually set - the behaviour reverts to the
      previous and the bridge follows the minimum MTU.
      Signed-off-by: default avatarNikolay Aleksandrov <nikolay@cumulusnetworks.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      804b854d
    • Nikolay Aleksandrov's avatar
      net: bridge: set min MTU on port events and allow user to set max · f40aa233
      Nikolay Aleksandrov authored
      Recently the bridge was changed to automatically set maximum MTU on port
      events (add/del/changemtu) when vlan filtering is enabled, but that
      actually changes behaviour in a way which breaks some setups and can lead
      to packet drops. In order to still allow that maximum to be set while being
      compatible, we add the ability for the user to tune the bridge MTU up to
      the maximum when vlan filtering is enabled, but that has to be done
      explicitly and all port events (add/del/changemtu) lead to resetting that
      MTU to the minimum as before.
      Suggested-by: default avatarRoopa Prabhu <roopa@cumulusnetworks.com>
      Signed-off-by: default avatarNikolay Aleksandrov <nikolay@cumulusnetworks.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f40aa233
    • David S. Miller's avatar
      Merge branch 'thunderx-DMAC-filtering' · 56c03cbf
      David S. Miller authored
      Vadim Lomovtsev says:
      
      ====================
      net: thunderx: implement DMAC filtering support
      
      By default CN88XX BGX accepts all incoming multicast and broadcast
      packets and filtering is disabled. The nic driver doesn't provide
      an ability to change such behaviour.
      
      This series is to implement DMAC filtering management for CN88XX
      nic driver allowing user to enable/disable filtering and configure
      specific MAC addresses to filter traffic.
      
      Changes from v1:
      build issues:
       - update code in order to address compiler warnings;
      checkpatch.pl reported issues:
       - update code in order to fit 80 symbols length;
       - update commit descriptions in order to fit 80 symbols length;
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      56c03cbf
    • Vadim Lomovtsev's avatar
      net: thunderx: add ndo_set_rx_mode callback implementation for VF · 37c3347e
      Vadim Lomovtsev authored
      The ndo_set_rx_mode() is called from atomic context which causes
      messages response timeouts while VF to PF communication via MSIx.
      To get rid of that we're copy passed mc list, parse flags and queue
      handling of kernel request to ordered workqueue.
      Signed-off-by: default avatarVadim Lomovtsev <Vadim.Lomovtsev@cavium.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      37c3347e
    • Vadim Lomovtsev's avatar
      net: thunderx: add workqueue control structures for handle ndo_set_rx_mode request · 1b6d55f2
      Vadim Lomovtsev authored
      The kernel calls ndo_set_rx_mode() callback from atomic context which
      causes messaging timeouts between VF and PF (as they’re implemented via
      MSIx). So in order to handle ndo_set_rx_mode() we need to get rid of it.
      
      This commit implements necessary workqueue related structures to let VF
      queue kernel request processing in non-atomic context later.
      Signed-off-by: default avatarVadim Lomovtsev <Vadim.Lomovtsev@cavium.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1b6d55f2
    • Vadim Lomovtsev's avatar
      net: thunderx: add XCAST messages handlers for PF · aba4a263
      Vadim Lomovtsev authored
      This commit is to add message handling for ndo_set_rx_mode()
      callback at PF side.
      Signed-off-by: default avatarVadim Lomovtsev <Vadim.Lomovtsev@cavium.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      aba4a263
    • Vadim Lomovtsev's avatar
      net: thunderx: add new messages for handle ndo_set_rx_mode callback · 0b849f58
      Vadim Lomovtsev authored
      The kernel calls ndo_set_rx_mode() callback supplying it will all necessary
      info, such as device state flags, multicast mac addresses list and so on.
      Since we have only 128 bits to communicate with PF we need to initiate
      several requests to PF with small/short operation each based on input data.
      
      So this commit implements following PF messages codes along with new
      data structures for them:
      NIC_MBOX_MSG_RESET_XCAST to flush all filters configured for this
                                particular network interface (VF)
      NIC_MBOX_MSG_ADD_MCAST   to add new MAC address to DMAC filter registers
                                for this particular network interface (VF)
      NIC_MBOX_MSG_SET_XCAST   to apply filtering configuration to filter control
                                register
      Signed-off-by: default avatarVadim Lomovtsev <Vadim.Lomovtsev@cavium.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0b849f58
    • Vadim Lomovtsev's avatar
      net: thunderx: add multicast filter management support · ceb9ea21
      Vadim Lomovtsev authored
      The ThunderX NIC could be partitioned to up to 128 VFs and thus
      represented to system. Each VF is mapped to pair BGX:LMAC, and each of VF
      is configured by kernel individually. Eventually the bunch of VFs could be
      mapped onto same pair BGX:LMAC and thus could cause several multicast
      filtering configuration requests to LMAC with the same MAC addresses.
      
      This commit is to add ThunderX NIC BGX filtering manipulation routines.
      Signed-off-by: default avatarVadim Lomovtsev <Vadim.Lomovtsev@cavium.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ceb9ea21
    • Vadim Lomovtsev's avatar
      net: thunderx: add MAC address filter tracking for LMAC · 3a34ecfd
      Vadim Lomovtsev authored
      The ThunderX NIC has two Ethernet Interfaces (BGX) each of them could has
      up to four Logical MACs configured. Each of BGX has 32 filters to be
      configured for filtering ingress packets. The number of filters available
      to particular LMAC is from 8 (if we have four LMACs configured per BGX)
      up to 32 (in case of only one LMAC is configured per BGX).
      
      At the same time the NIC could present up to 128 VFs to OS as network
      interfaces, each of them kernel will configure with set of MAC addresses
      for filtering. So to prevent dupes in BGX filter registers from different
      network interfaces it is required to cache and track all filter
      configuration requests prior to applying them onto BGX filter registers.
      
      This commit is to update LMAC structures with control fields to
      allocate/releasing filters tracking list along with implementing
      dmac array allocate/release per LMAC.
      Signed-off-by: default avatarVadim Lomovtsev <Vadim.Lomovtsev@cavium.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3a34ecfd
    • Vadim Lomovtsev's avatar
      net: thunderx: move filter register related macro into proper place · f8ad1f3f
      Vadim Lomovtsev authored
      The ThunderX NIC has set of registers which allows to configure
      filter policy for ingress packets. There are three possible regimes
      of filtering multicasts, broadcasts and unicasts: accept all, reject all
      and accept filter allowed only.
      
      Current implementation has enum with all of them and two generic macro
      for enabling filtering et all (CAM_ACCEPT) and enabling/disabling
      broadcast packets, which also should be corrected in order to represent
      register bits properly. All these values are private for driver and
      there is no need to ‘publish’ them via header file.
      
      This commit is to move filtering register manipulation values from
      header file into source with explicit assignment of exact register
      values to them to be used while register configuring.
      Signed-off-by: default avatarVadim Lomovtsev <Vadim.Lomovtsev@cavium.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f8ad1f3f
    • David S. Miller's avatar
      Merge branch 'meson8b' · 5e8b270f
      David S. Miller authored
      Martin Blumenstingl says:
      
      ====================
      Meson8m2 support for dwmac-meson8b
      
      The Meson8m2 SoC is an updated version of the Meson8 SoC. Some of the
      peripherals are shared with Meson8b (for example the watchdog registers
      and the internal temperature sensor calibration procedure).
      Meson8m2 also seems to include the same Gigabit MAC register layout as
      Meson8b.
      
      The registers in the Amlogic dwmac "glue" seem identical between Meson8b
      and Meson8m2. Manual testing seems to confirm this.
      
      To be extra-safe a new compatible string is added because there's no
      (public) documentation on the Meson8m2 SoC. This will allow us to
      implement any SoC-specific variations later on (if needed).
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5e8b270f
    • Martin Blumenstingl's avatar
      net: stmmac: dwmac-meson8b: Add support for the Meson8m2 SoC · 7676693c
      Martin Blumenstingl authored
      The Meson8m2 SoC uses a similar (potentially even identical) register
      layout as the Meson8b and GXBB SoCs for the dwmac glue.
      Add a new compatible string and update the module description to
      indicate support for these SoCs.
      Signed-off-by: default avatarMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7676693c
    • Martin Blumenstingl's avatar
      dt-bindings: net: meson-dwmac: add support for the Meson8m2 SoC · a5af1fb9
      Martin Blumenstingl authored
      The Meson8m2 SoC uses a similar (potentially even identical) register
      layout for the dwmac glue as Meson8b and GXBB. Unfortunately there is no
      documentation available.
      Testing shows that both, RMII and RGMII PHYs are working if they are
      configured as on Meson8b. Add a new compatible string to the
      documentation so differences (if there are any) between Meson8m2 and the
      other SoCs can be taken care of within the driver.
      Signed-off-by: default avatarMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a5af1fb9
  2. 30 Mar, 2018 12 commits
    • David Howells's avatar
      rxrpc: Fix leak of rxrpc_peer objects · 17226f12
      David Howells authored
      When a new client call is requested, an rxrpc_conn_parameters struct object
      is passed in with a bunch of parameters set, such as the local endpoint to
      use.  A pointer to the target peer record is also placed in there by
      rxrpc_get_client_conn() - and this is removed if and only if a new
      connection object is allocated.  Thus it leaks if a new connection object
      isn't allocated.
      
      Fix this by putting any peer object attached to the rxrpc_conn_parameters
      object in the function that allocated it.
      
      Fixes: 19ffa01c ("rxrpc: Use structs to hold connection params and protocol info")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      17226f12
    • David Howells's avatar
      rxrpc: Add a tracepoint to track rxrpc_peer refcounting · 1159d4b4
      David Howells authored
      Add a tracepoint to track reference counting on the rxrpc_peer struct.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      1159d4b4
    • David Howells's avatar
      rxrpc: Fix apparent leak of rxrpc_local objects · 31f5f9a1
      David Howells authored
      rxrpc_local objects cannot be disposed of until all the connections that
      point to them have been RCU'd as a connection object holds refcount on the
      local endpoint it is communicating through.  Currently, this can cause an
      assertion failure to occur when a network namespace is destroyed as there's
      no check that the RCU destructors for the connections have been run before
      we start trying to destroy local endpoints.
      
      The kernel reports:
      
      	rxrpc: AF_RXRPC: Leaked local 0000000036a41bc1 {5}
      	------------[ cut here ]------------
      	kernel BUG at ../net/rxrpc/local_object.c:439!
      
      Fix this by keeping a count of the live connections and waiting for it to
      go to zero at the end of rxrpc_destroy_all_connections().
      
      Fixes: dee46364 ("rxrpc: Add RCU destruction for connections and calls")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      31f5f9a1
    • David Howells's avatar
      rxrpc: Add a tracepoint to track rxrpc_local refcounting · 09d2bf59
      David Howells authored
      Add a tracepoint to track reference counting on the rxrpc_local struct.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      09d2bf59
    • David Howells's avatar
      rxrpc: Fix potential call vs socket/net destruction race · d3be4d24
      David Howells authored
      rxrpc_call structs don't pin sockets or network namespaces, but may attempt
      to access both after their refcount reaches 0 so that they can detach
      themselves from the network namespace.  However, there's no guarantee that
      the socket still exists at this point (so sock_net(&call->socket->sk) may
      be invalid) and the namespace may have gone away if the call isn't pinning
      a peer.
      
      Fix this by (a) carrying a net pointer in the rxrpc_call struct and (b)
      waiting for all calls to be destroyed when the network namespace goes away.
      
      This was detected by checker:
      
      net/rxrpc/call_object.c:634:57: warning: incorrect type in argument 1 (different address spaces)
      net/rxrpc/call_object.c:634:57:    expected struct sock const *sk
      net/rxrpc/call_object.c:634:57:    got struct sock [noderef] <asn:4>*<noident>
      
      Fixes: 2baec2c3 ("rxrpc: Support network namespacing")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      d3be4d24
    • David Howells's avatar
      rxrpc: Fix checker warnings and errors · 88f2a825
      David Howells authored
      Fix various issues detected by checker.
      
      Errors:
      
       (*) rxrpc_discard_prealloc() should be using rcu_assign_pointer to set
           call->socket.
      
      Warnings:
      
       (*) rxrpc_service_connection_reaper() should be passing NULL rather than 0 to
           trace_rxrpc_conn() as the where argument.
      
       (*) rxrpc_disconnect_client_call() should get its net pointer via the
           call->conn rather than call->sock to avoid a warning about accessing
           an RCU pointer without protection.
      
       (*) Proc seq start/stop functions need annotation as they pass locks
           between the functions.
      
      False positives:
      
       (*) Checker doesn't correctly handle of seq-retry lock context balance in
           rxrpc_find_service_conn_rcu().
      
       (*) Checker thinks execution may proceed past the BUG() in
           rxrpc_publish_service_conn().
      
       (*) Variable length array warnings from SKCIPHER_REQUEST_ON_STACK() in
           rxkad.c.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      88f2a825
    • Sebastian Andrzej Siewior's avatar
      rxrpc: remove unused static variables · edb63e2b
      Sebastian Andrzej Siewior authored
      The rxrpc_security_methods and rxrpc_security_sem user has been removed
      in 648af7fc ("rxrpc: Absorb the rxkad security module"). This was
      noticed by kbuild test robot for the -RT tree but is also true for !RT.
      Reported-by: default avatarkbuild test robot <fengguang.wu@intel.com>
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      edb63e2b
    • Marc Dionne's avatar
      rxrpc: Fix resend event time calculation · 59299aa1
      Marc Dionne authored
      Commit a158bdd3 ("rxrpc: Fix call timeouts") reworked the time calculation
      for the next resend event.  For this calculation, "oldest" will be before
      "now", so ktime_sub(oldest, now) will yield a negative value.  When passed
      to nsecs_to_jiffies which expects an unsigned value, the end result will be
      a very large value, and a resend event scheduled far into the future.  This
      could cause calls to stall if some packets were lost.
      
      Fix by ordering the arguments to ktime_sub correctly.
      
      Fixes: a158bdd3 ("rxrpc: Fix call timeouts")
      Signed-off-by: default avatarMarc Dionne <marc.dionne@auristor.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      59299aa1
    • David Howells's avatar
      rxrpc: Don't treat call aborts as conn aborts · 57b0c9d4
      David Howells authored
      If a call-level abort is received for the previous call to complete on a
      connection channel, then that abort is queued for the connection processor
      to handle.  Unfortunately, the connection processor then assumes without
      checking that the abort is connection-level (ie. callNumber is 0) and
      distributes it over all active calls on that connection, thereby
      incorrectly aborting them.
      
      Fix this by discarding aborts aimed at a completed call.
      
      Further, discard all packets aimed at a call that's complete if there's
      currently an active call on a channel, since the DATA packets associated
      with the new call automatically terminate the old call.
      
      Fixes: 18bfeba5 ("rxrpc: Perform terminal call ACK/ABORT retransmission from conn processor")
      Reported-by: default avatarMarc Dionne <marc.dionne@auristor.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      57b0c9d4
    • David Howells's avatar
      rxrpc: Fix Tx ring annotation after initial Tx failure · 03877bf6
      David Howells authored
      rxrpc calls have a ring of packets that are awaiting ACK or retransmission
      and a parallel ring of annotations that tracks the state of those packets.
      If the initial transmission of a packet on the underlying UDP socket fails
      then the packet annotation is marked for resend - but the setting of this
      mark accidentally erases the last-packet mark also stored in the same
      annotation slot.  If this happens, a call won't switch out of the Tx phase
      when all the packets have been transmitted.
      
      Fix this by retaining the last-packet mark and only altering the packet
      state.
      
      Fixes: 248f219c ("rxrpc: Rewrite the data and ack handling code")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      03877bf6
    • David Howells's avatar
      rxrpc: Fix a bit of time confusion · f82eb88b
      David Howells authored
      The rxrpc_reduce_call_timer() function should be passed the 'current time'
      in jiffies, not the current ktime time.  It's confusing in rxrpc_resend
      because that has to deal with both.  Pass the correct current time in.
      
      Note that this only affects the trace produced and not the functioning of
      the code.
      
      Fixes: a158bdd3 ("rxrpc: Fix call timeouts")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      f82eb88b
    • David Howells's avatar
      rxrpc: Fix firewall route keepalive · ace45bec
      David Howells authored
      Fix the firewall route keepalive part of AF_RXRPC which is currently
      function incorrectly by replying to VERSION REPLY packets from the server
      with VERSION REQUEST packets.
      
      Instead, send VERSION REPLY packets to the peers of service connections to
      act as keep-alives 20s after the latest packet was transmitted to that
      peer.
      
      Also, just discard VERSION REPLY packets rather than replying to them.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      ace45bec