An error occurred fetching the project authors.
  1. 09 Aug, 2023 1 commit
  2. 14 Jul, 2023 1 commit
  3. 19 Jul, 2022 1 commit
  4. 21 Mar, 2022 2 commits
  5. 15 Mar, 2022 1 commit
    • Petr Machata's avatar
      netdevsim: Introduce support for L3 offload xstats · 1a6d7ae7
      Petr Machata authored
      Add support for testing of HW stats support that was added recently, namely
      the L3 stats support. L3 stats are provided for devices for which the L3
      stats have been turned on, and that were enabled for netdevsim through a
      debugfs toggle:
      
          # echo $ifindex > /sys/kernel/debug/netdevsim/$DEV/hwstats/l3/enable_ifindex
      
      For fully enabled netdevices, netdevsim counts 10pps of ingress traffic and
      20pps of egress traffic. Similarly, L3 stats can be disabled for a given
      device, and netdevsim ceases pretending there is any HW traffic going on:
      
          # echo $ifindex > /sys/kernel/debug/netdevsim/$DEV/hwstats/l3/disable_ifindex
      
      Besides this, there is a third toggle to mark a device for future failure:
      
          # echo $ifindex > /sys/kernel/debug/netdevsim/$DEV/hwstats/l3/fail_next_enable
      
      A future request to enable L3 stats on such netdevice will be bounced by
      netdevsim:
      
          # ip -j l sh dev d | jq '.[].ifindex'
          66
          # echo 66 > /sys/kernel/debug/netdevsim/netdevsim10/hwstats/l3/enable_ifindex
          # echo 66 > /sys/kernel/debug/netdevsim/netdevsim10/hwstats/l3/fail_next_enable
          # ip stats set dev d l3_stats on
          Error: netdevsim: Stats enablement set to fail.
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Acked-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      1a6d7ae7
  6. 01 Nov, 2021 4 commits
  7. 30 Oct, 2021 1 commit
  8. 15 Sep, 2021 1 commit
  9. 06 Aug, 2021 1 commit
  10. 16 Jul, 2021 1 commit
    • Peilin Ye's avatar
      netdevsim: Add multi-queue support · d4861fc6
      Peilin Ye authored
      Currently netdevsim only supports a single queue per port, which is
      insufficient for testing multi-queue TC schedulers e.g. sch_mq.  Extend
      the current sysfs interface so that users can create ports with multiple
      queues:
      
      $ echo "[ID] [PORT_COUNT] [NUM_QUEUES]" > /sys/bus/netdevsim/new_device
      
      As an example, echoing "2 4 8" creates 4 ports, with 8 queues per port.
      Note, this is compatible with the current interface, with default number
      of queues set to 1.  For example, echoing "2 4" creates 4 ports with 1
      queue per port; echoing "2" simply creates 1 port with 1 queue.
      Reviewed-by: default avatarCong Wang <cong.wang@bytedance.com>
      Signed-off-by: default avatarPeilin Ye <peilin.ye@bytedance.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d4861fc6
  11. 18 Jun, 2021 1 commit
  12. 14 Jun, 2021 1 commit
  13. 02 Jun, 2021 6 commits
  14. 31 Mar, 2021 1 commit
  15. 14 Mar, 2021 1 commit
    • Ido Schimmel's avatar
      netdevsim: Add dummy psample implementation · a8700c3d
      Ido Schimmel authored
      Allow netdevsim to report "sampled" packets to the psample module by
      periodically generating packets from a work queue. The behavior can be
      enabled / disabled (default) and the various meta data attributes can be
      controlled via debugfs knobs.
      
      This implementation enables both testing of the psample module with all
      the optional attributes as well as development of user space
      applications on top of psample such as hsflowd and a Wireshark dissector
      for psample generic netlink packets.
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a8700c3d
  16. 09 Dec, 2020 1 commit
  17. 20 Nov, 2020 2 commits
  18. 06 Nov, 2020 1 commit
    • Ido Schimmel's avatar
      netdevsim: Add devlink resource for nexthops · 35266255
      Ido Schimmel authored
      The Spectrum ASIC has a dedicated table where nexthops (i.e., adjacency
      entries) are populated. The size of this table can be controlled via
      devlink-resource.
      
      Add such a resource to netdevsim so that its occupancy will reflect the
      number of nexthop objects currently programmed to the device.
      
      By limiting the size of the resource, error paths could be exercised and
      tested.
      
      Example output:
      
      # devlink resource show netdevsim/netdevsim10
      netdevsim/netdevsim10:
        name IPv4 size unlimited unit entry size_min 0 size_max unlimited size_gran 1 dpipe_tables none
          resources:
            name fib size unlimited occ 4 unit entry size_min 0 size_max unlimited size_gran 1 dpipe_tables none
            name fib-rules size unlimited occ 3 unit entry size_min 0 size_max unlimited size_gran 1 dpipe_tables none
        name IPv6 size unlimited unit entry size_min 0 size_max unlimited size_gran 1 dpipe_tables none
          resources:
            name fib size unlimited occ 1 unit entry size_min 0 size_max unlimited size_gran 1 dpipe_tables none
            name fib-rules size unlimited occ 2 unit entry size_min 0 size_max unlimited size_gran 1 dpipe_tables none
        name nexthops size unlimited occ 0 unit entry size_min 0 size_max unlimited size_gran 1 dpipe_tables none
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      35266255
  19. 28 Sep, 2020 2 commits
  20. 26 Sep, 2020 1 commit
  21. 15 Sep, 2020 1 commit
  22. 26 Jul, 2020 1 commit
  23. 10 Jul, 2020 1 commit
  24. 31 Mar, 2020 2 commits
  25. 25 Feb, 2020 1 commit
  26. 03 Feb, 2020 3 commits
    • Taehee Yoo's avatar
      netdevsim: fix panic in nsim_dev_take_snapshot_write() · 8526ad96
      Taehee Yoo authored
      nsim_dev_take_snapshot_write() uses nsim_dev and nsim_dev->dummy_region.
      So, during this function, these data shouldn't be removed.
      But there is no protecting stuff in this function.
      
      There are two similar cases.
      1. reload case
      reload could be called during nsim_dev_take_snapshot_write().
      When reload is being executed, nsim_dev_reload_down() is called and it
      calls nsim_dev_reload_destroy(). nsim_dev_reload_destroy() calls
      devlink_region_destroy() to destroy nsim_dev->dummy_region.
      So, during nsim_dev_take_snapshot_write(), nsim_dev->dummy_region()
      would be removed.
      At this point, snapshot_write() would access freed pointer.
      In order to fix this case, take_snapshot file will be removed before
      devlink_region_destroy().
      The take_snapshot file will be re-created by ->reload_up().
      
      2. del_device_store case
      del_device_store() also could call nsim_dev_reload_destroy()
      during nsim_dev_take_snapshot_write(). If so, panic would occur.
      This problem is actually the same problem with the first case.
      So, this problem will be fixed by the first case's solution.
      
      Test commands:
          modprobe netdevsim
          while :
          do
              echo 1 > /sys/bus/netdevsim/new_device &
              echo 1 > /sys/bus/netdevsim/del_device &
      	devlink dev reload netdevsim/netdevsim1 &
      	echo 1 > /sys/kernel/debug/netdevsim/netdevsim1/take_snapshot &
          done
      
      Splat looks like:
      [   45.564513][  T975] general protection fault, probably for non-canonical address 0xdffffc000000003a: 0000 [#1] SMP DEI
      [   45.566131][  T975] KASAN: null-ptr-deref in range [0x00000000000001d0-0x00000000000001d7]
      [   45.566135][  T975] CPU: 1 PID: 975 Comm: bash Not tainted 5.5.0+ #322
      [   45.569020][  T975] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
      [   45.569026][  T975] RIP: 0010:__mutex_lock+0x10a/0x14b0
      [   45.570518][  T975] Code: 08 84 d2 0f 85 7f 12 00 00 44 8b 0d 10 23 65 02 45 85 c9 75 29 49 8d 7f 68 48 b8 00 00 00 0f
      [   45.570522][  T975] RSP: 0018:ffff888046ccfbf0 EFLAGS: 00010206
      [   45.572305][  T975] RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000000
      [   45.572308][  T975] RDX: 000000000000003a RSI: ffffffffac926440 RDI: 00000000000001d0
      [   45.576843][  T975] RBP: ffff888046ccfd70 R08: ffffffffab610645 R09: 0000000000000000
      [   45.576847][  T975] R10: ffff888046ccfd90 R11: ffffed100d6360ad R12: 0000000000000000
      [   45.578471][  T975] R13: dffffc0000000000 R14: ffffffffae1976c0 R15: 0000000000000168
      [   45.578475][  T975] FS:  00007f614d6e7740(0000) GS:ffff88806c400000(0000) knlGS:0000000000000000
      [   45.581492][  T975] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   45.582942][  T975] CR2: 00005618677d1cf0 CR3: 000000005fb9c002 CR4: 00000000000606e0
      [   45.584543][  T975] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [   45.586633][  T975] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [   45.589889][  T975] Call Trace:
      [   45.591445][  T975]  ? devlink_region_snapshot_create+0x55/0x4a0
      [   45.601250][  T975]  ? mutex_lock_io_nested+0x1380/0x1380
      [   45.602817][  T975]  ? mutex_lock_io_nested+0x1380/0x1380
      [   45.603875][  T975]  ? mark_held_locks+0xa5/0xe0
      [   45.604769][  T975]  ? _raw_spin_unlock_irqrestore+0x2d/0x50
      [   45.606147][  T975]  ? __mutex_unlock_slowpath+0xd0/0x670
      [   45.607723][  T975]  ? crng_backtrack_protect+0x80/0x80
      [   45.613530][  T975]  ? wait_for_completion+0x390/0x390
      [   45.615152][  T975]  ? devlink_region_snapshot_create+0x55/0x4a0
      [   45.616834][  T975]  devlink_region_snapshot_create+0x55/0x4a0
      [ ... ]
      
      Fixes: 4418f862 ("netdevsim: implement support for devlink region and snapshots")
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      8526ad96
    • Taehee Yoo's avatar
      netdevsim: disable devlink reload when resources are being used · 6ab63366
      Taehee Yoo authored
      devlink reload destroys resources and allocates resources again.
      So, when devices and ports resources are being used, devlink reload
      function should not be executed. In order to avoid this race, a new
      lock is added and new_port() and del_port() call devlink_reload_disable()
      and devlink_reload_enable().
      
      Thread0                      Thread1
      {new/del}_port()             {new/del}_port()
      devlink_reload_disable()
                                   devlink_reload_disable()
      devlink_reload_enable()
                                   //here
                                   devlink_reload_enable()
      
      Before Thread1's devlink_reload_enable(), the devlink is already allowed
      to execute reload because Thread0 allows it. devlink reload disable/enable
      variable type is bool. So the above case would exist.
      So, disable/enable should be executed atomically.
      In order to do that, a new lock is used.
      
      Test commands:
          modprobe netdevsim
          echo 1 > /sys/bus/netdevsim/new_device
          while :
          do
              echo 1 > /sys/devices/netdevsim1/new_port &
              echo 1 > /sys/devices/netdevsim1/del_port &
              devlink dev reload netdevsim/netdevsim1 &
          done
      
      Splat looks like:
      [   23.342145][  T932] DEBUG_LOCKS_WARN_ON(mutex_is_locked(lock))
      [   23.342159][  T932] WARNING: CPU: 0 PID: 932 at kernel/locking/mutex-debug.c:103 mutex_destroy+0xc7/0xf0
      [   23.344182][  T932] Modules linked in: netdevsim openvswitch nsh nf_conncount nf_nat nf_conntrack nf_defrag_ipv6 nf_dx
      [   23.346485][  T932] CPU: 0 PID: 932 Comm: devlink Not tainted 5.5.0+ #322
      [   23.347696][  T932] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
      [   23.348893][  T932] RIP: 0010:mutex_destroy+0xc7/0xf0
      [   23.349505][  T932] Code: e0 07 83 c0 03 38 d0 7c 04 84 d2 75 2e 8b 05 00 ac b0 02 85 c0 75 8b 48 c7 c6 00 5e 07 96 40
      [   23.351887][  T932] RSP: 0018:ffff88806208f810 EFLAGS: 00010286
      [   23.353963][  T932] RAX: dffffc0000000008 RBX: ffff888067f6f2c0 RCX: ffffffff942c4bd4
      [   23.355222][  T932] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffffff96dac5b4
      [   23.356169][  T932] RBP: ffff888067f6f000 R08: fffffbfff2d235a5 R09: fffffbfff2d235a5
      [   23.357160][  T932] R10: 0000000000000001 R11: fffffbfff2d235a4 R12: ffff888067f6f208
      [   23.358288][  T932] R13: ffff88806208fa70 R14: ffff888067f6f000 R15: ffff888069ce3800
      [   23.359307][  T932] FS:  00007fe2a3876740(0000) GS:ffff88806c000000(0000) knlGS:0000000000000000
      [   23.360473][  T932] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   23.361319][  T932] CR2: 00005561357aa000 CR3: 000000005227a006 CR4: 00000000000606f0
      [   23.362323][  T932] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [   23.363417][  T932] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [   23.364414][  T932] Call Trace:
      [   23.364828][  T932]  nsim_dev_reload_destroy+0x77/0xb0 [netdevsim]
      [   23.365655][  T932]  nsim_dev_reload_down+0x84/0xb0 [netdevsim]
      [   23.366433][  T932]  devlink_reload+0xb1/0x350
      [   23.367010][  T932]  genl_rcv_msg+0x580/0xe90
      
      [ ...]
      
      [   23.531729][ T1305] kernel BUG at lib/list_debug.c:53!
      [   23.532523][ T1305] invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN PTI
      [   23.533467][ T1305] CPU: 2 PID: 1305 Comm: bash Tainted: G        W         5.5.0+ #322
      [   23.534962][ T1305] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
      [   23.536503][ T1305] RIP: 0010:__list_del_entry_valid+0xe6/0x150
      [   23.538346][ T1305] Code: 89 ea 48 c7 c7 00 73 1e 96 e8 df f7 4c ff 0f 0b 48 c7 c7 60 73 1e 96 e8 d1 f7 4c ff 0f 0b 44
      [   23.541068][ T1305] RSP: 0018:ffff888047c27b58 EFLAGS: 00010282
      [   23.542001][ T1305] RAX: 0000000000000054 RBX: ffff888067f6f318 RCX: 0000000000000000
      [   23.543051][ T1305] RDX: 0000000000000054 RSI: 0000000000000008 RDI: ffffed1008f84f61
      [   23.544072][ T1305] RBP: ffff88804aa0fca0 R08: ffffed100d940539 R09: ffffed100d940539
      [   23.545085][ T1305] R10: 0000000000000001 R11: ffffed100d940538 R12: ffff888047c27cb0
      [   23.546422][ T1305] R13: ffff88806208b840 R14: ffffffff981976c0 R15: ffff888067f6f2c0
      [   23.547406][ T1305] FS:  00007f76c0431740(0000) GS:ffff88806c800000(0000) knlGS:0000000000000000
      [   23.548527][ T1305] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   23.549389][ T1305] CR2: 00007f5048f1a2f8 CR3: 000000004b310006 CR4: 00000000000606e0
      [   23.550636][ T1305] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [   23.551578][ T1305] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [   23.552597][ T1305] Call Trace:
      [   23.553004][ T1305]  mutex_remove_waiter+0x101/0x520
      [   23.553646][ T1305]  __mutex_lock+0xac7/0x14b0
      [   23.554218][ T1305]  ? nsim_dev_port_del+0x4e/0x140 [netdevsim]
      [   23.554908][ T1305]  ? mutex_lock_io_nested+0x1380/0x1380
      [   23.555570][ T1305]  ? _parse_integer+0xf0/0xf0
      [   23.556043][ T1305]  ? kstrtouint+0x86/0x110
      [   23.556504][ T1305]  ? nsim_dev_port_del+0x4e/0x140 [netdevsim]
      [   23.557133][ T1305]  nsim_dev_port_del+0x4e/0x140 [netdevsim]
      [   23.558024][ T1305]  del_port_store+0xcc/0xf0 [netdevsim]
      [ ... ]
      
      Fixes: 75ba029f ("netdevsim: implement proper devlink reload")
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      6ab63366
    • Taehee Yoo's avatar
      netdevsim: fix using uninitialized resources · f5cd2160
      Taehee Yoo authored
      When module is being initialized, __init() calls bus_register() and
      driver_register().
      These functions internally create various resources and sysfs files.
      The sysfs files are used for basic operations(add/del device).
      /sys/bus/netdevsim/new_device
      /sys/bus/netdevsim/del_device
      
      These sysfs files use netdevsim resources, they are mostly allocated
      and initialized in ->probe() function, which is nsim_dev_probe().
      But, sysfs files could be executed before ->probe() is finished.
      So, accessing uninitialized data would occur.
      
      Another problem is very similar.
      /sys/bus/netdevsim/new_device internally creates sysfs files.
      /sys/devices/netdevsim<id>/new_port
      /sys/devices/netdevsim<id>/del_port
      
      These sysfs files also use netdevsim resources, they are mostly allocated
      and initialized in creating device routine, which is nsim_bus_dev_new().
      But they also could be executed before nsim_bus_dev_new() is finished.
      So, accessing uninitialized data would occur.
      
      To fix these problems, this patch adds flags, which means whether the
      operation is finished or not.
      The flag variable 'nsim_bus_enable' means whether netdevsim bus was
      initialized or not.
      This is protected by nsim_bus_dev_list_lock.
      The flag variable 'nsim_bus_dev->init' means whether nsim_bus_dev was
      initialized or not.
      This could be used in {new/del}_port_store() with no lock.
      
      Test commands:
          #SHELL1
          modprobe netdevsim
          while :
          do
              echo "1 1" > /sys/bus/netdevsim/new_device
              echo "1 1" > /sys/bus/netdevsim/del_device
          done
      
          #SHELL2
          while :
          do
              echo 1 > /sys/devices/netdevsim1/new_port
              echo 1 > /sys/devices/netdevsim1/del_port
          done
      
      Splat looks like:
      [   47.508954][ T1008] general protection fault, probably for non-canonical address 0xdffffc0000000021: 0000 I
      [   47.510793][ T1008] KASAN: null-ptr-deref in range [0x0000000000000108-0x000000000000010f]
      [   47.511963][ T1008] CPU: 2 PID: 1008 Comm: bash Not tainted 5.5.0+ #322
      [   47.512823][ T1008] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
      [   47.514041][ T1008] RIP: 0010:__mutex_lock+0x10a/0x14b0
      [   47.514699][ T1008] Code: 08 84 d2 0f 85 7f 12 00 00 44 8b 0d 10 23 65 02 45 85 c9 75 29 49 8d 7f 68 48 b8 00 00 00 0f
      [   47.517163][ T1008] RSP: 0018:ffff888059b4fbb0 EFLAGS: 00010206
      [   47.517802][ T1008] RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000000000
      [   47.518941][ T1008] RDX: 0000000000000021 RSI: ffffffff85926440 RDI: 0000000000000108
      [   47.519732][ T1008] RBP: ffff888059b4fd30 R08: ffffffffc073fad0 R09: 0000000000000000
      [   47.520729][ T1008] R10: ffff888059b4fd50 R11: ffff88804bb38040 R12: 0000000000000000
      [   47.521702][ T1008] R13: dffffc0000000000 R14: ffffffff871976c0 R15: 00000000000000a0
      [   47.522760][ T1008] FS:  00007fd4be05a740(0000) GS:ffff88806c800000(0000) knlGS:0000000000000000
      [   47.523877][ T1008] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   47.524627][ T1008] CR2: 0000561c82b69cf0 CR3: 0000000065dd6004 CR4: 00000000000606e0
      [   47.527662][ T1008] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [   47.528604][ T1008] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [   47.529531][ T1008] Call Trace:
      [   47.529874][ T1008]  ? nsim_dev_port_add+0x50/0x150 [netdevsim]
      [   47.530470][ T1008]  ? mutex_lock_io_nested+0x1380/0x1380
      [   47.531018][ T1008]  ? _kstrtoull+0x76/0x160
      [   47.531449][ T1008]  ? _parse_integer+0xf0/0xf0
      [   47.531874][ T1008]  ? kernfs_fop_write+0x1cf/0x410
      [   47.532330][ T1008]  ? sysfs_file_ops+0x160/0x160
      [   47.532773][ T1008]  ? kstrtouint+0x86/0x110
      [   47.533168][ T1008]  ? nsim_dev_port_add+0x50/0x150 [netdevsim]
      [   47.533721][ T1008]  nsim_dev_port_add+0x50/0x150 [netdevsim]
      [   47.534336][ T1008]  ? sysfs_file_ops+0x160/0x160
      [   47.534858][ T1008]  new_port_store+0x99/0xb0 [netdevsim]
      [   47.535439][ T1008]  ? del_port_store+0xb0/0xb0 [netdevsim]
      [   47.536035][ T1008]  ? sysfs_file_ops+0x112/0x160
      [   47.536544][ T1008]  ? sysfs_kf_write+0x3b/0x180
      [   47.537029][ T1008]  kernfs_fop_write+0x276/0x410
      [   47.537548][ T1008]  ? __sb_start_write+0x215/0x2e0
      [   47.538110][ T1008]  vfs_write+0x197/0x4a0
      [ ... ]
      
      Fixes: f9d9db47 ("netdevsim: add bus attributes to add new and delete devices")
      Fixes: 794b2c05 ("netdevsim: extend device attrs to support port addition and deletion")
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      f5cd2160