Linux Documentation
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: toddfreed@meta.com
Cc: netdev@vger.kernel.org, davem@davemloft.net,
	andrew+netdev@lunn.ch, bjorn@kernel.org, bpf@vger.kernel.org,
	daniel@iogearbox.net, daniel.zahka@gmail.com,
	donald.hunter@gmail.com, edumazet@kernel.org, kuba@kernel.org,
	jhs@mojatatu.com, jiri@resnulli.us, john.fastabend@gmail.com,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, linux-rdma@vger.kernel.org,
	martin.lau@linux.dev, pabeni@redhat.com, saeedm@nvidia.com,
	horms@kernel.org, tariqt@nvidia.com, weiwan@google.com,
	willemdebruijn.kernel@gmail.com
Subject: Re: [PATCH net-next v1 15/15] Documentation: networking: psp: document socket-less associations
Date: Sun, 15 Nov 2026 03:18:31 +0000	[thread overview]
Message-ID: <179471271167.2199510.6222235735319435450@kernel.org> (raw)
In-Reply-To: <20261111005533.6436-16-toddfreed@meta.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] The new psp.rst text says, in the `psp encap assoc ID` bullet,
  "Encap on ingress is hardware offload only." The header comment of…
- [Low] In psp.rst, the `psp encap assoc ID` bullet says: "If the
  association is removed before transmit, or if the packet is…
- [Low] In the flower paragraph, psp.rst says the `psp_spi`, `psp_ver`
  and `psp_dev` matches together "tie a decap rule to one Rx…

--

Documentation: networking: psp: document socket-less associations

This commit reorganizes the PSP documentation around associations. It
documents the new netlink commands for socket-less associations, the psp
tc action and the flower psp_spi, psp_ver and psp_dev matches. It also
adds sections on fragments and on PSP device statistics.

> diff --git a/Documentation/networking/psp.rst b/Documentation/networking/psp.rst
> index 0f9b6b73f2447..79b101db5dfc4 100644
> --- a/Documentation/networking/psp.rst
> +++ b/Documentation/networking/psp.rst

[ ... ]

> @@ -140,6 +162,55 @@ The PSP assoc state of a socket is not reset when the connection is
>  torn down. ``connect()`` on a socket that has PSP assoc state will
>  return ``-EINVAL``.
>  
> +Socket-less associations
> +~~~~~~~~~~~~~~~~~~~~~~~~
> +

[ ... ]

> +- ``assoc-del`` deletes an association. tc actions and packets which still
> +  reference it keep it alive. The device keeps decrypting the SPI of a
> +  deleted Rx association until its device key is rotated out: remove the
> +  decap rule to stop taking its packets.

[ ... ]

> +- ``psp encap assoc ID`` attaches a Tx association. The packet must then
> +  be transmitted on the main netdev of the association's PSP device, which
> +  encrypts it (``mirred egress redirect``). If the association is removed
> +  before transmit, or if the packet is transmitted on any other device,
> +  it will be dropped, rather than sent in the clear. Encap on ingress is
> +  hardware offload only.

[Severity: Low]
Is the part that says "If the association is removed before transmit ...
it will be dropped" accurate? It conflicts with the assoc-del bullet above
and with the assoc-del doc in Documentation/netlink/specs/psp.yaml:

    Packets and tc actions which still reference it keep it alive.

In the code, psp_nl_assoc_del_doit() only calls psp_assoc_unpublish().
That removes the ID from the registry and drops the registry's reference:

net/psp/psp_assoc.c:psp_assoc_unpublish() {
    ...
	if (xa_cmpxchg(&psp_assocs, pas->id, pas, NULL, 0) == pas)
		psp_assoc_put(pas);
    ...
}

The METADATA_PSP dst created by tcf_psp_md_create() keeps its own
reference. tcf_psp_act() also keeps attaching dst_clone(&params->md->dst)
to every packet.

On transmit, psp_xmit_md() checks only the device and the MTU. It never
checks whether the association was deleted:

include/net/psp/functions.h:psp_xmit_md() {
    ...
	if (rcu_access_pointer(dev->psp_dev) != pas->psd ||
	    dev != pas->psd->main_netdev)
		return -EINVAL;
    ...
}

So after assoc-del, packets are still encrypted and sent with the deleted
association's key until the tc action is removed. A drop seems to happen
only when the packet loses its METADATA_PSP dst, or when the PSP device
does not match or has been unregistered.

Would "if the packet loses its association on the way (e.g. its dst is
replaced)" describe this more accurately?

[Severity: Low]
Is "Encap on ingress is hardware offload only" accurate for this series?
act_psp_ops in net/sched/act_psp.c does not set .offload_act_setup:

static struct tc_action_ops act_psp_ops = {
	.kind		=	"psp",
	.id		=	TCA_ID_PSP,
	.owner		=	THIS_MODULE,
	.act		=	tcf_psp_act,
	.dump		=	tcf_psp_dump,
	.init		=	tcf_psp_init,
	.cleanup	=	tcf_psp_cleanup,
	.size		=	sizeof(struct tcf_psp),
};

Because of that, tc_setup_offload_act() in net/sched/cls_api.c rejects the
action:

	} else {
		NL_SET_ERR_MSG(extack, "Action does not support offload");
		return -EOPNOTSUPP;
	}

In software, tcf_psp_act() always drops encap at ingress:

		if (unlikely(skb_at_tc_ingress(skb)))
			return tcf_psp_drop(p, skb, SKB_DROP_REASON_PSP_OUTPUT);

So ingress encap cannot work in any configuration today. The flower commit
in this series says offload will come in a follow-up series.

Should this say that ingress encap is not supported (the packet is always
dropped) and that hardware offload is future work? The header comment in
net/sched/act_psp.c makes the same claim.

[ ... ]

> +The flower classifier matches what a packet was decrypted with:
> +``psp_spi SPI[/MASK]``, ``psp_ver VERSION`` and ``psp_dev DEV_ID``, the
> +ID of the PSP device which decrypted it. These never match a clear text
> +packet, so ``psp_spi 0/0`` matches any packet decrypted with PSP.
> +Together they tie a decap rule to one Rx association.
> +
> +Once the device key an SPI was created from has been rotated twice, that
> +association is considered stale. Unlike sockets, tc does not handle key
> +rotation. userspace should replace such rules before two rotations.

[Severity: Low]
Does "Together they tie a decap rule to one Rx association" overstate what
the match guarantees? The flow key built by skb_flow_dissect_psp() carries
only these fields:

	key->spi = pse->spi;
	key->dev_id = pse->dev_id;
	key->version = pse->version;
	key->present = 1;

It has no key generation and no association identity. SPI values get
reused after key rotation. For example, nsim_key_rotate() in netdevsim
resets the SPI counter:

	if (ns->psp.spi & PSP_SPI_KEY_PHASE)
		ns->psp.spi = 0;
	else
		ns->psp.spi = PSP_SPI_KEY_PHASE;

After two rotations, the same SPI can be given to a different peer or to a
socket association under a new key. If the old decap rule is still in
place, it would strip SKB_EXT_PSP and skb->decrypted from that other
association's packets and forward them.

PSP device IDs are also allocated cyclically in a 16-bit space in
psp_dev_create():

	err = xa_alloc_cyclic(&psp_devs, &psd->id, psd, xa_limit_16b,
			      &last_id, GFP_KERNEL);

After enough unregister/register cycles, a stale psp_dev match could end
up matching a different device.

The next paragraph says userspace should replace rules before two
rotations. It does not say that a stale rule will match other
associations' traffic, and it does not mention device ID reuse.

The flower commit in this series says "the generation of the device key is
not checked". Could the doc include the same qualification here?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261111005533.6436-1-toddfreed%40meta.com

  reply	other threads:[~2026-11-15  3:18 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11  0:55 [PATCH net-next v1 00/15] psp: introduce socket-less associations Todd Freed
2026-11-11  0:55 ` [PATCH net-next v1 01/15] psp: get netns from net_device instead of sock Todd Freed
2026-11-11  0:55 ` [PATCH net-next v1 02/15] psp: take the psp nexthdr from the packet on encap Todd Freed
2026-11-15  3:18   ` netdev-bot+sashiko
2026-11-11  0:55 ` [PATCH net-next v1 03/15] psp: declare psp_assoc_set_tx() in psp.h Todd Freed
2026-11-11  0:55 ` [PATCH net-next v1 04/15] psp: add support for socket-less psp associations Todd Freed
2026-11-11 16:49   ` Daniel Zahka
2026-11-11 18:23     ` Todd Bert Freed
2026-11-11 19:01       ` Daniel Zahka
2026-11-11 21:49         ` Todd Bert Freed
2026-11-12  0:51     ` Todd Bert Freed
2026-11-15  3:18   ` netdev-bot+sashiko
2026-11-11  0:55 ` [PATCH net-next v1 05/15] net: add METADATA_PSP dst to carry a psp association on an skb Todd Freed
2026-11-15  3:18   ` netdev-bot+sashiko
2026-11-11  0:55 ` [PATCH net-next v1 06/15] net/sched: act_mirred: don't send decrypted skbs from egress to ingress Todd Freed
2026-11-15  3:18   ` netdev-bot+sashiko
2026-11-11  0:55 ` [PATCH net-next v1 07/15] bpf: don't redirect " Todd Freed
2026-11-15  3:18   ` netdev-bot+sashiko
2026-11-11  0:55 ` [PATCH net-next v1 08/15] psp: only give time-wait sockets of psp connections a validator Todd Freed
2026-11-11 11:37   ` Daniel Zahka
2026-11-15  3:18   ` netdev-bot+sashiko
2026-11-11  0:55 ` [PATCH net-next v1 09/15] net/sched: add act_psp for psp transport mode Todd Freed
2026-11-15  3:18   ` netdev-bot+sashiko
2026-11-11  0:55 ` [PATCH net-next v1 10/15] net/sched: flower: add psp_spi, psp_ver, and psp_dev matches Todd Freed
2026-11-15  3:18   ` netdev-bot+sashiko
2026-11-11  0:55 ` [PATCH net-next v1 11/15] selftests: drv-net: psp: test socket-less associations and the tc psp action Todd Freed
2026-11-11  0:55 ` [PATCH net-next v1 12/15] selftests: drv-net: psp: test that software encap on ingress drops Todd Freed
2026-11-11  0:55 ` [PATCH net-next v1 13/15] selftests: tc-testing: run dependsOn probes outside the test namespace Todd Freed
2026-11-15  3:18   ` netdev-bot+sashiko
2026-11-11  0:55 ` [PATCH net-next v1 14/15] selftests: tc-testing: add tests for the psp action Todd Freed
2026-11-15  3:18   ` netdev-bot+sashiko
2026-11-11  0:55 ` [PATCH net-next v1 15/15] Documentation: networking: psp: document socket-less associations Todd Freed
2026-11-15  3:18   ` netdev-bot+sashiko [this message]
2026-11-11 17:01 ` [PATCH net-next v1 00/15] psp: introduce " Daniel Zahka
2026-11-12 19:35   ` Todd Bert Freed
2026-11-13 15:45 ` Jamal Hadi Salim
2026-11-13 16:21   ` Jamal Hadi Salim
2026-11-13 19:08     ` Todd Bert Freed

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=179471271167.2199510.6222235735319435450@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel.zahka@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    --cc=toddfreed@meta.com \
    --cc=weiwan@google.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