From: netdev-bot+sashiko@kernel.org
To: daniel.zahka@gmail.com
Cc: kuba@kernel.org, willemdebruijn.kernel@gmail.com,
davem@davemloft.net, edumazet@kernel.org, pabeni@redhat.com,
horms@kernel.org, corbet@lwn.net, skhan@linuxfoundation.org,
rdunlap@infradead.org, donald.hunter@gmail.com,
andrew+netdev@lunn.ch, shuah@kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net-next v2 4/7] psp: add core tracked stat for outstanding tx keys
Date: Sat, 10 Oct 2026 21:43:45 +0000 [thread overview]
Message-ID: <179166862537.434549.3280314687131205952@kernel.org> (raw)
In-Reply-To: <20261009-psp-v2-4-5596ab50f677@gmail.com>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] psp_dev_tx_key_del() (net/psp/psp_sock.c) calls
psd->ops->tx_key_del(psd, pas) and then always decrements…
--
psp: add core tracked stat for outstanding tx keys
This commit adds a core-maintained tx_key_cnt to psd->stats. The counter
goes up when tx_key_add() succeeds and down in psp_dev_tx_key_del(). It is
reported to userspace as tx-key-count, but only for drivers that use an
SADB, and psp_dev_unregister() warns if any keys are still outstanding.
> diff --git a/Documentation/netlink/specs/psp.yaml b/Documentation/netlink/specs/psp.yaml
> index f3266763c3253..d14c11d098914 100644
> --- a/Documentation/netlink/specs/psp.yaml
> +++ b/Documentation/netlink/specs/psp.yaml
> @@ -190,6 +190,13 @@ attribute-sets:
> doc: |
> Number of PSP packets for transmission with errors.
> Device statistic (from the PSP spec).
> + -
> + name: tx-key-count
> + type: uint
> + doc: |
> + Current number of Tx keys installed on the device.
> + Only visible if the driver stores keys on device.
> + Kernel statistic.
[ ... ]
> diff --git a/net/psp/psp_sock.c b/net/psp/psp_sock.c
> index d21f7afd830a3..c458bc551b4b9 100644
> --- a/net/psp/psp_sock.c
> +++ b/net/psp/psp_sock.c
[ ... ]
> @@ -105,6 +107,8 @@ static int psp_dev_tx_key_add(struct psp_dev *psd, struct psp_assoc *pas,
> void psp_dev_tx_key_del(struct psp_dev *psd, struct psp_assoc *pas)
> {
> psd->ops->tx_key_del(psd, pas);
> + if (!WARN_ON_ONCE(!psd->stats.tx_key_cnt))
> + psd->stats.tx_key_cnt--;
> }
[Severity: Low]
Is tx-key-count really the number of keys installed on the device? The
YAML doc says "Current number of Tx keys installed on the device". The
commit message says it counts keys "from the hw's perspective" and can show
whether "a device is approaching its SADB capacity".
struct psp_dev_ops::tx_key_del returns void, so psp_dev_tx_key_del()
decrements the counter whether or not the device actually freed the entry.
In mlx5, which is the only SADB driver, the delete path drops any firmware
error:
drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp.c:mlx5e_psp_assoc_del() {
...
nkey = (struct psp_key *)pas->drv_data;
mlx5_destroy_encryption_key(priv->mdev, nkey->id);
atomic_dec(&psp->tx_key_cnt);
}
drivers/net/ethernet/mellanox/mlx5/core/lib/crypto.c:mlx5_crypto_destroy_dek_key() {
...
mlx5_cmd_exec(mdev, in, sizeof(in), out, sizeof(out));
}
The call path is psp_assoc_free(), psp_deferred_del_work() or
psp_deferred_del_uninit(), then psp_dev_tx_key_del(), then
mlx5e_psp_assoc_del(), then mlx5_destroy_encryption_key().
If MLX5_CMD_OP_DESTROY_GENERAL_OBJECT fails (bad status or timeout), the
DEK can stay allocated on the device while tx_key_cnt still goes down. In
that case the stat would read lower than real SADB occupancy.
The counter still catches missing tx_key_del calls in the core. It does
not catch failed deletes on the device side.
Should the doc and commit message describe this as a count of keys the
stack believes are installed? The alternative would be for tx_key_del to
return an error, so the core can skip the decrement when the device-side
delete fails.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261009-psp-v2-0-5596ab50f677%40gmail.com
next prev parent reply other threads:[~2026-10-10 21:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 20:46 [PATCH net-next v2 0/7] psp: support rekeying psp protected tcp connections Daniel Zahka
2026-10-09 20:46 ` [PATCH net-next v2 1/7] psp: support rx rekey operation Daniel Zahka
2026-10-10 21:43 ` netdev-bot+sashiko
2026-10-09 20:46 ` [PATCH net-next v2 2/7] psp: support tx " Daniel Zahka
2026-10-10 21:43 ` netdev-bot+sashiko
2026-10-09 20:46 ` [PATCH net-next v2 3/7] psp: defer tx key deletions for SADB drivers Daniel Zahka
2026-10-10 21:43 ` netdev-bot+sashiko
2026-10-09 20:46 ` [PATCH net-next v2 4/7] psp: add core tracked stat for outstanding tx keys Daniel Zahka
2026-10-10 21:43 ` netdev-bot+sashiko [this message]
2026-10-09 20:46 ` [PATCH net-next v2 5/7] selftests: drv-net: psp: factor out psp connection setup Daniel Zahka
2026-10-10 21:43 ` netdev-bot+sashiko
2026-10-09 20:46 ` [PATCH net-next v2 6/7] selftests: drv-net: psp: add rekey tests Daniel Zahka
2026-10-10 21:43 ` netdev-bot+sashiko
2026-10-09 20:46 ` [PATCH net-next v2 7/7] selftests: drv-net: psp: add a tx rekey drain test for SADB drivers Daniel Zahka
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=179166862537.434549.3280314687131205952@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=corbet@lwn.net \
--cc=daniel.zahka@gmail.com \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rdunlap@infradead.org \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
--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
all inboxes | Powered by JetHome®