Netdev List
 help / color / mirror / Atom feed
From: Stanislav Fomichev <sdf.kernel@gmail.com>
To: Vijay Nag <nagvijay@microsoft.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	 "bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	willemb@google.com, tariqt@nvidia.com
Subject: Re: mlx5: stale skb encapsulation metadata after native XDP decapsulation
Date: Tue, 20 Oct 2026 16:51:00 -0700	[thread overview]
Message-ID: <atf9BogSMMrUenOQ@devvm16445.scu0.facebook.com> (raw)
In-Reply-To: <SETP153MB2368281B3138379C3F88AF71C4672@SETP153MB2368.APCP153.PROD.OUTLOOK.COM>

On 10/20, Vijay Nag wrote:
> Hi all, 
> 
> In a setup where native XDP performs tunnel decapsulation before TC ingress, I'm seeing an unexpected interaction with RX checksum offload.
> 
> XDP removes an outer IPv6 header using bpf_xdp_adjust_head() and returns XDP_PASS. TC ingress subsequently calls bpf_skb_change_tail() on the decapsulated packet.
> 
> On mlx5 with RX checksum offload enabled, bpf_skb_change_tail() returns -524 (-ENOTSUPP). Tracing shows skb->encapsulation == 1 at TC ingress, even though the outer header has already been removed. Disabling RX checksum offload makes the same processing path succeed.
> 
> The following Linux v6.6 code paths appear relevant.
> 
> In net/core/filter.c, __bpf_skb_change_tail():
> 
> if (skb->encapsulation)
>     return -ENOTSUPP;
> 
> In drivers/net/ethernet/mellanox/mlx5/core/en_rx.c, mlx5e_handle_csum():
> 
> if (likely((cqe->hds_ip_ext & CQE_L3_OK) && (cqe->hds_ip_ext & CQE_L4_OK))) {
>     skb->ip_summed = CHECKSUM_UNNECESSARY;
>     if (cqe_is_tunneled(cqe)) {
>         skb->csum_level = 1;
>         skb->encapsulation = 1;
>         stats->csum_unnecessary_inner++;
>         return;
>     }
> }
> 
> My current understanding is that the CQE tunnel classification causes the subsequently constructed skb to retain encapsulation metadata corresponding to the original packet, even though XDP has already removed the outer header.
> 
> Is this expected behavior when native XDP decapsulates a packet before skb construction?
> 
> More generally, what is the intended handling of checksum/encapsulation metadata in this case? Is there an existing fix or recommended way to handle this interaction?
> 
> This was observed on a v6.6-based kernel with an mlx5 VF.
> 
> Source references:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/net/core/filter.c?h=v6.6
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c?h=v6.6

I don't think we have a good answer for this, there has been some recent
discussion here: https://lore.kernel.org/netdev/amEojEGsIGkUjIWn@devvm7509.cco0.facebook.com/

In general, from my POW, we should not carry most of the rx metadata into
an skb when there is an xdp program (until we expose some helpers to the
xdp to change it). For mlx, we might want to skip that cqe_is_tunneled
branch in case of xdp, you can try to send a patch and see what happens :-)

For more recent kernels, and for tc, there is bpf_skb_adjust_room helper
with gives you more control over these fields (in case you can move your
decap fully to tc).

CC'd Willem who might know more about csum+encap specifics and Tariq for
mlx5.

      reply	other threads:[~2026-10-20 23:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20  1:15 mlx5: stale skb encapsulation metadata after native XDP decapsulation Vijay Nag
2026-10-20 23:51 ` Stanislav Fomichev [this message]

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=atf9BogSMMrUenOQ@devvm16445.scu0.facebook.com \
    --to=sdf.kernel@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=nagvijay@microsoft.com \
    --cc=netdev@vger.kernel.org \
    --cc=tariqt@nvidia.com \
    --cc=willemb@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