netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Daniel Zahka <daniel.zahka@gmail.com>
Cc: Jakub Kicinski <kuba@kernel.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>, Shuah Khan <shuah@kernel.org>,
	Willem de Bruijn <willemb@google.com>,
	Breno Leitao <leitao@debian.org>, Petr Machata <petrm@nvidia.com>,
	Yuyang Huang <yuyanghuang@google.com>,
	Xiao Liang <shaw.leon@gmail.com>,
	Carolina Jubran <cjubran@nvidia.com>,
	Donald Hunter <donald.hunter@gmail.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH net-next 1/9] netdevsim: a basic test PSP implementation
Date: Fri, 26 Sep 2025 16:35:19 +0100	[thread overview]
Message-ID: <aNayt5IBiX1Vegbr@horms.kernel.org> (raw)
In-Reply-To: <20250924194959.2845473-2-daniel.zahka@gmail.com>

On Wed, Sep 24, 2025 at 12:49:47PM -0700, Daniel Zahka wrote:
> From: Jakub Kicinski <kuba@kernel.org>
> 
> Provide a PSP implementation for netdevsim.
> 
> Use psp_dev_encapsulate() and psp_dev_rcv() to do actual encapsulation
> and decapsulation on skbs, but perform no encryption or decryption. In
> order to make encryption with a bad key result in a drop on the peer's
> rx side, we stash our psd's generation number in the first byte of each
> key before handing to the peer.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> Co-developed-by: Daniel Zahka <daniel.zahka@gmail.com>
> Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com>

...

> diff --git a/drivers/net/netdevsim/psp.c b/drivers/net/netdevsim/psp.c
> new file mode 100644
> index 000000000000..cb568f89eb3e
> --- /dev/null
> +++ b/drivers/net/netdevsim/psp.c
> @@ -0,0 +1,218 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +
> +#include <linux/ip.h>
> +#include <linux/skbuff.h>
> +#include <net/ip6_checksum.h>
> +#include <net/psp.h>
> +#include <net/sock.h>
> +
> +#include "netdevsim.h"
> +
> +enum skb_drop_reason
> +nsim_do_psp(struct sk_buff *skb, struct netdevsim *ns,
> +	    struct netdevsim *peer_ns, struct skb_ext **psp_ext)
> +{

...

> +	} else {
> +		struct ipv6hdr *ip6h;
> +		struct iphdr *iph;
> +		struct udphdr *uh;
> +		__wsum csum;
> +
> +		/* Do not decapsulate. Receive the skb with the udp and psp
> +		 * headers still there as if this is a normal udp packet.
> +		 * psp_dev_encapsulate() sets udp checksum to 0, so we need to
> +		 * provide a valid checksum here, so the skb isn't dropped.
> +		 */
> +		uh = udp_hdr(skb);
> +		csum = skb_checksum(skb, skb_transport_offset(skb),
> +				    ntohs(uh->len), 0);
> +
> +		switch (skb->protocol) {
> +		case htons(ETH_P_IP):
> +			iph = ip_hdr(skb);
> +			uh->check = udp_v4_check(ntohs(uh->len), iph->saddr,
> +						 iph->daddr, csum);
> +			break;
> +#if IS_ENABLED(CONFIG_IPV6)
> +		case htons(ETH_P_IPV6):
> +			ip6h = ipv6_hdr(skb);

ip6h is only used here. Which means that if CONFIG_IPV6 is not set then
compilers - e.g GCC 15.2.0 and Clang 21.1.1 - will warn when run with
-Wunused-variable.

Maybe no one cares. But if the scope of ip6h was reduced to here,
say by making this a block (using {}) and declaring iph6 inside it,
or using a helper, then things might be a bit cleaner.

> +			uh->check = udp_v6_check(ntohs(uh->len), &ip6h->saddr,
> +						 &ip6h->daddr, csum);
> +			break;
> +#endif
> +		}
> +
> +		uh->check	= uh->check ?: CSUM_MANGLED_0;
> +		skb->ip_summed	= CHECKSUM_NONE;
> +	}
> +
> +out_unlock:
> +	rcu_read_unlock();
> +	return rc;
> +}

...

  parent reply	other threads:[~2025-09-26 15:35 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-24 19:49 [PATCH net-next 0/9] psp: add a kselftest suite and netdevsim implementation Daniel Zahka
2025-09-24 19:49 ` [PATCH net-next 1/9] netdevsim: a basic test PSP implementation Daniel Zahka
2025-09-25  0:12   ` Jakub Kicinski
2025-09-25  6:48   ` kernel test robot
2025-09-26 15:30   ` Simon Horman
2025-09-26 15:35   ` Simon Horman [this message]
2025-09-24 19:49 ` [PATCH net-next 2/9] selftests: net: add skip all feature to ksft_run() Daniel Zahka
2025-09-25 16:09   ` Petr Machata
2025-09-25 17:04     ` Daniel Zahka
2025-09-26  2:18     ` Jakub Kicinski
2025-09-24 19:49 ` [PATCH net-next 3/9] selftests: drv-net: base device access API test Daniel Zahka
2025-09-25  0:13   ` Jakub Kicinski
2025-09-24 19:49 ` [PATCH net-next 4/9] selftests: drv-net: add PSP responder Daniel Zahka
2025-09-24 19:49 ` [PATCH net-next 5/9] selftests: drv-net: psp: add basic data transfer and key rotation tests Daniel Zahka
2025-09-26  9:15   ` Petr Machata
2025-09-24 19:49 ` [PATCH net-next 6/9] selftests: drv-net: psp: add association tests Daniel Zahka
2025-09-24 19:49 ` [PATCH net-next 7/9] selftests: drv-net: psp: add connection breaking tests Daniel Zahka
2025-09-24 19:49 ` [PATCH net-next 8/9] selftests: drv-net: psp: add test for auto-adjusting TCP MSS Daniel Zahka
2025-09-24 19:49 ` [PATCH net-next 9/9] selftests: drv-net: psp: add tests for destroying devices 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=aNayt5IBiX1Vegbr@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=cjubran@nvidia.com \
    --cc=daniel.zahka@gmail.com \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=leitao@debian.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petrm@nvidia.com \
    --cc=shaw.leon@gmail.com \
    --cc=shuah@kernel.org \
    --cc=willemb@google.com \
    --cc=yuyanghuang@google.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;
as well as URLs for NNTP newsgroup(s).