mbox series

[net-next,v8,0/5] netdevsim: link and forward skbs between ports

Message ID 20240130214620.3722189-1-dw@davidwei.uk (mailing list archive)
Headers show
Series netdevsim: link and forward skbs between ports | expand

Message

David Wei Jan. 30, 2024, 9:46 p.m. UTC
This patchset adds the ability to link two netdevsim ports together and
forward skbs between them, similar to veth. The goal is to use netdevsim
for testing features e.g. zero copy Rx using io_uring.

This feature was tested locally on QEMU, and a selftest is included.

---
v7->v8:
- fix not dereferencing RCU ptr using rcu_dereference()
- remove unused variables in selftest

v6->v7:
- change link syntax to netnsid:ifidx
- replace dev_get_by_index() with __dev_get_by_index()
- check for NULL peer when linking
- add a sysfs attribute for unlinking
- only update Tx stats if not dropped
- update selftest

v5->v6:
- reworked to link two netdevsims using sysfs attribute on the bus
  device instead of debugfs due to deadlock possibility if a netdevsim
  is removed during linking
- removed unnecessary patch maintaining a list of probed nsim_devs
- updated selftest

v4->v5:
- reduce nsim_dev_list_lock critical section
- fixed missing mutex unlock during unwind ladder
- rework nsim_dev_peer_write synchronization to take devlink lock as
  well as rtnl_lock
- return err msgs to user during linking if port doesn't exist or
  linking to self
- update tx stats outside of RCU lock

v3->v4:
- maintain a mutex protected list of probed nsim_devs instead of using
  nsim_bus_dev
- fixed synchronization issues by taking rtnl_lock
- track tx_dropped skbs

v2->v3:
- take lock when traversing nsim_bus_dev_list
- take device ref when getting a nsim_bus_dev
- return 0 if nsim_dev_peer_read cannot find the port
- address code formatting
- do not hard code values in selftests
- add Makefile for selftests

v1->v2:
- renamed debugfs file from "link" to "peer"
- replaced strstep() with sscanf() for consistency
- increased char[] buf sz to 22 for copying id + port from user
- added err msg w/ expected fmt when linking as a hint to user
- prevent linking port to itself
- protect peer ptr using RCU

David Wei (4):
  netdevsim: allow two netdevsim ports to be connected
  netdevsim: forward skbs from one connected port to another
  netdevsim: add selftest for forwarding skb between connected ports
  netdevsim: add Makefile for selftests

 MAINTAINERS                                   |   1 +
 drivers/net/netdevsim/bus.c                   | 130 ++++++++++++++++++
 drivers/net/netdevsim/netdev.c                |  39 +++++-
 drivers/net/netdevsim/netdevsim.h             |   3 +
 .../selftests/drivers/net/netdevsim/Makefile  |  18 +++
 .../selftests/drivers/net/netdevsim/peer.sh   | 125 +++++++++++++++++
 6 files changed, 311 insertions(+), 5 deletions(-)
 create mode 100644 tools/testing/selftests/drivers/net/netdevsim/Makefile
 create mode 100755 tools/testing/selftests/drivers/net/netdevsim/peer.sh

Comments

Jakub Kicinski Feb. 1, 2024, 12:44 a.m. UTC | #1
On Tue, 30 Jan 2024 13:46:16 -0800 David Wei wrote:
> [PATCH net-next v8 0/5] netdevsim: link and forward skbs between ports

There's only 4 patches here, you'll need to repost because you promised
patchwork 5 by saying 0/5 :(
David Wei Feb. 1, 2024, 4:48 a.m. UTC | #2
On 2024-01-31 16:44, Jakub Kicinski wrote:
> On Tue, 30 Jan 2024 13:46:16 -0800 David Wei wrote:
>> [PATCH net-next v8 0/5] netdevsim: link and forward skbs between ports
> 
> There's only 4 patches here, you'll need to repost because you promised
> patchwork 5 by saying 0/5 :(

I'm sorry for being a bad chef and making bad copy pasta :(
patchwork-bot+netdevbpf@kernel.org Feb. 5, 2024, 3:40 p.m. UTC | #3
Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 30 Jan 2024 13:46:16 -0800 you wrote:
> This patchset adds the ability to link two netdevsim ports together and
> forward skbs between them, similar to veth. The goal is to use netdevsim
> for testing features e.g. zero copy Rx using io_uring.
> 
> This feature was tested locally on QEMU, and a selftest is included.
> 
> 
> [...]

Here is the summary with links:
  - [net-next,v8,1/4] netdevsim: allow two netdevsim ports to be connected
    (no matching commit)
  - [net-next,v8,2/4] netdevsim: forward skbs from one connected port to another
    (no matching commit)
  - [net-next,v8,3/4] netdevsim: add selftest for forwarding skb between connected ports
    (no matching commit)
  - [net-next,v8,4/4] netdevsim: add Makefile for selftests
    https://git.kernel.org/netdev/net-next/c/8ff25dac88f6

You are awesome, thank you!