All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Todd Freed" <toddfreed@meta.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH net-next v2 02/12] psp: take the psp nexthdr from the packet on encap
Date: Fri, 20 Nov 2026 01:31:56 +0000	[thread overview]
Message-ID: <sashiko-outbox-224309@kernel.org> (raw)
In-Reply-To: <20261119013103.1092559-3-toddfreed@meta.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mlx5e: psp software GSO on tunneled skbs bypasses
  psp_dev_encap_ok()
--

commit a0d2a8f5be06d7567437603fff001e2cd59e1432
Author: Todd Freed <toddfreed@meta.com>

psp: take the psp nexthdr from the packet on encap

This commit populates the PSP next header from the original IP header
instead of hardcoding IPPROTO_TCP, rejecting unsupported packets such as
fragments, IPv6 extension headers, and already-encapsulated tunnel packets,
and adjusts mlx5e feature checks and outer UDP source port selection for
non-TCP packets.

> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> index 2be8147fdb64f..d6c32080634da 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> @@ -5139,6 +5139,23 @@ static netdev_features_t mlx5e_tunnel_features_check(struct mlx5e_priv *priv,
>  	return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
>  }
>  
> +/* The L4 protocol right after the fixed IP header, which the PSP Tx path
> + * requires, is one the device can complete the checksum of
> + */
> +static bool mlx5e_psp_l4_csum_ok(const struct sk_buff *skb)
> +{
> +	u8 proto;
> +
> +	if (skb->protocol == htons(ETH_P_IP))
> +		proto = ip_hdr(skb)->protocol;
> +	else if (skb->protocol == htons(ETH_P_IPV6))
> +		proto = ipv6_hdr(skb)->nexthdr;
> +	else
> +		return false;
> +
> +	return proto == IPPROTO_TCP || proto == IPPROTO_UDP;
> +}
> +
>  netdev_features_t mlx5e_features_check(struct sk_buff *skb,
>  				       struct net_device *netdev,
>  				       netdev_features_t features)
> @@ -5147,6 +5164,22 @@ netdev_features_t mlx5e_features_check(struct sk_buff *skb,
>  
>  	features = vlan_features_check(skb, features);
>  
> +	/* The PSP tx path fixes up the TCP checksum of a GSO skb for the
> +	 * device, which is only valid for TCP, and the device only completes
> +	 * a TCP or UDP checksum behind the PSP header. Have the stack segment
> +	 * and checksum other skbs.
> +	 */
> +	if ((skb_is_gso(skb) || skb->ip_summed == CHECKSUM_PARTIAL) &&
> +	    mlx5e_psp_is_offload(skb, netdev)) {
> +		if (skb_is_gso(skb) &&
> +		    !(skb_shinfo(skb)->gso_type &
> +		      (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)))
> +			features &= ~NETIF_F_GSO_MASK;
> +		if (skb->ip_summed == CHECKSUM_PARTIAL &&
> +		    !mlx5e_psp_l4_csum_ok(skb))
> +			features &= ~NETIF_F_CSUM_MASK;
> +	}

[Severity: Medium]
Can clearing NETIF_F_CSUM_MASK or NETIF_F_GSO_MASK on a tunneled GSO skb
(skb->encapsulation == 1) cause software GSO to strip skb->encapsulation
before psp_dev_encap_ok() checks it?

For an already-encapsulated GSO packet such as GRE (IPPROTO_GRE),
mlx5e_psp_l4_csum_ok() sees the outer IP protocol, returns false, and
clears NETIF_F_CSUM_MASK, causing harmonize_features() to also clear
NETIF_F_GSO_MASK.  When validate_xmit_skb() then runs software tunnel
GSO (e.g., gre_gso_segment()), it segments and checksums the inner
packet in software, clears seg->encapsulation to 0, sets
seg->transport_header to the outer tunnel header right after the outer
IP header, and (for SKB_GSO_GRE_CSUM) sets seg->ip_summed to
CHECKSUM_PARTIAL for the GRE checksum.

When those segments reach mlx5e_psp_handle_tx_skb() ->
psp_dev_encapsulate(), psp_dev_encap_ok() sees seg->encapsulation == 0
and skb_network_header_len(seg) == ip_hdrlen(seg), so it encapsulates
the tunnel packet with nexthdr = IPPROTO_GRE instead of rejecting it.
mlx5e_psp_set_swp() then leaves eseg->swp_inner_l4_offset as 0 because
skb->inner_ipproto is IPPROTO_GRE, while
mlx5e_psp_txwqe_build_eseg_csum() still sets
MLX5_ETH_WQE_L4_INNER_CSUM for the CHECKSUM_PARTIAL segment, producing
corrupted frames or device TX syndromes.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261119013103.1092559-1-toddfreed@meta.com?part=2

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

Thread overview: 26+ 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 ` [PATCH net-next v2 01/12] psp: get netns from net_device instead of sock Todd Freed
2026-11-20  1:31   ` sashiko-bot
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-20  1:31   ` sashiko-bot [this message]
2026-11-19  1:30 ` [PATCH net-next v2 03/12] psp: declare psp_assoc_set_tx() in psp.h Todd Freed
2026-11-20  1:31   ` sashiko-bot
2026-11-19  1:30 ` [PATCH net-next v2 04/12] psp: add support for socket-less psp associations Todd Freed
2026-11-20  1:31   ` sashiko-bot
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-20  1:31   ` sashiko-bot
2026-11-20 17:24     ` Todd Bert 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-20  1:31   ` sashiko-bot
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-20  1:31   ` sashiko-bot
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-20  1:32   ` sashiko-bot
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-20  1:32   ` sashiko-bot
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-20  1:32   ` sashiko-bot
2026-11-19  1:31 ` [PATCH net-next v2 11/12] selftests: tc-testing: add tests for the psp action Todd Freed
2026-11-20  1:32   ` sashiko-bot
2026-11-19  1:31 ` [PATCH net-next v2 12/12] Documentation: networking: psp: document socket-less associations Todd Freed
2026-11-20  1:32   ` sashiko-bot

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=sashiko-outbox-224309@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=toddfreed@meta.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.