Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Todd Freed <toddfreed@meta.com>
To: <netdev@vger.kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>,
	"Andrew Lunn" <andrew+netdev@lunn.ch>,
	"Björn Töpel" <bjorn@kernel.org>,
	"Boris Pismenny" <borisp@nvidia.com>,
	"Cosmin Ratiu" <cratiu@nvidia.com>,
	"Daniel Zahka" <daniel.zahka@gmail.com>,
	"Donald Hunter" <donald.hunter@gmail.com>,
	"Dragos Tatulea" <dtatulea@nvidia.com>,
	"Eric Dumazet" <edumazet@kernel.org>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Jamal Hadi Salim" <jhs@mojatatu.com>,
	"Jiri Pirko" <jiri@resnulli.us>,
	"Leon Romanovsky" <leon@kernel.org>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, linux-rdma@vger.kernel.org,
	"Mark Bloch" <mbloch@nvidia.com>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Pedro Tammela" <pctammela@mojatatu.com>,
	"Saeed Mahameed" <saeedm@nvidia.com>,
	"Simon Horman" <horms@kernel.org>,
	"Tariq Toukan" <tariqt@nvidia.com>,
	"Wei Wang" <weiwan@google.com>,
	"Willem de Bruijn" <willemdebruijn.kernel@gmail.com>
Subject: [PATCH net-next v2 01/12] psp: get netns from net_device instead of sock
Date: Wed, 18 Nov 2026 17:30:52 -0800	[thread overview]
Message-ID: <20261119013103.1092559-2-toddfreed@meta.com> (raw)
In-Reply-To: <20261119013103.1092559-1-toddfreed@meta.com>

Every PSP skb is related to a socket today, but that will no longer be
true once a PSP association can be attached to the skb by other means,
such as the tc psp action added later in the series.

Get the netns from the transmitting device instead.

For the outer source port range, psp_write_headers() now explicitly uses
sock_net(sk) in the socket case specifically, to maintain the existing
behavior.

Signed-off-by: Todd Freed <toddfreed@meta.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp_rxtx.c | 2 +-
 drivers/net/netdevsim/psp.c                                 | 2 +-
 net/psp/psp_main.c                                          | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp_rxtx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp_rxtx.c
index 348fd7a96261..8b474f75dd61 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp_rxtx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/psp_rxtx.c
@@ -165,7 +165,7 @@ bool mlx5e_psp_handle_tx_skb(struct net_device *netdev,
 			     struct mlx5e_accel_tx_psp_state *psp_st)
 {
 	struct mlx5e_priv *priv = netdev_priv(netdev);
-	struct net *net = sock_net(skb->sk);
+	struct net *net = dev_net(netdev);
 
 	if (!mlx5e_psp_set_state(priv, skb, psp_st))
 		return true;
diff --git a/drivers/net/netdevsim/psp.c b/drivers/net/netdevsim/psp.c
index b7452c49b581..0701f38aee6d 100644
--- a/drivers/net/netdevsim/psp.c
+++ b/drivers/net/netdevsim/psp.c
@@ -36,7 +36,7 @@ nsim_do_psp(struct sk_buff *skb, struct netdevsim *ns,
 		goto out_unlock;
 	}
 
-	net = sock_net(skb->sk);
+	net = dev_net(ns->netdev);
 	if (!psp_dev_encapsulate(net, skb, pas->tx.spi, pas->version, 0)) {
 		rc = SKB_DROP_REASON_PSP_OUTPUT;
 		goto out_unlock;
diff --git a/net/psp/psp_main.c b/net/psp/psp_main.c
index 273b010d2355..e09f6fec948d 100644
--- a/net/psp/psp_main.c
+++ b/net/psp/psp_main.c
@@ -221,7 +221,7 @@ static void psp_write_headers(struct net *net, struct sk_buff *skb, __be32 spi,
 		/* These operations are cheap, no need to cache the result
 		 * in another socket field.
 		 */
-		inet_get_local_port_range(net, &min, &max);
+		inet_get_local_port_range(sock_net(sk), &min, &max);
 		/* Since this is being sent on the wire obfuscate hash a bit
 		 * to minimize possibility that any useful information to an
 		 * attacker is leaked. Only upper 16 bits are relevant in the
-- 
2.53.1-Meta


  reply	other threads:[~2026-11-19  1:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  1:30 [PATCH net-next v2 00/12] psp: introduce socket-less associations Todd Freed
2026-11-19  1:30 ` Todd Freed [this message]
2026-11-19  1:30 ` [PATCH net-next v2 02/12] psp: take the psp nexthdr from the packet on encap Todd Freed
2026-11-19  1:30 ` [PATCH net-next v2 03/12] psp: declare psp_assoc_set_tx() in psp.h Todd Freed
2026-11-19  1:30 ` [PATCH net-next v2 04/12] psp: add support for socket-less psp associations Todd Freed
2026-11-19  1:30 ` [PATCH net-next v2 05/12] net: add METADATA_PSP dst to carry a psp association on an skb Todd Freed
2026-11-19  1:30 ` [PATCH net-next v2 06/12] net/sched: add act_psp for psp transport mode Todd Freed
2026-11-19  1:30 ` [PATCH net-next v2 07/12] net/sched: flower: add psp_spi, psp_ver, and psp_dev matches Todd Freed
2026-11-19  1:30 ` [PATCH net-next v2 08/12] selftests: drv-net: psp: test socket-less associations and the tc psp action Todd Freed
2026-11-19  1:31 ` [PATCH net-next v2 09/12] selftests: drv-net: psp: test that software encap on ingress drops Todd Freed
2026-11-19  1:31 ` [PATCH net-next v2 10/12] selftests: tc-testing: run dependsOn probes outside the test namespace Todd Freed
2026-11-19  1:31 ` [PATCH net-next v2 11/12] selftests: tc-testing: add tests for the psp action Todd Freed
2026-11-19  1:31 ` [PATCH net-next v2 12/12] Documentation: networking: psp: document socket-less associations Todd 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=20261119013103.1092559-2-toddfreed@meta.com \
    --to=toddfreed@meta.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bjorn@kernel.org \
    --cc=borisp@nvidia.com \
    --cc=cratiu@nvidia.com \
    --cc=daniel.zahka@gmail.com \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=dtatulea@nvidia.com \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=leon@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=mbloch@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pctammela@mojatatu.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.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