1. 14 Feb, 2019 29 commits
  2. 13 Feb, 2019 3 commits
  3. 12 Feb, 2019 8 commits
    • Florian Fainelli's avatar
      rocker: Remove port_attr_bridge_flags_get assignment · bd3606c2
      Florian Fainelli authored
      After 610d2b60 ("rocker: Remove getting PORT_BRIDGE_FLAGS") we no
      longer have a port_attr_bridge_flags_get member in the rocker_world_ops
      structre, fix that.
      
      Fixes: 610d2b60 ("rocker: Remove getting PORT_BRIDGE_FLAGS")
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      bd3606c2
    • David S. Miller's avatar
      Merge branch 'classifier-no-rtnl' · ef718bc3
      David S. Miller authored
      Vlad Buslov says:
      
      ====================
      Refactor classifier API to work with chain/classifiers without rtnl lock
      
      Currently, all netlink protocol handlers for updating rules, actions and
      qdiscs are protected with single global rtnl lock which removes any
      possibility for parallelism. This patch set is a third step to remove
      rtnl lock dependency from TC rules update path.
      
      Recently, new rtnl registration flag RTNL_FLAG_DOIT_UNLOCKED was added.
      Handlers registered with this flag are called without RTNL taken. End
      goal is to have rule update handlers(RTM_NEWTFILTER, RTM_DELTFILTER,
      etc.) to be registered with UNLOCKED flag to allow parallel execution.
      However, there is no intention to completely remove or split rtnl lock
      itself. This patch set addresses specific problems in implementation of
      classifiers API that prevent its control path from being executed
      concurrently, and completes refactoring of cls API rules update handlers
      by removing rtnl lock dependency from code that handles chains and
      classifiers. Rules update handlers are registered with
      RTNL_FLAG_DOIT_UNLOCKED flag.
      
      This patch set substitutes global rtnl lock dependency on rules update
      path in cls API by extending its data structures with following locks:
      - tcf_block with 'lock' mutex. It is used to protect block state and
        life-time management fields of chains on the block (chain->refcnt,
        chain->action_refcnt, chain->explicitly crated, etc.).
      - tcf_chain with 'filter_chain_lock' mutex, that is used to protect list
        of classifier instances attached to chain. chain0->filter_chain_lock
        serializes calls to head change callbacks and allows them to rely on
        filter_chain_lock for serialization instead of rtnl lock.
      - tcf_proto with 'lock' spinlock that is intended to be used to
        synchronize access to classifiers that support unlocked execution.
      
      Classifiers are extended with reference counting to accommodate parallel
      access by unlocked cls API. Classifier ops structure is extended with
      additional 'put' function to allow reference counting of filters and
      intended to be used by classifiers that implement rtnl-unlocked API.
      Users of classifiers and individual filter instances are modified to
      always hold reference while working with them.
      
      Classifiers that support unlocked execution still need to know the
      status of rtnl lock, so their API is extended with additional
      'rtnl_held' argument that is used to indicate that caller holds rtnl
      lock. Cls API propagates rtnl lock status across its helper functions
      and passes it to classifier.
      
      Changes from V3 to V4:
      - Patch 1:
        - Extract code that manages chain 'explicitly_created' flag into
          standalone patch.
      - Patch 2 - new.
      
      Changes from V2 to V3:
      - Change block->lock and chain->filter_chain_lock type to mutex. This
        removes the need for async miniqp refactoring and allows calling
        sleeping functions while holding the block->lock and
        chain->filter_chain_lock locks.
      - Previous patch 1 - async miniqp is no longer needed, remove the patch.
      - Patch 1:
        - Change block->lock type to mutex.
        - Implement tcf_block_destroy() helper function that destroys
          block->lock mutex before deallocating the block.
        - Revert GFP_KERNEL->GFP_ATOMIC memory allocation flags of tcf_chain
          which is no longer needed after block->lock type change.
      - Patch 6:
        - Change chain->filter_chain_lock type to mutex.
        - Assume chain0->filter_chain_lock synchronizations instead of rtnl
          lock in mini_qdisc_pair_swap() function that is called from head
          change callback of ingress Qdisc. With filter_chain_lock type
          changed to mutex it is now possible to call sleeping function while
          holding it, so it is now used instead of async implementation from
          previous versions of this patch set.
      - Patch 7:
        - Add local tp_next var to tcf_chain_flush() and use it to store
          tp->next pointer dereferenced with rcu_dereference_protected() to
          satisfy kbuild test robot.
        - Reset tp pointer to NULL at the beginning of tc_new_tfilter() to
          prevent its uninitialized usage in error handling code. This code
          was already implemented in patch 10, but must be in patch 8 to
          preserve code bisectability.
        - Put parent chain in tcf_proto_destroy(). In previous version this
          code was implemented in patch 1 which was removed in V3.
      
      Changes from V1 to V2:
      - Patch 1:
        - Use smp_store_release() instead of xchg() for setting
          miniqp->tp_head.
        - Move Qdisc deallocation to tc_proto_wq ordered workqueue that is
          used to destroy tcf proto instances. This is necessary to ensure
          that Qdisc is destroyed after all instances of chain/proto that it
          contains in order to prevent use-after-free error in
          tc_chain_notify_delete().
        - Cache parent net device ifindex in block to prevent use-after-free
          of dev queue in tc_chain_notify_delete().
      - Patch 2:
        - Use lockdep_assert_held() instead of spin_is_locked() for assertion.
        - Use 'free_block' argument in tcf_chain_destroy() instead of checking
          block's reference count and chain_list for second time.
      - Patch 7:
        - Refactor tcf_chain0_head_change_cb_add() to not take block->lock and
          chain0->filter_chain_lock in correct order.
      - Patch 10:
        - Always set 'tp_created' flag when creating tp to prevent releasing
          the chain twice when tp with same priority was inserted
          concurrently.
      - Patch 11:
        - Add additional check to prevent creation of new proto instance when
          parent chain is being flushed to reduce CPU usage.
        - Don't call tcf_chain_delete_empty() if tp insertion failed.
      - Patch 16 - new.
      - Patch 17:
        - Refactor to only lock take rtnl lock once (at the beginning of rule
          update handlers).
        - Always release rtnl mutex in the same function that locked it.
          Remove unlock code from tcf_block_release().
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ef718bc3
    • Vlad Buslov's avatar
      net: sched: unlock rules update API · 470502de
      Vlad Buslov authored
      Register netlink protocol handlers for message types RTM_NEWTFILTER,
      RTM_DELTFILTER, RTM_GETTFILTER as unlocked. Set rtnl_held variable that
      tracks rtnl mutex state to be false by default.
      
      Introduce tcf_proto_is_unlocked() helper that is used to check
      tcf_proto_ops->flag to determine if ops can be called without taking rtnl
      lock. Manually lookup Qdisc, class and block in rule update handlers.
      Verify that both Qdisc ops and proto ops are unlocked before using any of
      their callbacks, and obtain rtnl lock otherwise.
      Signed-off-by: default avatarVlad Buslov <vladbu@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      470502de
    • Vlad Buslov's avatar
      net: sched: refactor tcf_block_find() into standalone functions · 18d3eefb
      Vlad Buslov authored
      Refactor tcf_block_find() code into three standalone functions:
      - __tcf_qdisc_find() to lookup Qdisc and increment its reference counter.
      - __tcf_qdisc_cl_find() to lookup class.
      - __tcf_block_find() to lookup block and increment its reference counter.
      
      This change is necessary to allow netlink tc rule update handlers to call
      these functions directly in order to conditionally take rtnl lock
      according to Qdisc class ops flags before calling any of class ops
      functions.
      Signed-off-by: default avatarVlad Buslov <vladbu@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      18d3eefb
    • Vlad Buslov's avatar
      net: sched: add flags to Qdisc class ops struct · dfcd2a2b
      Vlad Buslov authored
      Extend Qdisc_class_ops with flags. Create enum to hold possible class ops
      flag values. Add first class ops flags value QDISC_CLASS_OPS_DOIT_UNLOCKED
      to indicate that class ops functions can be called without taking rtnl
      lock.
      Signed-off-by: default avatarVlad Buslov <vladbu@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      dfcd2a2b
    • Vlad Buslov's avatar
      net: sched: extend proto ops to support unlocked classifiers · 12db03b6
      Vlad Buslov authored
      Add 'rtnl_held' flag to tcf proto change, delete, destroy, dump, walk
      functions to track rtnl lock status. Extend users of these function in cls
      API to propagate rtnl lock status to them. This allows classifiers to
      obtain rtnl lock when necessary and to pass rtnl lock status to extensions
      and driver offload callbacks.
      
      Add flags field to tcf proto ops. Add flag value to indicate that
      classifier doesn't require rtnl lock.
      Signed-off-by: default avatarVlad Buslov <vladbu@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      12db03b6
    • Vlad Buslov's avatar
      net: sched: extend proto ops with 'put' callback · 7d5509fa
      Vlad Buslov authored
      Add optional tp->ops->put() API to be implemented for filter reference
      counting. This new function is called by cls API to release filter
      reference for filters returned by tp->ops->change() or tp->ops->get()
      functions. Implement tfilter_put() helper to call tp->ops->put() only for
      classifiers that implement it.
      Signed-off-by: default avatarVlad Buslov <vladbu@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7d5509fa
    • Vlad Buslov's avatar
      net: sched: track rtnl lock status when validating extensions · ec6743a1
      Vlad Buslov authored
      Actions API is already updated to not rely on rtnl lock for
      synchronization. However, it need to be provided with rtnl status when
      called from classifiers API in order to be able to correctly release the
      lock when loading kernel module.
      
      Extend extension validation function with 'rtnl_held' flag which is passed
      to actions API. Add new 'rtnl_held' parameter to tcf_exts_validate() in cls
      API. No classifier is currently updated to support unlocked execution, so
      pass hardcoded 'true' flag parameter value.
      Signed-off-by: default avatarVlad Buslov <vladbu@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ec6743a1