From: Daniel Zahka <daniel.zahka@gmail.com>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Donald Hunter <donald.hunter@gmail.com>,
Boris Pismenny <borisp@nvidia.com>,
Saeed Mahameed <saeedm@nvidia.com>,
Leon Romanovsky <leon@kernel.org>,
Tariq Toukan <tariqt@nvidia.com>, Mark Bloch <mbloch@nvidia.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Shuah Khan <shuah@kernel.org>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
Daniel Zahka <daniel.zahka@gmail.com>
Subject: [PATCH net-next 3/9] psp: support tx rekey operation
Date: Wed, 04 Feb 2026 07:20:07 -0800 [thread overview]
Message-ID: <20260204-psp-v1-3-5f034e2dfa36@gmail.com> (raw)
In-Reply-To: <20260204-psp-v1-0-5f034e2dfa36@gmail.com>
The tx rekey operation creates a new psp_assoc with the same rx state,
but with new tx state. The new psp_assoc will reference the current
assocs 'prev' assoc as its own. The assoc referenced by
'sk->psp_assoc' will have its reference dropped and be freed.
Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com>
---
net/psp/psp_sock.c | 51 +++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 45 insertions(+), 6 deletions(-)
diff --git a/net/psp/psp_sock.c b/net/psp/psp_sock.c
index 9b0ecce8350f..f429b8b2d8f2 100644
--- a/net/psp/psp_sock.c
+++ b/net/psp/psp_sock.c
@@ -215,6 +215,47 @@ psp_pas_set_tx_key(struct psp_dev *psd, struct psp_assoc *pas,
return rc;
}
+static int
+psp_sock_tx_rekey(struct sock *sk, struct psp_dev *psd, struct psp_assoc *pas,
+ struct psp_key_parsed *key, struct netlink_ext_ack *extack)
+{
+ struct psp_assoc *new;
+ size_t pas_sz;
+ int err;
+
+ pas_sz = struct_size(new, drv_data, psd->caps->assoc_drv_spc);
+ new = kzalloc(pas_sz, GFP_KERNEL_ACCOUNT);
+ if (!new)
+ return -ENOMEM;
+
+ /* don't increase refcounts until we know we won't fail */
+ new->psd = pas->psd;
+ new->dev_id = pas->dev_id;
+ new->generation = pas->generation;
+ new->version = pas->version;
+ new->peer_tx = pas->peer_tx;
+ new->upgrade_seq = pas->upgrade_seq;
+ new->prev = pas->prev;
+ refcount_set(&new->refcnt, 1);
+ memcpy(&new->rx, &pas->rx, sizeof(new->rx));
+
+ err = psp_pas_set_tx_key(psd, new, key, extack);
+ if (err) {
+ kfree(new);
+ return err;
+ }
+
+ psp_dev_get(new->psd);
+ if (new->prev)
+ refcount_inc(&new->prev->refcnt);
+ list_add_tail(&new->assocs_list, &psd->active_assocs);
+
+ rcu_assign_pointer(sk->psp_assoc, new);
+ psp_assoc_put(pas);
+
+ return 0;
+}
+
static int
psp_sock_set_tx_key(struct sock *sk, struct psp_dev *psd, struct psp_assoc *pas,
struct psp_key_parsed *key, struct netlink_ext_ack *extack)
@@ -269,13 +310,11 @@ int psp_sock_assoc_set_tx(struct sock *sk, struct psp_dev *psd,
err = -EINVAL;
goto exit_unlock;
}
- if (pas->tx.spi) {
- NL_SET_ERR_MSG(extack, "Tx key already set");
- err = -EBUSY;
- goto exit_unlock;
- }
+ if (pas->tx.spi)
+ err = psp_sock_tx_rekey(sk, psd, pas, key, extack);
+ else
+ err = psp_sock_set_tx_key(sk, psd, pas, key, extack);
- err = psp_sock_set_tx_key(sk, psd, pas, key, extack);
exit_unlock:
release_sock(sk);
return err;
--
2.47.3
next prev parent reply other threads:[~2026-02-04 15:20 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-04 15:20 [PATCH net-next 0/9] psp: support rekeying psp protected tcp connections Daniel Zahka
2026-02-04 15:20 ` [PATCH net-next 1/9] psp: support rx rekey operation Daniel Zahka
2026-02-07 4:24 ` Jakub Kicinski
2026-02-07 4:32 ` [net-next,1/9] " Jakub Kicinski
2026-02-04 15:20 ` [PATCH net-next 2/9] psp: move code from psp_sock_assoc_set_tx() into helper functions Daniel Zahka
2026-02-04 20:46 ` Willem de Bruijn
2026-02-04 15:20 ` Daniel Zahka [this message]
2026-02-04 15:20 ` [PATCH net-next 4/9] psp: refactor psp_dev_tx_key_del() Daniel Zahka
2026-02-04 20:46 ` Willem de Bruijn
2026-02-04 15:20 ` [PATCH net-next 5/9] psp: add driver api for deferred tx key deletion Daniel Zahka
2026-02-04 15:20 ` [PATCH net-next 6/9] psp: add core tracked stats for deferred " Daniel Zahka
2026-02-04 15:20 ` [PATCH net-next 7/9] mlx5: psp: implement deferred tx " Daniel Zahka
2026-02-07 4:30 ` Jakub Kicinski
2026-02-07 4:32 ` [net-next,7/9] " Jakub Kicinski
2026-02-04 15:20 ` [PATCH net-next 8/9] selftests: drv-net: psp: lift psp connection setup out of _data_basic_send() testcase Daniel Zahka
2026-02-04 20:49 ` Willem de Bruijn
2026-02-04 15:20 ` [PATCH net-next 9/9] selftests: drv-net: psp: add tests for rekeying connections Daniel Zahka
2026-02-04 20:45 ` [PATCH net-next 0/9] psp: support rekeying psp protected tcp connections Willem de Bruijn
2026-02-04 21:43 ` Daniel Zahka
2026-02-07 4:18 ` Jakub Kicinski
2026-02-07 4:21 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260204-psp-v1-3-5f034e2dfa36@gmail.com \
--to=daniel.zahka@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=borisp@nvidia.com \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedm@nvidia.com \
--cc=shuah@kernel.org \
--cc=tariqt@nvidia.com \
--cc=willemdebruijn.kernel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox