1. 19 1月, 2019 1 次提交
    • C
      net_sched: add hit counter for matchall · f88c19aa
      Cong Wang 提交于
      Although matchall always matches packets, however, it still
      relies on a protocol match first. So it is still useful to have
      such a counter for matchall. Of course, unlike u32, every time
      we hit a matchall filter, it is always a success, so we don't
      have to distinguish them.
      
      Sample output:
      
      filter protocol 802.1Q pref 100 matchall chain 0
      filter protocol 802.1Q pref 100 matchall chain 0 handle 0x1
        not_in_hw (rule hit 10)
      	action order 1: vlan  pop continue
      	 index 1 ref 1 bind 1 installed 40 sec used 1 sec
      	Action statistics:
      	Sent 836 bytes 10 pkt (dropped 0, overlimits 0 requeues 0)
      	backlog 0b 0p requeues 0
      Reported-by: NMartin Olsson <martin.olsson+netdev@sentorsecurity.com>
      Cc: Jamal Hadi Salim <jhs@mojatatu.com>
      Cc: Jiri Pirko <jiri@resnulli.us>
      Signed-off-by: NCong Wang <xiyou.wangcong@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f88c19aa
  2. 16 11月, 2018 1 次提交
    • A
      net: sched: cls_flower: Classify packets using port ranges · 5c72299f
      Amritha Nambiar 提交于
      Added support in tc flower for filtering based on port ranges.
      
      Example:
      1. Match on a port range:
      -------------------------
      $ tc filter add dev enp4s0 protocol ip parent ffff:\
        prio 1 flower ip_proto tcp dst_port range 20-30 skip_hw\
        action drop
      
      $ tc -s filter show dev enp4s0 parent ffff:
      filter protocol ip pref 1 flower chain 0
      filter protocol ip pref 1 flower chain 0 handle 0x1
        eth_type ipv4
        ip_proto tcp
        dst_port range 20-30
        skip_hw
        not_in_hw
              action order 1: gact action drop
               random type none pass val 0
               index 1 ref 1 bind 1 installed 85 sec used 3 sec
              Action statistics:
              Sent 460 bytes 10 pkt (dropped 10, overlimits 0 requeues 0)
              backlog 0b 0p requeues 0
      
      2. Match on IP address and port range:
      --------------------------------------
      $ tc filter add dev enp4s0 protocol ip parent ffff:\
        prio 1 flower dst_ip 192.168.1.1 ip_proto tcp dst_port range 100-200\
        skip_hw action drop
      
      $ tc -s filter show dev enp4s0 parent ffff:
      filter protocol ip pref 1 flower chain 0 handle 0x2
        eth_type ipv4
        ip_proto tcp
        dst_ip 192.168.1.1
        dst_port range 100-200
        skip_hw
        not_in_hw
              action order 1: gact action drop
               random type none pass val 0
               index 2 ref 1 bind 1 installed 58 sec used 2 sec
              Action statistics:
              Sent 920 bytes 20 pkt (dropped 20, overlimits 0 requeues 0)
              backlog 0b 0p requeues 0
      
      v4:
      1. Added condition before setting port key.
      2. Organized setting and dumping port range keys into functions
         and added validation of input range.
      
      v3:
      1. Moved new fields in UAPI enum to the end of enum.
      2. Removed couple of empty lines.
      
      v2:
      Addressed Jiri's comments:
      1. Added separate functions for dst and src comparisons.
      2. Removed endpoint enum.
      3. Added new bit TCA_FLOWER_FLAGS_RANGE to decide normal/range
        lookup.
      4. Cleaned up fl_lookup function.
      Signed-off-by: NAmritha Nambiar <amritha.nambiar@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      5c72299f
  3. 11 9月, 2018 1 次提交
  4. 08 8月, 2018 1 次提交
    • P
      net/sched: allow flower to match tunnel options · 0a6e7778
      Pieter Jansen van Vuuren 提交于
      Allow matching on options in Geneve tunnel headers.
      This makes use of existing tunnel metadata support.
      
      The options can be described in the form
      CLASS:TYPE:DATA/CLASS_MASK:TYPE_MASK:DATA_MASK, where CLASS is
      represented as a 16bit hexadecimal value, TYPE as an 8bit
      hexadecimal value and DATA as a variable length hexadecimal value.
      
      e.g.
       # ip link add name geneve0 type geneve dstport 0 external
       # tc qdisc add dev geneve0 ingress
       # tc filter add dev geneve0 protocol ip parent ffff: \
           flower \
             enc_src_ip 10.0.99.192 \
             enc_dst_ip 10.0.99.193 \
             enc_key_id 11 \
             geneve_opts 0102:80:1122334421314151/ffff:ff:ffffffffffffffff \
             ip_proto udp \
             action mirred egress redirect dev eth1
      
      This patch adds support for matching Geneve options in the order
      supplied by the user. This leads to an efficient implementation in
      the software datapath (and in our opinion hardware datapaths that
      offload this feature). It is also compatible with Geneve options
      matching provided by the Open vSwitch kernel datapath which is
      relevant here as the Flower classifier may be used as a mechanism
      to program flows into hardware as a form of Open vSwitch datapath
      offload (sometimes referred to as OVS-TC). The netlink
      Kernel/Userspace API may be extended, for example by adding a flag,
      if other matching options are desired, for example matching given
      options in any order. This would require an implementation in the
      TC software datapath. And be done in a way that drivers that
      facilitate offload of the Flower classifier can reject or accept
      such flows based on hardware datapath capabilities.
      
      This approach was discussed and agreed on at Netconf 2017 in Seoul.
      Signed-off-by: NSimon Horman <simon.horman@netronome.com>
      Signed-off-by: NPieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
      Acked-by: NJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0a6e7778
  5. 31 7月, 2018 1 次提交
    • P
      net/sched: user-space can't set unknown tcfa_action values · 802bfb19
      Paolo Abeni 提交于
      Currently, when initializing an action, the user-space can specify
      and use arbitrary values for the tcfa_action field. If the value
      is unknown by the kernel, is implicitly threaded as TC_ACT_UNSPEC.
      
      This change explicitly checks for unknown values at action creation
      time, and explicitly convert them to TC_ACT_UNSPEC. No functional
      changes are introduced, but this will allow introducing tcfa_action
      values not exposed to user-space in a later patch.
      
      Note: we can't use the above to hide TC_ACT_REDIRECT from user-space,
      as the latter is already part of uAPI.
      
      v3 -> v4:
       - use an helper to check for action validity (JiriP)
       - emit an extack for invalid actions (JiriP)
      v4 -> v5:
       - keep messages on a single line, drop net_warn (Marcelo)
      Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
      Acked-by: NJiri Pirko <jiri@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      802bfb19
  6. 20 7月, 2018 1 次提交
  7. 07 7月, 2018 1 次提交
  8. 15 5月, 2018 1 次提交
    • M
      sched: cls: enable verbose logging · 81c7288b
      Marcelo Ricardo Leitner 提交于
      Currently, when the rule is not to be exclusively executed by the
      hardware, extack is not passed along and offloading failures don't
      get logged. The idea was that hardware failures are okay because the
      rule will get executed in software then and this way it doesn't confuse
      unware users.
      
      But this is not helpful in case one needs to understand why a certain
      rule failed to get offloaded. Considering it may have been a temporary
      failure, like resources exceeded or so, reproducing it later and knowing
      that it is triggering the same reason may be challenging.
      
      The ultimate goal is to improve Open vSwitch debuggability when using
      flower offloading.
      
      This patch adds a new flag to enable verbose logging. With the flag set,
      extack will be passed to the driver, which will be able to log the
      error. As the operation itself probably won't fail (not because of this,
      at least), current iproute will already log it as a Warning.
      
      The flag is generic, so it can be reused later. No need to restrict it
      just for HW offloading. The command line will follow the syntax that
      tc-ebpf already uses, tc ... [ verbose ] ... , and extend its meaning.
      
      For example:
      # ./tc qdisc add dev p7p1 ingress
      # ./tc filter add dev p7p1 parent ffff: protocol ip prio 1 \
      	flower verbose \
      	src_mac ed:13:db:00:00:00 dst_mac 01:80:c2:00:00:d0 \
      	src_ip 56.0.0.0 dst_ip 55.0.0.0 action drop
      Warning: TC offload is disabled on net device.
      # echo $?
      0
      # ./tc filter add dev p7p1 parent ffff: protocol ip prio 1 \
      	flower \
      	src_mac ff:13:db:00:00:00 dst_mac 01:80:c2:00:00:d0 \
      	src_ip 56.0.0.0 dst_ip 55.0.0.0 action drop
      # echo $?
      0
      Signed-off-by: NMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      81c7288b
  9. 09 3月, 2018 1 次提交
  10. 22 2月, 2018 1 次提交
    • E
      net: sched: add em_ipt ematch for calling xtables matches · ccc007e4
      Eyal Birger 提交于
      The commit a new tc ematch for using netfilter xtable matches.
      
      This allows early classification as well as mirroning/redirecting traffic
      based on logic implemented in netfilter extensions.
      
      Current supported use case is classification based on the incoming IPSec
      state used during decpsulation using the 'policy' iptables extension
      (xt_policy).
      
      The module dynamically fetches the netfilter match module and calls
      it using a fake xt_action_param structure based on validated userspace
      provided parameters.
      
      As the xt_policy match does not access skb->data, no skb modifications
      are needed on match.
      Signed-off-by: NEyal Birger <eyal.birger@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ccc007e4
  11. 02 11月, 2017 1 次提交
    • G
      License cleanup: add SPDX license identifier to uapi header files with no license · 6f52b16c
      Greg Kroah-Hartman 提交于
      Many user space API headers are missing licensing information, which
      makes it hard for compliance tools to determine the correct license.
      
      By default are files without license information under the default
      license of the kernel, which is GPLV2.  Marking them GPLV2 would exclude
      them from being included in non GPLV2 code, which is obviously not
      intended. The user space API headers fall under the syscall exception
      which is in the kernels COPYING file:
      
         NOTE! This copyright does *not* cover user programs that use kernel
         services by normal system calls - this is merely considered normal use
         of the kernel, and does *not* fall under the heading of "derived work".
      
      otherwise syscall usage would not be possible.
      
      Update the files which contain no license information with an SPDX
      license identifier.  The chosen identifier is 'GPL-2.0 WITH
      Linux-syscall-note' which is the officially assigned identifier for the
      Linux syscall exception.  SPDX license identifiers are a legally binding
      shorthand, which can be used instead of the full boiler plate text.
      
      This patch is based on work done by Thomas Gleixner and Kate Stewart and
      Philippe Ombredanne.  See the previous patch in this series for the
      methodology of how this patch was researched.
      Reviewed-by: NKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: NPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6f52b16c
  12. 22 6月, 2017 1 次提交
  13. 07 6月, 2017 1 次提交
  14. 05 6月, 2017 1 次提交
  15. 25 5月, 2017 1 次提交
  16. 18 5月, 2017 1 次提交
  17. 03 5月, 2017 1 次提交
  18. 25 4月, 2017 1 次提交
  19. 18 2月, 2017 1 次提交
  20. 26 1月, 2017 1 次提交
    • J
      net sched actions: Add support for user cookies · 1045ba77
      Jamal Hadi Salim 提交于
      Introduce optional 128-bit action cookie.
      Like all other cookie schemes in the networking world (eg in protocols
      like http or existing kernel fib protocol field, etc) the idea is to save
      user state that when retrieved serves as a correlator. The kernel
      _should not_ intepret it.  The user can store whatever they wish in the
      128 bits.
      
      Sample exercise(showing variable length use of cookie)
      
      .. create an accept action with cookie a1b2c3d4
      sudo $TC actions add action ok index 1 cookie a1b2c3d4
      
      .. dump all gact actions..
      sudo $TC -s actions ls action gact
      
          action order 0: gact action pass
           random type none pass val 0
           index 1 ref 1 bind 0 installed 5 sec used 5 sec
          Action statistics:
          Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
          backlog 0b 0p requeues 0
          cookie a1b2c3d4
      
      .. bind the accept action to a filter..
      sudo $TC filter add dev lo parent ffff: protocol ip prio 1 \
      u32 match ip dst 127.0.0.1/32 flowid 1:1 action gact index 1
      
      ... send some traffic..
      $ ping 127.0.0.1 -c 3
      PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
      64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.020 ms
      64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.027 ms
      64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.038 ms
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1045ba77
  21. 17 1月, 2017 1 次提交
    • D
      bpf: rework prog_digest into prog_tag · f1f7714e
      Daniel Borkmann 提交于
      Commit 7bd509e3 ("bpf: add prog_digest and expose it via
      fdinfo/netlink") was recently discussed, partially due to
      admittedly suboptimal name of "prog_digest" in combination
      with sha1 hash usage, thus inevitably and rightfully concerns
      about its security in terms of collision resistance were
      raised with regards to use-cases.
      
      The intended use cases are for debugging resp. introspection
      only for providing a stable "tag" over the instruction sequence
      that both kernel and user space can calculate independently.
      It's not usable at all for making a security relevant decision.
      So collisions where two different instruction sequences generate
      the same tag can happen, but ideally at a rather low rate. The
      "tag" will be dumped in hex and is short enough to introspect
      in tracepoints or kallsyms output along with other data such
      as stack trace, etc. Thus, this patch performs a rename into
      prog_tag and truncates the tag to a short output (64 bits) to
      make it obvious it's not collision-free.
      
      Should in future a hash or facility be needed with a security
      relevant focus, then we can think about requirements, constraints,
      etc that would fit to that situation. For now, rework the exposed
      parts for the current use cases as long as nothing has been
      released yet. Tested on x86_64 and s390x.
      
      Fixes: 7bd509e3 ("bpf: add prog_digest and expose it via fdinfo/netlink")
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NAlexei Starovoitov <ast@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f1f7714e
  22. 12 1月, 2017 1 次提交
  23. 09 1月, 2017 5 次提交
    • W
      net-tc: convert tc_from to tc_from_ingress and tc_redirected · bc31c905
      Willem de Bruijn 提交于
      The tc_from field fulfills two roles. It encodes whether a packet was
      redirected by an act_mirred device and, if so, whether act_mirred was
      called on ingress or egress. Split it into separate fields.
      
      The information is needed by the special IFB loop, where packets are
      taken out of the normal path by act_mirred, forwarded to IFB, then
      reinjected at their original location (ingress or egress) by IFB.
      
      The IFB device cannot use skb->tc_at_ingress, because that may have
      been overwritten as the packet travels from act_mirred to ifb_xmit,
      when it passes through tc_classify on the IFB egress path. Cache this
      value in skb->tc_from_ingress.
      
      That field is valid only if a packet arriving at ifb_xmit came from
      act_mirred. Other packets can be crafted to reach ifb_xmit. These
      must be dropped. Set tc_redirected on redirection and drop all packets
      that do not have this bit set.
      
      Both fields are set only on cloned skbs in tc actions, so original
      packet sources do not have to clear the bit when reusing packets
      (notably, pktgen and octeon).
      Signed-off-by: NWillem de Bruijn <willemb@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      bc31c905
    • W
      net-tc: convert tc_verd to integer bitfields · a5135bcf
      Willem de Bruijn 提交于
      Extract the remaining two fields from tc_verd and remove the __u16
      completely. TC_AT and TC_FROM are converted to equivalent two-bit
      integer fields tc_at and tc_from. Where possible, use existing
      helper skb_at_tc_ingress when reading tc_at. Introduce helper
      skb_reset_tc to clear fields.
      
      Not documenting tc_from and tc_at, because they will be replaced
      with single bit fields in follow-on patches.
      Signed-off-by: NWillem de Bruijn <willemb@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a5135bcf
    • W
      net-tc: extract skip classify bit from tc_verd · e7246e12
      Willem de Bruijn 提交于
      Packets sent by the IFB device skip subsequent tc classification.
      A single bit governs this state. Move it out of tc_verd in
      anticipation of removing that __u16 completely.
      
      The new bitfield tc_skip_classify temporarily uses one bit of a
      hole, until tc_verd is removed completely in a follow-up patch.
      
      Remove the bit hole comment. It could be 2, 3, 4 or 5 bits long.
      With that many options, little value in documenting it.
      
      Introduce a helper function to deduplicate the logic in the two
      sites that check this bit.
      
      The field tc_skip_classify is set only in IFB on skbs cloned in
      act_mirred, so original packet sources do not have to clear the
      bit when reusing packets (notably, pktgen and octeon).
      Signed-off-by: NWillem de Bruijn <willemb@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e7246e12
    • W
      net-tc: make MAX_RECLASSIFY_LOOP local · d6264071
      Willem de Bruijn 提交于
      This field is no longer kept in tc_verd. Remove it from the global
      definition of that struct.
      Signed-off-by: NWillem de Bruijn <willemb@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d6264071
    • W
      net-tc: remove unused tc_verd fields · aec745e2
      Willem de Bruijn 提交于
      Remove the last reference to tc_verd's munge and redirect ttl bits.
      These fields are no longer used.
      Signed-off-by: NWillem de Bruijn <willemb@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      aec745e2
  24. 09 12月, 2016 2 次提交
  25. 06 12月, 2016 1 次提交
    • D
      bpf: add prog_digest and expose it via fdinfo/netlink · 7bd509e3
      Daniel Borkmann 提交于
      When loading a BPF program via bpf(2), calculate the digest over
      the program's instruction stream and store it in struct bpf_prog's
      digest member. This is done at a point in time before any instructions
      are rewritten by the verifier. Any unstable map file descriptor
      number part of the imm field will be zeroed for the hash.
      
      fdinfo example output for progs:
      
        # cat /proc/1590/fdinfo/5
        pos:          0
        flags:        02000002
        mnt_id:       11
        prog_type:    1
        prog_jited:   1
        prog_digest:  b27e8b06da22707513aa97363dfb11c7c3675d28
        memlock:      4096
      
      When programs are pinned and retrieved by an ELF loader, the loader
      can check the program's digest through fdinfo and compare it against
      one that was generated over the ELF file's program section to see
      if the program needs to be reloaded. Furthermore, this can also be
      exposed through other means such as netlink in case of a tc cls/act
      dump (or xdp in future), but also through tracepoints or other
      facilities to identify the program. Other than that, the digest can
      also serve as a base name for the work in progress kallsyms support
      of programs. The digest doesn't depend/select the crypto layer, since
      we need to keep dependencies to a minimum. iproute2 will get support
      for this facility.
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7bd509e3
  26. 10 11月, 2016 1 次提交
  27. 04 11月, 2016 1 次提交
  28. 22 9月, 2016 1 次提交
  29. 16 9月, 2016 2 次提交
  30. 11 9月, 2016 1 次提交
    • A
      net/sched: cls_flower: Classify packet in ip tunnels · bc3103f1
      Amir Vadai 提交于
      Introduce classifying by metadata extracted by the tunnel device.
      Outer header fields - source/dest ip and tunnel id, are extracted from
      the metadata when classifying.
      
      For example, the following will add a filter on the ingress Qdisc of shared
      vxlan device named 'vxlan0'. To forward packets with outer src ip
      11.11.0.2, dst ip 11.11.0.1 and tunnel id 11. The packets will be
      forwarded to tap device 'vnet0' (after metadata is released):
      
      $ tc filter add dev vxlan0 protocol ip parent ffff: \
          flower \
            enc_src_ip 11.11.0.2 \
            enc_dst_ip 11.11.0.1 \
            enc_key_id 11 \
            dst_ip 11.11.11.1 \
          action tunnel_key release \
          action mirred egress redirect dev vnet0
      
      The action tunnel_key, will be introduced in the next patch in this
      series.
      Signed-off-by: NAmir Vadai <amir@vadai.me>
      Signed-off-by: NHadar Hen Zion <hadarh@mellanox.com>
      Acked-by: NJiri Pirko <jiri@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      bc3103f1
  31. 19 8月, 2016 1 次提交
  32. 25 7月, 2016 2 次提交
  33. 08 6月, 2016 1 次提交