1. 05 5月, 2020 1 次提交
  2. 02 5月, 2020 2 次提交
    • A
      drop_monitor: work around gcc-10 stringop-overflow warning · dc30b405
      Arnd Bergmann 提交于
      The current gcc-10 snapshot produces a false-positive warning:
      
      net/core/drop_monitor.c: In function 'trace_drop_common.constprop':
      cc1: error: writing 8 bytes into a region of size 0 [-Werror=stringop-overflow=]
      In file included from net/core/drop_monitor.c:23:
      include/uapi/linux/net_dropmon.h:36:8: note: at offset 0 to object 'entries' with size 4 declared here
         36 |  __u32 entries;
            |        ^~~~~~~
      
      I reported this in the gcc bugzilla, but in case it does not get
      fixed in the release, work around it by using a temporary variable.
      
      Fixes: 9a8afc8d ("Network Drop Monitor: Adding drop monitor implementation & Netlink protocol")
      Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94881Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Acked-by: NNeil Horman <nhorman@tuxdriver.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      dc30b405
    • J
      devlink: fix return value after hitting end in region read · 610a9346
      Jakub Kicinski 提交于
      Commit d5b90e99 ("devlink: report 0 after hitting end in region read")
      fixed region dump, but region read still returns a spurious error:
      
      $ devlink region read netdevsim/netdevsim1/dummy snapshot 0 addr 0 len 128
      0000000000000000 a6 f4 c4 1c 21 35 95 a6 9d 34 c3 5b 87 5b 35 79
      0000000000000010 f3 a0 d7 ee 4f 2f 82 7f c6 dd c4 f6 a5 c3 1b ae
      0000000000000020 a4 fd c8 62 07 59 48 03 70 3b c7 09 86 88 7f 68
      0000000000000030 6f 45 5d 6d 7d 0e 16 38 a9 d0 7a 4b 1e 1e 2e a6
      0000000000000040 e6 1d ae 06 d6 18 00 85 ca 62 e8 7e 11 7e f6 0f
      0000000000000050 79 7e f7 0f f3 94 68 bd e6 40 22 85 b6 be 6f b1
      0000000000000060 af db ef 5e 34 f0 98 4b 62 9a e3 1b 8b 93 fc 17
      devlink answers: Invalid argument
      0000000000000070 61 e8 11 11 66 10 a5 f7 b1 ea 8d 40 60 53 ed 12
      
      This is a minimal fix, I'll follow up with a restructuring
      so we don't have two checks for the same condition.
      
      Fixes: fdd41ec2 ("devlink: Return right error code in case of errors for region read")
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      Reviewed-by: NJacob Keller <jacob.e.keller@intel.com>
      Reviewed-by: NJiri Pirko <jiri@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      610a9346
  3. 26 4月, 2020 1 次提交
  4. 22 4月, 2020 1 次提交
  5. 15 4月, 2020 1 次提交
  6. 10 4月, 2020 1 次提交
  7. 09 4月, 2020 1 次提交
  8. 08 4月, 2020 1 次提交
  9. 03 4月, 2020 3 次提交
    • H
      neigh: support smaller retrans_time settting · 19e16d22
      Hangbin Liu 提交于
      Currently, we limited the retrans_time to be greater than HZ/2. i.e.
      setting retrans_time less than 500ms will not work. This makes the user
      unable to achieve a more accurate control for bonding arp fast failover.
      
      Update the sanity check to HZ/100, which is 10ms, to let users have more
      ability on the retrans_time control.
      
      v3: sync the behavior with IPv6 and update all the timer handler
      v2: use HZ instead of hard code number
      Signed-off-by: NHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      19e16d22
    • V
      net: core: enable SO_BINDTODEVICE for non-root users · c427bfec
      Vincent Bernat 提交于
      Currently, SO_BINDTODEVICE requires CAP_NET_RAW. This change allows a
      non-root user to bind a socket to an interface if it is not already
      bound. This is useful to allow an application to bind itself to a
      specific VRF for outgoing or incoming connections. Currently, an
      application wanting to manage connections through several VRF need to
      be privileged.
      
      Previously, IP_UNICAST_IF and IPV6_UNICAST_IF were added for
      Wine (76e21053 and c4062dfc) specifically for use by
      non-root processes. However, they are restricted to sendmsg() and not
      usable with TCP. Allowing SO_BINDTODEVICE would allow TCP clients to
      get the same privilege. As for TCP servers, outside the VRF use case,
      SO_BINDTODEVICE would only further restrict connections a server could
      accept.
      
      When an application is restricted to a VRF (with `ip vrf exec`), the
      socket is bound to an interface at creation and therefore, a
      non-privileged call to SO_BINDTODEVICE to escape the VRF fails.
      
      When an application bound a socket to SO_BINDTODEVICE and transmit it
      to a non-privileged process through a Unix socket, a tentative to
      change the bound device also fails.
      
      Before:
      
          >>> import socket
          >>> s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          >>> s.setsockopt(socket.SOL_SOCKET, socket.SO_BINDTODEVICE, b"dummy0")
          Traceback (most recent call last):
            File "<stdin>", line 1, in <module>
          PermissionError: [Errno 1] Operation not permitted
      
      After:
      
          >>> import socket
          >>> s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          >>> s.setsockopt(socket.SOL_SOCKET, socket.SO_BINDTODEVICE, b"dummy0")
          >>> s.setsockopt(socket.SOL_SOCKET, socket.SO_BINDTODEVICE, b"dummy0")
          Traceback (most recent call last):
            File "<stdin>", line 1, in <module>
          PermissionError: [Errno 1] Operation not permitted
      Signed-off-by: NVincent Bernat <vincent@bernat.ch>
      Reviewed-by: NDavid Ahern <dsahern@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      c427bfec
    • J
      net, sk_msg: Don't use RCU_INIT_POINTER on sk_user_data · 7a1ca972
      Jakub Sitnicki 提交于
      sparse reports an error due to use of RCU_INIT_POINTER helper to assign to
      sk_user_data pointer, which is not tagged with __rcu:
      
      net/core/sock.c:1875:25: error: incompatible types in comparison expression (different address spaces):
      net/core/sock.c:1875:25:    void [noderef] <asn:4> *
      net/core/sock.c:1875:25:    void *
      
      ... and rightfully so. sk_user_data is not always treated as a pointer to
      an RCU-protected data. When it is used to point at an RCU-protected object,
      we access it with __sk_user_data to inform sparse about it.
      
      In this case, when the child socket does not inherit sk_user_data from the
      parent, there is no reason to treat it as an RCU-protected pointer.
      
      Use a regular assignment to clear the pointer value.
      
      Fixes: f1ff5ce2 ("net, sk_msg: Clear sk_user_data pointer on clone if tagged")
      Reported-by: Nkbuild test robot <lkp@intel.com>
      Signed-off-by: NJakub Sitnicki <jakub@cloudflare.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20200402125524.851439-1-jakub@cloudflare.com
      7a1ca972
  10. 31 3月, 2020 9 次提交
  11. 30 3月, 2020 5 次提交
  12. 29 3月, 2020 1 次提交
  13. 28 3月, 2020 7 次提交
  14. 27 3月, 2020 6 次提交
    • J
      devlink: implement DEVLINK_CMD_REGION_NEW · b9a17abf
      Jacob Keller 提交于
      Implement support for the DEVLINK_CMD_REGION_NEW command for creating
      snapshots. This new command parallels the existing
      DEVLINK_CMD_REGION_DEL.
      
      In order for DEVLINK_CMD_REGION_NEW to work for a region, the new
      ".snapshot" operation must be implemented in the region's ops structure.
      
      The desired snapshot id must be provided. This helps avoid confusion on
      the purpose of DEVLINK_CMD_REGION_NEW, and keeps the API simpler.
      
      The requested id will be inserted into the xarray tracking the number of
      snapshots using each id. If this id is already used by another snapshot
      on any region, an error will be returned.
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Reviewed-by: NJiri Pirko <jiri@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b9a17abf
    • J
      devlink: track snapshot id usage count using an xarray · 12102436
      Jacob Keller 提交于
      Each snapshot created for a devlink region must have an id. These ids
      are supposed to be unique per "event" that caused the snapshot to be
      created. Drivers call devlink_region_snapshot_id_get to obtain a new id
      to use for a new event trigger. The id values are tracked per devlink,
      so that the same id number can be used if a triggering event creates
      multiple snapshots on different regions.
      
      There is no mechanism for snapshot ids to ever be reused. Introduce an
      xarray to store the count of how many snapshots are using a given id,
      replacing the snapshot_id field previously used for picking the next id.
      
      The devlink_region_snapshot_id_get() function will use xa_alloc to
      insert an initial value of 1 value at an available slot between 0 and
      U32_MAX.
      
      The new __devlink_snapshot_id_increment() and
      __devlink_snapshot_id_decrement() functions will be used to track how
      many snapshots currently use an id.
      
      Drivers must now call devlink_snapshot_id_put() in order to release
      their reference of the snapshot id after adding region snapshots.
      
      By tracking the total number of snapshots using a given id, it is
      possible for the decrement() function to erase the id from the xarray
      when it is not in use.
      
      With this method, a snapshot id can become reused again once all
      snapshots that referred to it have been deleted via
      DEVLINK_CMD_REGION_DEL, and the driver has finished adding snapshots.
      
      This work also paves the way to introduce a mechanism for userspace to
      request a snapshot.
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Reviewed-by: NJiri Pirko <jiri@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      12102436
    • J
      devlink: report error once U32_MAX snapshot ids have been used · 7ef19d3b
      Jacob Keller 提交于
      The devlink_snapshot_id_get() function returns a snapshot id. The
      snapshot id is a u32, so there is no way to indicate an error code.
      
      A future change is going to possibly add additional cases where this
      function could fail. Refactor the function to return the snapshot id in
      an argument, so that it can return zero or an error value.
      
      This ensures that snapshot ids cannot be confused with error values, and
      aids in the future refactor of snapshot id allocation management.
      
      Because there is no current way to release previously used snapshot ids,
      add a simple check ensuring that an error is reported in case the
      snapshot_id would over flow.
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Reviewed-by: NJiri Pirko <jiri@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7ef19d3b
    • J
      devlink: extract snapshot id allocation to helper function · 7000108f
      Jacob Keller 提交于
      A future change is going to implement a new devlink command to request
      a snapshot on demand. As part of this, the logic for handling the
      snapshot ids will be refactored. To simplify the snapshot id allocation
      function, move it to a separate function prefixed by `__`. This helper
      function will assume the lock is held.
      
      While no other callers will exist, it simplifies refactoring the logic
      because there is no need to complicate the function with gotos to handle
      unlocking on failure.
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Reviewed-by: NJiri Pirko <jiri@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7000108f
    • J
      devlink: use -ENOSPC to indicate no more room for snapshots · 47a39f61
      Jacob Keller 提交于
      The devlink_region_snapshot_create function returns -ENOMEM when the
      maximum number of snapshots has been reached. This is confusing because
      it is not an issue of being out of memory. Change this to use -ENOSPC
      instead.
      Reported-by: NJiri Pirko <jiri@resnulli.us>
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Reviewed-by: NJiri Pirko <jiri@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      47a39f61
    • J
      devlink: add function to take snapshot while locked · cf80faee
      Jacob Keller 提交于
      A future change is going to add a new devlink command to request
      a snapshot on demand. This function will want to call the
      devlink_region_snapshot_create function while already holding the
      devlink instance lock.
      
      Extract the logic of this function into a static function prefixed by
      `__` to indicate that it is an internal helper function. Modify the
      original function to be implemented in terms of the new locked
      function.
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Reviewed-by: NJiri Pirko <jiri@mellanox.com>
      Reviewed-by: NJakub Kicinski <kuba@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      cf80faee