1. 31 10月, 2020 4 次提交
    • X
      sctp: allow changing transport encap_port by peer packets · a1dd2cf2
      Xin Long 提交于
      As rfc6951#section-5.4 says:
      
        "After finding the SCTP association (which
         includes checking the verification tag), the UDP source port MUST be
         stored as the encapsulation port for the destination address the SCTP
         packet is received from (see Section 5.1).
      
         When a non-encapsulated SCTP packet is received by the SCTP stack,
         the encapsulation of outgoing packets belonging to the same
         association and the corresponding destination address MUST be
         disabled."
      
      transport encap_port should be updated by a validated incoming packet's
      udp src port.
      
      We save the udp src port in sctp_input_cb->encap_port, and then update
      the transport in two places:
      
        1. right after vtag is verified, which is required by RFC, and this
           allows the existent transports to be updated by the chunks that
           can only be processed on an asoc.
      
        2. right before processing the 'init' where the transports are added,
           and this allows building a sctp over udp connection by client with
           the server not knowing the remote encap port.
      
        3. when processing ootb_pkt and creating the temporary transport for
           the reply pkt.
      
      Note that sctp_input_cb->header is removed, as it's not used any more
      in sctp.
      
      v1->v2:
        - Change encap_port as __be16 for sctp_input_cb.
      Signed-off-by: NXin Long <lucien.xin@gmail.com>
      Acked-by: NMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      a1dd2cf2
    • X
      sctp: add encap_port for netns sock asoc and transport · e8a3001c
      Xin Long 提交于
      encap_port is added as per netns/sock/assoc/transport, and the
      latter one's encap_port inherits the former one's by default.
      The transport's encap_port value would mostly decide if one
      packet should go out with udp encapsulated or not.
      
      This patch also allows users to set netns' encap_port by sysctl.
      
      v1->v2:
        - Change to define encap_port as __be16 for sctp_sock, asoc and
          transport.
      v2->v3:
        - No change.
      v3->v4:
        - Add 'encap_port' entry in ip-sysctl.rst.
      v4->v5:
        - Improve the description of encap_port in ip-sysctl.rst.
      Signed-off-by: NXin Long <lucien.xin@gmail.com>
      Acked-by: NMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      e8a3001c
    • X
      sctp: create udp6 sock and set its encap_rcv · 9d6ba260
      Xin Long 提交于
      This patch is to add the udp6 sock part in sctp_udp_sock_start/stop().
      udp_conf.use_udp6_rx_checksums is set to true, as:
      
         "The SCTP checksum MUST be computed for IPv4 and IPv6, and the UDP
          checksum SHOULD be computed for IPv4 and IPv6"
      
      says in rfc6951#section-5.3.
      
      v1->v2:
        - Add pr_err() when fails to create udp v6 sock.
        - Add #if IS_ENABLED(CONFIG_IPV6) not to create v6 sock when ipv6 is
          disabled.
      Signed-off-by: NXin Long <lucien.xin@gmail.com>
      Acked-by: NMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      9d6ba260
    • X
      sctp: create udp4 sock and add its encap_rcv · 965ae444
      Xin Long 提交于
      This patch is to add the functions to create/release udp4 sock,
      and set the sock's encap_rcv to process the incoming udp encap
      sctp packets. In sctp_udp_rcv(), as we can see, all we need to
      do is fix the transport header for sctp_rcv(), then it would
      implement the part of rfc6951#section-5.4:
      
        "When an encapsulated packet is received, the UDP header is removed.
         Then, the generic lookup is performed, as done by an SCTP stack
         whenever a packet is received, to find the association for the
         received SCTP packet"
      
      Note that these functions will be called in the last patch of
      this patchset when enabling this feature.
      
      v1->v2:
        - Add pr_err() when fails to create udp v4 sock.
      v2->v3:
        - Add 'select NET_UDP_TUNNEL' in sctp Kconfig.
      v3->v4:
        - No change.
      v4->v5:
        - Change to set udp_port to 0 by default.
      Signed-off-by: NXin Long <lucien.xin@gmail.com>
      Acked-by: NMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      965ae444
  2. 30 10月, 2020 1 次提交
  3. 20 10月, 2020 1 次提交
  4. 16 10月, 2020 1 次提交
    • L
      net: sched: Fix suspicious RCU usage while accessing tcf_tunnel_info · d086a1c6
      Leon Romanovsky 提交于
      The access of tcf_tunnel_info() produces the following splat, so fix it
      by dereferencing the tcf_tunnel_key_params pointer with marker that
      internal tcfa_liock is held.
      
       =============================
       WARNING: suspicious RCU usage
       5.9.0+ #1 Not tainted
       -----------------------------
       include/net/tc_act/tc_tunnel_key.h:59 suspicious rcu_dereference_protected() usage!
       other info that might help us debug this:
      
       rcu_scheduler_active = 2, debug_locks = 1
       1 lock held by tc/34839:
        #0: ffff88828572c2a0 (&p->tcfa_lock){+...}-{2:2}, at: tc_setup_flow_action+0xb3/0x48b5
       stack backtrace:
       CPU: 1 PID: 34839 Comm: tc Not tainted 5.9.0+ #1
       Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014
       Call Trace:
        dump_stack+0x9a/0xd0
        tc_setup_flow_action+0x14cb/0x48b5
        fl_hw_replace_filter+0x347/0x690 [cls_flower]
        fl_change+0x2bad/0x4875 [cls_flower]
        tc_new_tfilter+0xf6f/0x1ba0
        rtnetlink_rcv_msg+0x5f2/0x870
        netlink_rcv_skb+0x124/0x350
        netlink_unicast+0x433/0x700
        netlink_sendmsg+0x6f1/0xbd0
        sock_sendmsg+0xb0/0xe0
        ____sys_sendmsg+0x4fa/0x6d0
        ___sys_sendmsg+0x12e/0x1b0
        __sys_sendmsg+0xa4/0x120
        do_syscall_64+0x2d/0x40
        entry_SYSCALL_64_after_hwframe+0x44/0xa9
       RIP: 0033:0x7f1f8cd4fe57
       Code: 0c 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 2e 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 89 54 24 1c 48 89 74 24 10
       RSP: 002b:00007ffdc1e193b8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
       RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f1f8cd4fe57
       RDX: 0000000000000000 RSI: 00007ffdc1e19420 RDI: 0000000000000003
       RBP: 000000005f85aafa R08: 0000000000000001 R09: 00007ffdc1e1936c
       R10: 000000000040522d R11: 0000000000000246 R12: 0000000000000001
       R13: 0000000000000000 R14: 00007ffdc1e1d6f0 R15: 0000000000482420
      
      Fixes: 3ebaf6da ("net: sched: Do not assume RTNL is held in tunnel key action helpers")
      Fixes: 7a472814 ("net: sched: lock action when translating it to flow_action infra")
      Signed-off-by: NLeon Romanovsky <leonro@nvidia.com>
      Acked-by: NCong Wang <xiyou.wangcong@gmail.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      d086a1c6
  5. 15 10月, 2020 2 次提交
  6. 14 10月, 2020 1 次提交
    • P
      netfilter: nf_log: missing vlan offload tag and proto · 0d9826bc
      Pablo Neira Ayuso 提交于
      Dump vlan tag and proto for the usual vlan offload case if the
      NF_LOG_MACDECODE flag is set on. Without this information the logging is
      misleading as there is no reference to the VLAN header.
      
      [12716.993704] test: IN=veth0 OUT= MACSRC=86:6c:92:ea:d6:73 MACDST=0e:3b:eb:86:73:76 VPROTO=8100 VID=10 MACPROTO=0800 SRC=192.168.10.2 DST=172.217.168.163 LEN=52 TOS=0x00 PREC=0x00 TTL=64 ID=2548 DF PROTO=TCP SPT=55848 DPT=80 WINDOW=501 RES=0x00 ACK FIN URGP=0
      [12721.157643] test: IN=veth0 OUT= MACSRC=86:6c:92:ea:d6:73 MACDST=0e:3b:eb:86:73:76 VPROTO=8100 VID=10 MACPROTO=0806 ARP HTYPE=1 PTYPE=0x0800 OPCODE=2 MACSRC=86:6c:92:ea:d6:73 IPSRC=192.168.10.2 MACDST=0e:3b:eb:86:73:76 IPDST=192.168.10.1
      
      Fixes: 83e96d44 ("netfilter: log: split family specific code to nf_log_{ip,ip6,common}.c files")
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      0d9826bc
  7. 12 10月, 2020 2 次提交
  8. 10 10月, 2020 7 次提交
    • J
      netlink: export policy in extended ACK · 44f3625b
      Johannes Berg 提交于
      Add a new attribute NLMSGERR_ATTR_POLICY to the extended ACK
      to advertise the policy, e.g. if an attribute was out of range,
      you'll know the range that's permissible.
      
      Add new NL_SET_ERR_MSG_ATTR_POL() and NL_SET_ERR_MSG_ATTR_POL()
      macros to set this, since realistically it's only useful to do
      this when the bad attribute (offset) is also returned.
      
      Use it in lib/nlattr.c which practically does all the policy
      validation.
      
      v2:
       - add and use netlink_policy_dump_attr_size_estimate()
      v3:
       - remove redundant break
      v4:
       - really remove redundant break ... sorry
      Reviewed-by: NJakub Kicinski <kuba@kernel.org>
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      44f3625b
    • R
      net/tls: remove a duplicate function prototype · 923527dc
      Randy Dunlap 提交于
      Remove one of the two instances of the function prototype for
      tls_validate_xmit_skb().
      Signed-off-by: NRandy Dunlap <rdunlap@infradead.org>
      Cc: Boris Pismenny <borisp@nvidia.com>
      Cc: Aviad Yehezkel <aviadye@nvidia.com>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      923527dc
    • M
      devlink: Add enable_remote_dev_reset generic parameter · 195d9dec
      Moshe Shemesh 提交于
      The enable_remote_dev_reset devlink param flags that the host admin
      allows device resets that can be initiated by other hosts. This
      parameter is useful for setups where a device is shared by different
      hosts, such as multi-host setup. Once the user set this parameter to
      false, the driver should NACK any attempt to reset the device while the
      driver is loaded.
      Signed-off-by: NMoshe Shemesh <moshe@mellanox.com>
      Reviewed-by: NJiri Pirko <jiri@nvidia.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      195d9dec
    • M
      devlink: Add remote reload stats · 77069ba2
      Moshe Shemesh 提交于
      Add remote reload stats to hold the history of actions performed due
      devlink reload commands initiated by remote host. For example, in case
      firmware activation with reset finished successfully but was initiated
      by remote host.
      
      The function devlink_remote_reload_actions_performed() is exported to
      enable drivers update on remote reload actions performed as it was not
      initiated by their own devlink instance.
      
      Expose devlink remote reload stats to the user through devlink dev get
      command.
      
      Examples:
      $ devlink dev show
      pci/0000:82:00.0:
        stats:
            reload:
              driver_reinit 2 fw_activate 1 fw_activate_no_reset 0
            remote_reload:
              driver_reinit 0 fw_activate 0 fw_activate_no_reset 0
      pci/0000:82:00.1:
        stats:
            reload:
              driver_reinit 1 fw_activate 0 fw_activate_no_reset 0
            remote_reload:
              driver_reinit 1 fw_activate 1 fw_activate_no_reset 0
      
      $ devlink dev show -jp
      {
          "dev": {
              "pci/0000:82:00.0": {
                  "stats": {
                      "reload": {
                          "driver_reinit": 2,
                          "fw_activate": 1,
                          "fw_activate_no_reset": 0
                      },
                      "remote_reload": {
                          "driver_reinit": 0,
                          "fw_activate": 0,
                          "fw_activate_no_reset": 0
                      }
                  }
              },
              "pci/0000:82:00.1": {
                  "stats": {
                      "reload": {
                          "driver_reinit": 1,
                          "fw_activate": 0,
                          "fw_activate_no_reset": 0
                      },
                      "remote_reload": {
                          "driver_reinit": 1,
                          "fw_activate": 1,
                          "fw_activate_no_reset": 0
                      }
                  }
              }
          }
      }
      Signed-off-by: NMoshe Shemesh <moshe@mellanox.com>
      Reviewed-by: NJakub Kicinski <kuba@kernel.org>
      Reviewed-by: NJiri Pirko <jiri@nvidia.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      77069ba2
    • M
      devlink: Add reload stats · a254c264
      Moshe Shemesh 提交于
      Add reload stats to hold the history per reload action type and limit.
      
      For example, the number of times fw_activate has been performed on this
      device since the driver module was added or if the firmware activation
      was performed with or without reset.
      
      Add devlink notification on stats update.
      
      Expose devlink reload stats to the user through devlink dev get command.
      
      Examples:
      $ devlink dev show
      pci/0000:82:00.0:
        stats:
            reload:
              driver_reinit 2 fw_activate 1 fw_activate_no_reset 0
      pci/0000:82:00.1:
        stats:
            reload:
              driver_reinit 1 fw_activate 0 fw_activate_no_reset 0
      
      $ devlink dev show -jp
      {
          "dev": {
              "pci/0000:82:00.0": {
                  "stats": {
                      "reload": {
                          "driver_reinit": 2,
                          "fw_activate": 1,
                          "fw_activate_no_reset": 0
                      }
                  }
              },
              "pci/0000:82:00.1": {
                  "stats": {
                      "reload": {
                          "driver_reinit": 1,
                          "fw_activate": 0,
                          "fw_activate_no_reset": 0
                      }
                  }
              }
          }
      }
      Signed-off-by: NMoshe Shemesh <moshe@mellanox.com>
      Reviewed-by: NJiri Pirko <jiri@nvidia.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      a254c264
    • M
      devlink: Add devlink reload limit option · dc64cc7c
      Moshe Shemesh 提交于
      Add reload limit to demand restrictions on reload actions.
      Reload limits supported:
      no_reset: No reset allowed, no down time allowed, no link flap and no
                configuration is lost.
      
      By default reload limit is unspecified and so no constraints on reload
      actions are required.
      
      Some combinations of action and limit are invalid. For example, driver
      can not reinitialize its entities without any downtime.
      
      The no_reset reload limit will have usecase in this patchset to
      implement restricted fw_activate on mlx5.
      
      Have the uapi parameter of reload limit ready for future support of
      multiselection.
      Signed-off-by: NMoshe Shemesh <moshe@mellanox.com>
      Reviewed-by: NJiri Pirko <jiri@nvidia.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      dc64cc7c
    • M
      devlink: Add reload action option to devlink reload command · ccdf0721
      Moshe Shemesh 提交于
      Add devlink reload action to allow the user to request a specific reload
      action. The action parameter is optional, if not specified then devlink
      driver re-init action is used (backward compatible).
      Note that when required to do firmware activation some drivers may need
      to reload the driver. On the other hand some drivers may need to reset
      the firmware to reinitialize the driver entities. Therefore, the devlink
      reload command returns the actions which were actually performed.
      Reload actions supported are:
      driver_reinit: driver entities re-initialization, applying devlink-param
                     and devlink-resource values.
      fw_activate: firmware activate.
      
      command examples:
      $devlink dev reload pci/0000:82:00.0 action driver_reinit
      reload_actions_performed:
        driver_reinit
      
      $devlink dev reload pci/0000:82:00.0 action fw_activate
      reload_actions_performed:
        driver_reinit fw_activate
      Signed-off-by: NMoshe Shemesh <moshe@mellanox.com>
      Reviewed-by: NJakub Kicinski <kuba@kernel.org>
      Reviewed-by: NJacob Keller <jacob.e.keller@intel.com>
      Reviewed-by: NJiri Pirko <jiri@nvidia.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      ccdf0721
  9. 09 10月, 2020 1 次提交
  10. 08 10月, 2020 1 次提交
  11. 06 10月, 2020 2 次提交
  12. 05 10月, 2020 7 次提交
  13. 04 10月, 2020 2 次提交
    • G
      net/sched: act_vlan: Add {POP,PUSH}_ETH actions · 19fbcb36
      Guillaume Nault 提交于
      Implement TCA_VLAN_ACT_POP_ETH and TCA_VLAN_ACT_PUSH_ETH, to
      respectively pop and push a base Ethernet header at the beginning of a
      frame.
      
      POP_ETH is just a matter of pulling ETH_HLEN bytes. VLAN tags, if any,
      must be stripped before calling POP_ETH.
      
      PUSH_ETH is restricted to skbs with no mac_header, and only the MAC
      addresses can be configured. The Ethertype is automatically set from
      skb->protocol. These restrictions ensure that all skb's fields remain
      consistent, so that this action can't confuse other part of the
      networking stack (like GSO).
      
      Since openvswitch already had these actions, consolidate the code in
      skbuff.c (like for vlan and mpls push/pop).
      Signed-off-by: NGuillaume Nault <gnault@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      19fbcb36
    • J
      netlink: rework policy dump to support multiple policies · 04a351a6
      Johannes Berg 提交于
      Rework the policy dump code a bit to support adding multiple
      policies to a single dump, in order to e.g. support per-op
      policies in generic netlink.
      
      v2:
       - move kernel-doc to implementation [Jakub]
       - squash the first patch to not flip-flop on the prototype
         [Jakub]
       - merge netlink_policy_dump_get_policy_idx() with the old
         get_policy_idx() we already had
       - rebase without Jakub's patch to have per-op dump
      Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      04a351a6
  14. 03 10月, 2020 8 次提交