1. 10 7月, 2019 4 次提交
    • P
      net: flow_offload: add list handling functions · da3eeb90
      Pablo Neira Ayuso 提交于
      This patch adds the list handling functions for the flow block API:
      
      * flow_block_cb_lookup() allows drivers to look up for existing flow blocks.
      * flow_block_cb_add() adds a flow block to the per driver list to be registered
        by the core.
      * flow_block_cb_remove() to remove a flow block from the list of existing
        flow blocks per driver and to request the core to unregister this.
      
      The flow block API also annotates the netns this flow block belongs to.
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      da3eeb90
    • P
      net: flow_offload: rename TCF_BLOCK_BINDER_TYPE_* to FLOW_BLOCK_BINDER_TYPE_* · 32f8c409
      Pablo Neira Ayuso 提交于
      Rename from TCF_BLOCK_BINDER_TYPE_* to FLOW_BLOCK_BINDER_TYPE_* and
      remove temporary tcf_block_binder_type alias.
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      32f8c409
    • P
      net: flow_offload: rename TC_BLOCK_{UN}BIND to FLOW_BLOCK_{UN}BIND · 9c0e189e
      Pablo Neira Ayuso 提交于
      Rename from TC_BLOCK_{UN}BIND to FLOW_BLOCK_{UN}BIND and remove
      temporary tc_block_command alias.
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9c0e189e
    • P
      net/sched: Introduce action ct · b57dc7c1
      Paul Blakey 提交于
      Allow sending a packet to conntrack module for connection tracking.
      
      The packet will be marked with conntrack connection's state, and
      any metadata such as conntrack mark and label. This state metadata
      can later be matched against with tc classifers, for example with the
      flower classifier as below.
      
      In addition to committing new connections the user can optionally
      specific a zone to track within, set a mark/label and configure nat
      with an address range and port range.
      
      Usage is as follows:
      $ tc qdisc add dev ens1f0_0 ingress
      $ tc qdisc add dev ens1f0_1 ingress
      
      $ tc filter add dev ens1f0_0 ingress \
        prio 1 chain 0 proto ip \
        flower ip_proto tcp ct_state -trk \
        action ct zone 2 pipe \
        action goto chain 2
      $ tc filter add dev ens1f0_0 ingress \
        prio 1 chain 2 proto ip \
        flower ct_state +trk+new \
        action ct zone 2 commit mark 0xbb nat src addr 5.5.5.7 pipe \
        action mirred egress redirect dev ens1f0_1
      $ tc filter add dev ens1f0_0 ingress \
        prio 1 chain 2 proto ip \
        flower ct_zone 2 ct_mark 0xbb ct_state +trk+est \
        action ct nat pipe \
        action mirred egress redirect dev ens1f0_1
      
      $ tc filter add dev ens1f0_1 ingress \
        prio 1 chain 0 proto ip \
        flower ip_proto tcp ct_state -trk \
        action ct zone 2 pipe \
        action goto chain 1
      $ tc filter add dev ens1f0_1 ingress \
        prio 1 chain 1 proto ip \
        flower ct_zone 2 ct_mark 0xbb ct_state +trk+est \
        action ct nat pipe \
        action mirred egress redirect dev ens1f0_0
      Signed-off-by: NPaul Blakey <paulb@mellanox.com>
      Signed-off-by: NMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: NYossi Kuperman <yossiku@mellanox.com>
      Acked-by: NJiri Pirko <jiri@mellanox.com>
      
      Changelog:
      V5->V6:
      	Added CONFIG_NF_DEFRAG_IPV6 in handle fragments ipv6 case
      V4->V5:
      	Reordered nf_conntrack_put() in tcf_ct_skb_nfct_cached()
      V3->V4:
      	Added strict_start_type for act_ct policy
      V2->V3:
      	Fixed david's comments: Removed extra newline after rcu in tcf_ct_params , and indent of break in act_ct.c
      V1->V2:
      	Fixed parsing of ranges TCA_CT_NAT_IPV6_MAX as 'else' case overwritten ipv4 max
      	Refactored NAT_PORT_MIN_MAX range handling as well
      	Added ipv4/ipv6 defragmentation
      	Removed extra skb pull push of nw offset in exectute nat
      	Refactored tcf_ct_skb_network_trim after pull
      	Removed TCA_ACT_CT define
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b57dc7c1
  2. 31 5月, 2019 1 次提交
  3. 06 5月, 2019 2 次提交
  4. 28 4月, 2019 2 次提交
    • J
      netlink: make validation more configurable for future strictness · 8cb08174
      Johannes Berg 提交于
      We currently have two levels of strict validation:
      
       1) liberal (default)
           - undefined (type >= max) & NLA_UNSPEC attributes accepted
           - attribute length >= expected accepted
           - garbage at end of message accepted
       2) strict (opt-in)
           - NLA_UNSPEC attributes accepted
           - attribute length >= expected accepted
      
      Split out parsing strictness into four different options:
       * TRAILING     - check that there's no trailing data after parsing
                        attributes (in message or nested)
       * MAXTYPE      - reject attrs > max known type
       * UNSPEC       - reject attributes with NLA_UNSPEC policy entries
       * STRICT_ATTRS - strictly validate attribute size
      
      The default for future things should be *everything*.
      The current *_strict() is a combination of TRAILING and MAXTYPE,
      and is renamed to _deprecated_strict().
      The current regular parsing has none of this, and is renamed to
      *_parse_deprecated().
      
      Additionally it allows us to selectively set one of the new flags
      even on old policies. Notably, the UNSPEC flag could be useful in
      this case, since it can be arranged (by filling in the policy) to
      not be an incompatible userspace ABI change, but would then going
      forward prevent forgetting attribute entries. Similar can apply
      to the POLICY flag.
      
      We end up with the following renames:
       * nla_parse           -> nla_parse_deprecated
       * nla_parse_strict    -> nla_parse_deprecated_strict
       * nlmsg_parse         -> nlmsg_parse_deprecated
       * nlmsg_parse_strict  -> nlmsg_parse_deprecated_strict
       * nla_parse_nested    -> nla_parse_nested_deprecated
       * nla_validate_nested -> nla_validate_nested_deprecated
      
      Using spatch, of course:
          @@
          expression TB, MAX, HEAD, LEN, POL, EXT;
          @@
          -nla_parse(TB, MAX, HEAD, LEN, POL, EXT)
          +nla_parse_deprecated(TB, MAX, HEAD, LEN, POL, EXT)
      
          @@
          expression NLH, HDRLEN, TB, MAX, POL, EXT;
          @@
          -nlmsg_parse(NLH, HDRLEN, TB, MAX, POL, EXT)
          +nlmsg_parse_deprecated(NLH, HDRLEN, TB, MAX, POL, EXT)
      
          @@
          expression NLH, HDRLEN, TB, MAX, POL, EXT;
          @@
          -nlmsg_parse_strict(NLH, HDRLEN, TB, MAX, POL, EXT)
          +nlmsg_parse_deprecated_strict(NLH, HDRLEN, TB, MAX, POL, EXT)
      
          @@
          expression TB, MAX, NLA, POL, EXT;
          @@
          -nla_parse_nested(TB, MAX, NLA, POL, EXT)
          +nla_parse_nested_deprecated(TB, MAX, NLA, POL, EXT)
      
          @@
          expression START, MAX, POL, EXT;
          @@
          -nla_validate_nested(START, MAX, POL, EXT)
          +nla_validate_nested_deprecated(START, MAX, POL, EXT)
      
          @@
          expression NLH, HDRLEN, MAX, POL, EXT;
          @@
          -nlmsg_validate(NLH, HDRLEN, MAX, POL, EXT)
          +nlmsg_validate_deprecated(NLH, HDRLEN, MAX, POL, EXT)
      
      For this patch, don't actually add the strict, non-renamed versions
      yet so that it breaks compile if I get it wrong.
      
      Also, while at it, make nla_validate and nla_parse go down to a
      common __nla_validate_parse() function to avoid code duplication.
      
      Ultimately, this allows us to have very strict validation for every
      new caller of nla_parse()/nlmsg_parse() etc as re-introduced in the
      next patch, while existing things will continue to work as is.
      
      In effect then, this adds fully strict validation for any new command.
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      8cb08174
    • M
      netlink: make nla_nest_start() add NLA_F_NESTED flag · ae0be8de
      Michal Kubecek 提交于
      Even if the NLA_F_NESTED flag was introduced more than 11 years ago, most
      netlink based interfaces (including recently added ones) are still not
      setting it in kernel generated messages. Without the flag, message parsers
      not aware of attribute semantics (e.g. wireshark dissector or libmnl's
      mnl_nlmsg_fprintf()) cannot recognize nested attributes and won't display
      the structure of their contents.
      
      Unfortunately we cannot just add the flag everywhere as there may be
      userspace applications which check nlattr::nla_type directly rather than
      through a helper masking out the flags. Therefore the patch renames
      nla_nest_start() to nla_nest_start_noflag() and introduces nla_nest_start()
      as a wrapper adding NLA_F_NESTED. The calls which add NLA_F_NESTED manually
      are rewritten to use nla_nest_start().
      
      Except for changes in include/net/netlink.h, the patch was generated using
      this semantic patch:
      
      @@ expression E1, E2; @@
      -nla_nest_start(E1, E2)
      +nla_nest_start_noflag(E1, E2)
      
      @@ expression E1, E2; @@
      -nla_nest_start_noflag(E1, E2 | NLA_F_NESTED)
      +nla_nest_start(E1, E2)
      Signed-off-by: NMichal Kubecek <mkubecek@suse.cz>
      Acked-by: NJiri Pirko <jiri@mellanox.com>
      Acked-by: NDavid Ahern <dsahern@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ae0be8de
  5. 03 4月, 2019 1 次提交
    • V
      net: sched: don't set tunnel for decap action · 3eed5284
      Vlad Buslov 提交于
      Action tunnel_key doesn't have a metadata/tunnel for release(decap) action.
      Drivers do not dereference entry->tunnel pointer for that action type, so
      this behavior doesn't result in a crash at the moment. However, this needs
      to be corrected as a preparation for updating hardware offloads API to not
      rely on rtnl lock, for which flow_action code will copy the tunnel data to
      temporary buffer to prevent concurrent action overwrite from
      invalidating/freeing it.
      
      Fixes: 3a7b6861 ("cls_api: add translator to flow_action representation")
      Signed-off-by: NVlad Buslov <vladbu@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      3eed5284
  6. 22 3月, 2019 1 次提交
    • D
      net/sched: let actions use RCU to access 'goto_chain' · ee3bbfe8
      Davide Caratti 提交于
      use RCU when accessing the action chain, to avoid use after free in the
      traffic path when 'goto chain' is replaced on existing TC actions (see
      script below). Since the control action is read in the traffic path
      without holding the action spinlock, we need to explicitly ensure that
      a->goto_chain is not NULL before dereferencing (i.e it's not sufficient
      to rely on the value of TC_ACT_GOTO_CHAIN bits). Not doing so caused NULL
      dereferences in tcf_action_goto_chain_exec() when the following script:
      
       # tc chain add dev dd0 chain 42 ingress protocol ip flower \
       > ip_proto udp action pass index 4
       # tc filter add dev dd0 ingress protocol ip flower \
       > ip_proto udp action csum udp goto chain 42 index 66
       # tc chain del dev dd0 chain 42 ingress
       (start UDP traffic towards dd0)
       # tc action replace action csum udp pass index 66
      
      was run repeatedly for several hours.
      Suggested-by: NCong Wang <xiyou.wangcong@gmail.com>
      Suggested-by: NVlad Buslov <vladbu@mellanox.com>
      Signed-off-by: NDavide Caratti <dcaratti@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ee3bbfe8
  7. 14 3月, 2019 1 次提交
  8. 09 3月, 2019 1 次提交
    • V
      net: sched: fix potential use-after-free in __tcf_chain_put() · b62989fc
      Vlad Buslov 提交于
      When used with unlocked classifier that have filters attached to actions
      with goto chain, __tcf_chain_put() for last non action reference can race
      with calls to same function from action cleanup code that releases last
      action reference. In this case action cleanup handler could free the chain
      if it executes after all references to chain were released, but before all
      concurrent users finished using it. Modify __tcf_chain_put() to only access
      tcf_chain fields when holding block->lock. Remove local variables that were
      used to cache some tcf_chain fields and are no longer needed because their
      values can now be obtained directly from chain under block->lock
      protection.
      
      Fixes: 726d0612 ("net: sched: prevent insertion of new classifiers during chain flush")
      Signed-off-by: NVlad Buslov <vladbu@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b62989fc
  9. 27 2月, 2019 1 次提交
  10. 26 2月, 2019 2 次提交
  11. 23 2月, 2019 1 次提交
  12. 22 2月, 2019 1 次提交
  13. 14 2月, 2019 1 次提交
  14. 13 2月, 2019 16 次提交
  15. 07 2月, 2019 2 次提交
  16. 17 1月, 2019 1 次提交
  17. 15 12月, 2018 1 次提交
  18. 11 12月, 2018 1 次提交