Skip to content

netdevsim: add TLS device offload emulation and test

Jiayuan Chen linux-kselftest lkml llvm netdev oe-kbuild-all 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 0 repliesNew
  2. v12 patches 3 repliesSuperseded

Changes in v2 from the cover letter

- drop the netdevsim-only selftest, run the upstream tls_hw_offload.py
on netdevsim instead so the test also covers real hardware (Jakub)
- rebase on net-next
v1: https://lore.kernel.org/netdev/[email protected]/
RFC (July): https://lore.kernel.org/netdev/[email protected]/

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2netdevsim: add TLS device offload emulationdrivers/net/Kconfig drivers/net/netdevsim/Makefile drivers/net/netdevsim/netdev.c +2 more+523 -20 replies
2/2selftests: drv-net: run tls_hw_offload on netdevsimtools/testing/selftests/drivers/net/hw/tls_hw_offload.py+4 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH net-next v2 0/2] netdevsim: add TLS device offload emulation and test

Running kTLS over this already found a few bugs:

b17cf742eaad ("tls: device: fix out-of-bounds write in tls_append_frag()") ed642349d87d ("tls: fix the open record check in the max payload size setsockopt")

So I think it is worth sending a formal patchset. v1 [1] was asked to wait for a selftest that can also run against real hardware. That test, drivers/net/hw/tls_hw_offload.py, is in the tree now, so this can move forward.

The kTLS device offload path in net/tls/tls_device.c has no test coverage upstream -- selftests/net/tls.c is software only, and the offload code needs a driver that implements it.

So teach netdevsim to fake it. Patch 1 implements tlsdev_ops and advertises the TLS features. Patch 2 lets the existing hardware offload test, drivers/net/hw/tls_hw_offload.py, run on netdevsim as well, so the same test covers real devices and the netdevsim pair CI already uses.

No crypto is done, like the IPsec, MACsec and PSP emulation netdevsim already has: TX puts the plaintext record on the wire, RX just sets skb->decrypted. That only works with netdevsim on both ends and offload on in both directions, which is what the netdevsim environment of the drivers/net tests gives. It still covers record assembly and the offload lifecycle.

[1] https://lore.kernel.org/netdev/[email protected]/

v1 -> v2:
- drop the netdevsim-only selftest, run the upstream tls_hw_offload.py
on netdevsim instead so the test also covers real hardware (Jakub)
- rebase on net-next
v1: https://lore.kernel.org/netdev/[email protected]/
RFC (July): https://lore.kernel.org/netdev/[email protected]/

Jiayuan Chen (2):
netdevsim: add TLS device offload emulation
selftests: drv-net: run tls_hw_offload on netdevsim

 drivers/net/Kconfig                           |   1 +
 drivers/net/netdevsim/Makefile                |   4 +
 drivers/net/netdevsim/netdev.c                |   9 +-
 drivers/net/netdevsim/netdevsim.h             |  34 ++
 drivers/net/netdevsim/tls.c                   | 477 ++++++++++++++++++
 .../drivers/net/hw/tls_hw_offload.py          |   5 +-
 6 files changed, 527 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/netdevsim/tls.c
Signature · 1 line
2.43.0