The PSP architecture spec specifies the need for rekeying connections in the event of a device key rotation. After a device key rotation has occurred, a new rx derived key needs to be generated and sent out to the other end of the connection sometime before the next device key rotation occurs.
Because PSP connections involve two different keys at each endpoint, one for decrypting ingress traffic, and one for encrypting egress traffic, there are two types of rekeying events that need to be supported. From the perspective of one endpoint of the connection: 1. rx rekey: we need to allocate a new spi and decryption key on the current device key to provide to our peer. 2. tx rekey: our peer has provided us with a new spi + encryption key pair which we should use for encrypting traffic immediately. In the case of rx rekeying, there is a period where it makes sense to accept packets authenticated from either the previous or current spi. To deal with that we allow a socket to keep a chain of a max of two psp assocs at any time. If authentication state does not match the most recent assoc, the previous one will be tried. In the case of tx rekeying, as soon as we install the new tx key, we have no use for the previous one, and it can be disposed of immediately. The only catch, is in the case where hw uses a key handle in tx descriptor state (as opposed to inlining the key directly). If this is the case, psp core needs to be sure that any of these unaccounted for references to key state are gone by the time it tries to sync a deleted key to hw. To deal with this race condition, the series includes a driver api for implementing deferred tx key deletion, where the driver can signal back to the core when it is safe to dispose of old tx keys. Lastly, some test cases for rekeying are included that go through key rotations and rekeying. Signed-off-by: Daniel Zahka <[email protected]> --- Daniel Zahka (9): psp: support rx rekey operation psp: move code from psp_sock_assoc_set_tx() into helper functions psp: support tx rekey operation psp: refactor psp_dev_tx_key_del() psp: add driver api for deferred tx key deletion psp: add core tracked stats for deferred key deletion mlx5: psp: implement deferred tx key deletion selftests: drv-net: psp: lift psp connection setup out of _data_basic_send() testcase selftests: drv-net: psp: add tests for rekeying connections Documentation/netlink/specs/psp.yaml | 14 ++ .../net/ethernet/mellanox/mlx5/core/en_accel/psp.c | 101 +++++++++- .../net/ethernet/mellanox/mlx5/core/en_accel/psp.h | 7 + drivers/net/ethernet/mellanox/mlx5/core/en_stats.h | 1 + drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 1 + include/net/psp/functions.h | 6 + include/net/psp/types.h | 39 ++++ include/uapi/linux/psp.h | 2 + net/psp/psp.h | 7 +- net/psp/psp_main.c | 101 +++++++++- net/psp/psp_nl.c | 9 +- net/psp/psp_sock.c | 213 +++++++++++++++------ tools/testing/selftests/drivers/net/psp.py | 133 ++++++++++++- .../testing/selftests/drivers/net/psp_responder.c | 131 +++++++++++++ 14 files changed, 685 insertions(+), 80 deletions(-) --- base-commit: 9a9424c756feee9ee6e717405a9d6fa7bacdef08 change-id: 20260202-psp-3c8e2f65c5c4 Best regards, -- Daniel Zahka <[email protected]>
