Skip to content
  1. Jul 10, 2019
    • Paul Blakey's avatar
      net/sched: Introduce action ct · b57dc7c1
      Paul Blakey authored
      
      
      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: default avatarPaul Blakey <paulb@mellanox.com>
      Signed-off-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: default avatarYossi Kuperman <yossiku@mellanox.com>
      Acked-by: default avatarJiri 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: default avatarDavid S. Miller <davem@davemloft.net>
      b57dc7c1
    • David S. Miller's avatar
      Merge branch 'devlink-Introduce-PCI-PF-VF-ports-and-attributes' · f108c887
      David S. Miller authored
      Parav Pandit says:
      
      ====================
      devlink: Introduce PCI PF, VF ports and attributes
      
      This patchset carry forwards the work initiated in [1] and discussion
      futher concluded at [2].
      
      To improve visibility of representor netdevice, its association with
      PF or VF, physical port, two new devlink port flavours are added as
      PCI PF and PCI VF ports.
      
      A sample eswitch view can be seen below, which will be futher extended to
      mdev subdevices of a PCI function in future.
      
      Patch-1 moves physical port's attribute to new structure
      Patch-2 enhances netlink response to consider port flavour
      Patch-3,4 extends devlink port attributes and port flavour
      Patch-5 extends mlx5 driver to register devlink ports for PF, VF and
      physical link.
      
                                      +---+      +---+
                                    vf|   |      |   | pf
                                      +-+-+      +-+-+
      physical link <---------+         |          |
                              |         |          |
                              |         |          |
                            +-+-+     +-+-+      +-+-+
                            | 1 |     | 2 |      | 3 |
                         +--+---+-----+---+------+---+--+
                         |  physical   vf         pf    |
                         |  port       port       port  |
                         |                              |
                         |             eswitch          |
                         |                              |
                         +------------------------------+
      
      [1] https://www.spinics.net/lists/netdev/msg555797.html
      [2] https://marc.info/?l=linux-netdev&m=155354609408485&w=2
      
      
      
      Changelog:
      v5->v6:
       - Fixed port flavour check order for PCI PF vs other flavours in
         netlink response.
       - Changed 'physical' to 'phys'.
      v4->v5:
       - Split first patch to two patches to handle netlink response in
         separate patch.
       - Corrected typo 'otwerwise' to 'otherwise' in patches 3 and 4.
      v3->v4:
       - Addressed comments from Jiri.
       - Split first patch to two patches.
       - Renamed phys_port to physical to be consistent with pci_pf.
       - Removed port_number from __devlink_port_attrs_set and moved
         assignment to caller function.
       - Used capital letter while moving old comment to new structure.
       - Removed helper function is_devlink_phy_port_num_supported().
      v2->v3:
       - Made port_number and split_port_number applicable only to
         physical port flavours.
      v1->v2:
       - Updated new APIs and mlx5 driver to drop port_number for PF, VF
         attributes
       - Updated port_number comment for its usage
       - Limited putting port_number to physical ports
      ====================
      
      Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f108c887
    • Parav Pandit's avatar
      net/mlx5e: Register devlink ports for physical link, PCI PF, VFs · f60f315d
      Parav Pandit authored
      
      
      Register devlink port of physical port, PCI PF and PCI VF flavour
      for each PF, VF when a given devlink instance is in switchdev mode.
      
      Implement ndo_get_devlink_port callback API to make use of registered
      devlink ports.
      This eliminates ndo_get_phys_port_name() and ndo_get_port_parent_id()
      callbacks. Hence, remove them.
      
      An example output with 2 VFs, without a PF and single uplink port is
      below.
      
      $devlink port show
      pci/0000:06:00.0/65535: type eth netdev ens2f0 flavour physical
      pci/0000:05:00.0/1: type eth netdev eth1 flavour pcivf pfnum 0 vfnum 0
      pci/0000:05:00.0/2: type eth netdev eth2 flavour pcivf pfnum 0 vfnum 1
      
      Reviewed-by: default avatarRoi Dayan <roid@mellanox.com>
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f60f315d
    • Parav Pandit's avatar
      devlink: Introduce PCI VF port flavour and port attribute · e41b6bf3
      Parav Pandit authored
      
      
      In an eswitch, PCI VF may have port which is normally represented using
      a representor netdevice.
      To have better visibility of eswitch port, its association with VF,
      and its representor netdevice, introduce a PCI VF port flavour.
      
      When devlink port flavour is PCI VF, fill up PCI VF attributes of
      the port.
      
      Extend port name creation using PCI PF and VF number scheme on best
      effort basis, so that vendor drivers can skip defining their own scheme.
      
      $ devlink port show
      pci/0000:05:00.0/0: type eth netdev eth0 flavour pcipf pfnum 0
      pci/0000:05:00.0/1: type eth netdev eth1 flavour pcivf pfnum 0 vfnum 0
      pci/0000:05:00.0/2: type eth netdev eth2 flavour pcivf pfnum 0 vfnum 1
      
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e41b6bf3
    • Parav Pandit's avatar
      devlink: Introduce PCI PF port flavour and port attribute · 98fd2d65
      Parav Pandit authored
      
      
      In an eswitch, PCI PF may have port which is normally represented
      using a representor netdevice.
      To have better visibility of eswitch port, its association with
      PF and a representor netdevice, introduce a PCI PF port
      flavour and port attriute.
      
      When devlink port flavour is PCI PF, fill up PCI PF attributes of the
      port.
      
      Extend port name creation using PCI PF number on best effort basis.
      So that vendor drivers can skip defining their own scheme.
      
      $ devlink port show
      pci/0000:05:00.0/0: type eth netdev eth0 flavour pcipf pfnum 0
      
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      98fd2d65
    • Parav Pandit's avatar
      devlink: Return physical port fields only for applicable port flavours · a2c6b87d
      Parav Pandit authored
      
      
      Physical port number and split group fields are applicable only to
      physical port flavours such as PHYSICAL, CPU and DSA.
      Hence limit returning those values in netlink response to such port
      flavours.
      
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a2c6b87d
    • Parav Pandit's avatar
      devlink: Refactor physical port attributes · 378ef01b
      Parav Pandit authored
      
      
      To support additional devlink port flavours and to support few common
      and few different port attributes, move physical port attributes to a
      different structure.
      
      Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      378ef01b
  2. Jul 09, 2019