Skip to content

netdevsim: link and forward skbs between ports

David Wei netdev 15 versions – Applied

Status from this message: This series was applied to netdev/net-next.git (main)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v14 Latest5 patches 4 repliesApplied 5/5
  2. v134 patches 3 repliesSuperseded
  3. v124 patches 3 repliesSuperseded
Earlier versions · 12
VersionPostedPatchesRepliesStatus
v113 patches11 repliesSuperseded
v103 patches1 replySuperseded
v93 patches9 repliesSuperseded
v8 posting 2/24 patches2 repliesSuperseded
v8 posting 1/20 of 5 patches2 repliesSuperseded
v74 patches3 repliesSuperseded
v64 patches5 repliesSuperseded
v55 patches14 repliesSuperseded
v45 patches12 repliesSuperseded
v34 patches9 repliesSuperseded
v23 patches4 repliesSuperseded
v13 patches9 repliesSuperseded

Changes in v14 from the cover letter

- implement ndo_get_iflink()
- fix returning 0 if peer is already linked during linking or not linked during unlinking
- bump dropped counter if nsim_ipsec_tx() fails and generally reorder nsim_start_xmit()
- fix overflowing lines and indentations

Patches in v14 All 5 applied

#Subject and filesSizeRepliesApplied
1/5netdevsim: allow two netdevsim ports to be connecteddrivers/net/netdevsim/bus.c drivers/net/netdevsim/netdev.c drivers/net/netdevsim/netdevsim.h+157 -01 replyApplied
2/5netdevsim: forward skbs from one connected port to anotherdrivers/net/netdevsim/netdev.c drivers/net/netdevsim/netdevsim.h+23 -51 replyApplied
3/5netdevsim: add ndo_get_iflink() implementationdrivers/net/netdevsim/netdev.c+16 -01 replyApplied
4/5netdevsim: add selftest for forwarding skb between connected portstools/testing/selftests/drivers/net/netdevsim/Makefile tools/testing/selftests/drivers/net/netdevsim/peer.sh+144 -01 replyApplied
5/5netdevsim: fix rtnetlink.sh selftesttools/testing/selftests/net/rtnetlink.sh+2 -00 repliesApplied

Reviews trailers per patch

4 of 5 patches have a Reviewed-by or Acked-by.

PatchMaciek Machnikowski
1/5R-b
2/5R-b
3/5R-b
4/5R-b
5/5

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v14 thread

Cover letter [PATCH v14 0/5] netdevsim: link and forward skbs between ports

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.

I ran netdev selftests CI style and all tests but the following passed:
- gro.sh
- l2tp.sh
- ip_local_port_range.sh

gro.sh fails because virtme-ng mounts as read-only and it tries to write to log.txt. This issue was reported to virtme-ng upstream.

l2tp.sh and ip_local_port_range.sh both fail for me on net-next/main as well.

---
v13->v14:
- implement ndo_get_iflink()
- fix returning 0 if peer is already linked during linking or not linked during unlinking
- bump dropped counter if nsim_ipsec_tx() fails and generally reorder nsim_start_xmit()
- fix overflowing lines and indentations

v12->v13:
- wait for socat listening port to be ready before sending data in selftest

v11->v12:
- fix leaked netns refs
- fix rtnetlink.sh kci_test_ipsec_offload() selftest

v10->v11:
- add udevadm settle after creating netdevsims in selftest

v9->v10:
- fix not freeing skb when not there is no peer
- prevent possible id clashes in selftest
- cleanup selftest on error paths

v8->v9:
- switch to getting netns using fd rather than id
- prevent linking a netdevsim to itself
- update tests

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 (5):
netdevsim: allow two netdevsim ports to be connected
netdevsim: forward skbs from one connected port to another
netdevsim: add ndo_get_iflink() implementation
netdevsim: add selftest for forwarding skb between connected ports
netdevsim: fix rtnetlink.sh selftest

 drivers/net/netdevsim/bus.c                   | 145 ++++++++++++++++++
 drivers/net/netdevsim/netdev.c                |  53 ++++++-
 drivers/net/netdevsim/netdevsim.h             |   3 +
 .../selftests/drivers/net/netdevsim/Makefile  |   1 +
 .../selftests/drivers/net/netdevsim/peer.sh   | 143 +++++++++++++++++
 tools/testing/selftests/net/rtnetlink.sh      |   2 +
 6 files changed, 342 insertions(+), 5 deletions(-)
 create mode 100755 tools/testing/selftests/drivers/net/netdevsim/peer.sh
Signature · 1 line
2.43.0