Skip to content

psp: introduce socket-less associations

Todd Freed linux-doc linux-kselftest linux-rdma lkml netdev 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest12 patches 0 repliesNew
  2. v115 patches 22 repliesSuperseded

Changes in v2 from the cover letter

- Moved the mirred, bpf and time-wait validator fixes (v1 patches 6-8) to a net series, with Fixes tags. (Daniel)
- Don't store Rx associations at all (Daniel)
- Keep socket-less Tx associations on their own device list (Daniel)
- Documentation: the userspace key rotation contract, and the use of tc action cookies, filter handles and a chain per key phase to track decap rules. (Daniel)
- act_psp: add .get_fill_size. (Sashiko, Jamal)
- psp.py: use ctl_file_write(), and _check_data_outq() to wait for retransmits. (Sashiko)
- tc-testing dependsOn fix: add a Fixes tag, and document the probe stage. (Sashiko)
- Outer UDP source port: only use sk_hash for TCP sockets. (Sashiko)
- flower: don't offload a rule which uses the PSP matches, and reject it with skip_sw, until a driver supports them: some drivers would offload it without them. (Sashiko)
- Moved the drop of a packet with both a socket offload and a METADATA_PSP dst to the METADATA_PSP patch, with the rest of sk_validate_xmit_skb().
- Say that encap on ingress isn't supported, rather than hardware offload only, in act_psp.c, psp.rst and the commit messages. (Sashiko)
- psp.rst: an encapped packet is dropped if it loses its association or the PSP device is unregistered, not when the association is deleted. (Sashiko)
- tc-testing: the tests of rejected psp actions match the kernel's extack, the decap with an association and encap without an association tests are dropped (tc rejects those itself), and the flower decap tests also probe for the psp action. (Sashiko)
- Rebased on net-next.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12psp: get netns from net_device instead of sockdrivers/net/ethernet/mellanox/mlx5/core/en_accel/psp_rxtx.c drivers/net/netdevsim/psp.c net/psp/psp_main.c+3 -30 replies
2/12psp: take the psp nexthdr from the packet on encapdrivers/net/ethernet/mellanox/mlx5/core/en_main.c net/psp/psp_main.c+79 -100 replies
3/12psp: declare psp_assoc_set_tx() in psp.hnet/psp/psp.h net/psp/psp_sock.c+15 -30 replies
4/12psp: add support for socket-less psp associationsDocumentation/netlink/specs/psp.yaml include/net/psp/functions.h include/net/psp/types.h +9 more+542 -10 replies
5/12net: add METADATA_PSP dst to carry a psp association on an skbinclude/net/dst_metadata.h include/net/psp/functions.h net/core/dev.c +1 more+146 -90 replies
6/12net/sched: add act_psp for psp transport modeMAINTAINERS include/net/tc_act/tc_psp.h include/uapi/linux/pkt_cls.h +4 more+508 -00 replies
7/12net/sched: flower: add psp_spi, psp_ver, and psp_dev matchesDocumentation/netlink/specs/tc.yaml include/linux/skbuff.h include/net/flow_dissector.h +3 more+142 -00 replies
8/12selftests: drv-net: psp: test socket-less associations and the tc psp actiontools/testing/selftests/drivers/net/config tools/testing/selftests/drivers/net/psp.py+570 -50 replies
9/12selftests: drv-net: psp: test that software encap on ingress dropstools/testing/selftests/drivers/net/config tools/testing/selftests/drivers/net/psp.py+159 -20 replies
10/12selftests: tc-testing: run dependsOn probes outside the test namespacetools/testing/selftests/tc-testing/README tools/testing/selftests/tc-testing/creating-testcases/AddingTestCases.txt tools/testing/selftests/tc-testing/tdc.py+5 -20 replies
11/12selftests: tc-testing: add tests for the psp actiontools/testing/selftests/tc-testing/config tools/testing/selftests/tc-testing/tc-tests/actions/psp.json tools/testing/selftests/tc-testing/tdc.sh+406 -00 replies
12/12Documentation: networking: psp: document socket-less associationsDocumentation/networking/psp.rst+153 -160 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 00/12] psp: introduce socket-less associations

PSP associations today are bound to a TCP socket when created. Traffic on that socket is encapsulated in transport mode PSP, and encrypted.

This series adds PSP which isn't bound to a socket, which allows PSP encapsulation and encryption to be applied to forwarded traffic. You can use this to transparently apply PSP to flows, with help from userspace to manage the tc rules and orchestrate key exchange.

Socket-less PSP is managed over the PSP netlink family. Tx associations hold the peer's key in the device, and are addressable by ID, for the tc psp encap action. Rx does not have any kernel state.

Since the kernel keeps no Rx state, it doesn't enforce key rotation for socket-less Rx. Userspace must remove the decap rules of an SPI before a second rotation lets the device allocate the same SPI again. The documentation patch describes this, with ways to use tc to keep track of the rules.

Series structure:

1, 2/ Prepare PSP to work with non-TCP packets.

3, 4/ Add the netlink commands for socket-less PSP.

5/ Adds a METADATA_PSP dst which carries a socket-less PSP association on an skb for Tx, and the transmit checks for it.

6/ Adds the act_psp tc action, psp encap and psp decap. Encap is egress only.

7/ Adds flower matches on PSP header fields, for Rx matching.

8, 9/ Add drv-net tests (netdevsim and hardware).

10/ Makes tc-testing run dependsOn probes outside the test namespace, where they currently always fail.

11/ Adds tc-testing tests.

12/ Documentation for socket-less PSP.

A following series adds hardware offload of the psp actions and flower matches, PSP tunnel mode (which is offload only and therefore not included here), encap on ingress (also offload only), and the mlx5 implementation for switchdev mode. It's available in the tree below.

Dependency on net:

v1 patches 6-8 are now a separate series to net:

"net: don't redirect decrypted skbs to ingress, psp time-wait validator"

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

This series builds without it, but relies on it: act_psp marks the packets it encaps decrypted, which mirred and bpf must not send back to ingress (the data_tc_encap_ingress test fails without the fix), and act_psp drops packets of sockets with a validator, which non-PSP time-wait sockets have without the fix.

Relation to the PSP fixes in net:

"psp, tls: don't send offloaded contents in cleartext"

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

When net is merged into net-next:

- net/psp/psp_main.c conflicts around psp_dev_encap_ok(), which both
add: net's only allows TCP, this series' (patch 2) takes any L4 protocol. Keep this series' version of the function, and its comments above it and above psp_dev_encapsulate().
- tools/testing/selftests/drivers/net/psp.py and tools/testing/selftests/drivers/net/config conflict: keep both sides (imports, constants, the list of test cases; the NET_ACT_* options).

Relation to the netfilter fixes in nf-next:

Packets which a PSP device decrypted don't have to end in a local PSP socket. They can already be forwarded or bridged today, but with socket-less PSP that is the intended use, e.g. a router that decaps and forwards. Netfilter handles two cases itself, outside the IP stack paths which the net series fixes, and would send such a packet's decrypted contents in clear text:

- The bridge refragments packets which bridge conntrack reassembled (br_ip6_fragment(), nf_br_ip_fragment()), without the check of "net:
don't fragment decrypted skbs".
- The reject code builds its own ICMP errors and TCP resets (nf_reject_skb_v4_unreach() and friends), without icmp_send() and icmpv6_send(), which the net series' ICMP patches cover.

A separate series to nf-next applies the net series' rules to both:

"netfilter: bridge: don't refragment decrypted skbs" "netfilter: reject: don't reply to decrypted skbs"

https://lore.kernel.org/netfilter-devel/[email protected]

It doesn't depend on this series, and the two don't conflict.

Trees:

The full tree, with the net fixes, the nf-next series, this series and the mlx5 offload series, and the conflicts above resolved, is at:

https://github.com/toddfreed/psptc branch psptc

iproute2 support for the psp action and the PSP flower matches, which the selftests need, is posted to iproute2-next as "tc: add the psp action and flower psp matches", and at:

https://github.com/toddfreed/iproute2-psptc branch tc-psp

It needs no change for v2: the tc uAPI is the same.

Testing:

- netdevsim: drivers/net psp.py passes (57 tests), and tc-testing psp.json (15 tests), with the net fixes series applied and tc from the iproute2-next series.
- mlx5 (ConnectX-7, FW 28.48), two hosts: drivers/net psp.py passes:
46 pass, 8 skip (GMAC versions not supported by the device), 3 xfail (netdevsim only), with the net fixes series applied.
- Each patch builds without warnings with gcc and clang, allmodconfig, W=1.

v2:
- Moved the mirred, bpf and time-wait validator fixes (v1 patches 6-8) to a net series, with Fixes tags. (Daniel)
- Don't store Rx associations at all (Daniel)
- Keep socket-less Tx associations on their own device list (Daniel)
- Documentation: the userspace key rotation contract, and the use of tc action cookies, filter handles and a chain per key phase to track decap rules. (Daniel)
- act_psp: add .get_fill_size. (Sashiko, Jamal)
- psp.py: use ctl_file_write(), and _check_data_outq() to wait for retransmits. (Sashiko)
- tc-testing dependsOn fix: add a Fixes tag, and document the probe stage. (Sashiko)
- Outer UDP source port: only use sk_hash for TCP sockets. (Sashiko)
- flower: don't offload a rule which uses the PSP matches, and reject it with skip_sw, until a driver supports them: some drivers would offload it without them. (Sashiko)
- Moved the drop of a packet with both a socket offload and a METADATA_PSP dst to the METADATA_PSP patch, with the rest of sk_validate_xmit_skb().
- Say that encap on ingress isn't supported, rather than hardware offload only, in act_psp.c, psp.rst and the commit messages. (Sashiko)
- psp.rst: an encapped packet is dropped if it loses its association or the PSP device is unregistered, not when the association is deleted. (Sashiko)
- tc-testing: the tests of rejected psp actions match the kernel's extack, the decap with an association and encap without an association tests are dropped (tc rejects those itself), and the flower decap tests also probe for the psp action. (Sashiko)
- Rebased on net-next.

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

Todd Freed (12):
psp: get netns from net_device instead of sock
psp: take the psp nexthdr from the packet on encap
psp: declare psp_assoc_set_tx() in psp.h
psp: add support for socket-less psp associations
net: add METADATA_PSP dst to carry a psp association on an skb net/sched: add act_psp for psp transport mode
net/sched: flower: add psp_spi, psp_ver, and psp_dev matches
selftests: drv-net: psp: test socket-less associations and the tc psp
action
selftests: drv-net: psp: test that software encap on ingress drops
selftests: tc-testing: run dependsOn probes outside the test namespace
selftests: tc-testing: add tests for the psp action
Documentation: networking: psp: document socket-less associations

 Documentation/netlink/specs/psp.yaml          |  91 +++
 Documentation/netlink/specs/tc.yaml           |  14 +
 Documentation/networking/psp.rst              | 169 +++-
 MAINTAINERS                                   |   3 +
 .../mellanox/mlx5/core/en_accel/psp_rxtx.c    |   2 +-
 .../net/ethernet/mellanox/mlx5/core/en_main.c |  33 +
 drivers/net/netdevsim/psp.c                   |   2 +-
 include/linux/skbuff.h                        |   4 +
 include/net/dst_metadata.h                    |  19 +
 include/net/flow_dissector.h                  |  18 +
 include/net/psp/functions.h                   |  82 +-
 include/net/psp/types.h                       |   2 +
 include/net/tc_act/tc_psp.h                   |  23 +
 include/uapi/linux/pkt_cls.h                  |   6 +
 include/uapi/linux/psp.h                      |   6 +
 include/uapi/linux/tc_act/tc_psp.h            |  28 +
 net/core/dev.c                                |  50 +-
 net/core/dst.c                                |   5 +
 net/core/flow_dissector.c                     |  27 +
 net/psp/Makefile                              |   2 +-
 net/psp/psp-nl-gen.c                          |  60 ++
 net/psp/psp-nl-gen.h                          |   8 +
 net/psp/psp.h                                 |   7 +
 net/psp/psp_assoc.c                           | 122 +++
 net/psp/psp_main.c                            |  62 +-
 net/psp/psp_nl.c                              | 242 ++++++
 net/psp/psp_sock.c                            |  16 +-
 net/sched/Kconfig                             |  13 +
 net/sched/Makefile                            |   1 +
 net/sched/act_psp.c                           | 439 +++++++++++
 net/sched/cls_flower.c                        |  74 ++
 tools/testing/selftests/drivers/net/config    |   5 +
 tools/testing/selftests/drivers/net/psp.py    | 729 +++++++++++++++++-
 tools/testing/selftests/tc-testing/README     |   1 +
 tools/testing/selftests/tc-testing/config     |   2 +
 .../creating-testcases/AddingTestCases.txt    |   4 +-
 .../tc-testing/tc-tests/actions/psp.json      | 403 ++++++++++
 tools/testing/selftests/tc-testing/tdc.py     |   2 +-
 tools/testing/selftests/tc-testing/tdc.sh     |   1 +
 39 files changed, 2727 insertions(+), 50 deletions(-)
 create mode 100644 include/net/tc_act/tc_psp.h
 create mode 100644 include/uapi/linux/tc_act/tc_psp.h
 create mode 100644 net/psp/psp_assoc.c
 create mode 100644 net/sched/act_psp.c
 create mode 100644 tools/testing/selftests/tc-testing/tc-tests/actions/psp.json

base-commit: 89f0fb60afdb35cf2a94e6279c8960feb1c4d1d4

Signature · 1 line
2.53.1-Meta