🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
6 messages
6 total messages Started by Alexander H Duyck Mon, 23 Nov 2026 18:49
Re: [PATCH net] ice: do not report CHECKSUM_COMPLETE when an XDP program is attached
#21252
Author: Alexander H Duyck
Date: Mon, 23 Nov 2026 18:49
93 lines
16267 bytes
On Sat, 2026-11-21 at 01:24 +0000, Tianyi Gao wrote:
> On E830, ice reports CHECKSUM_COMPLETE with the generic checksum (GCS)
> that the hardware computes over the received frame. If an XDP program
> changes the packet and returns XDP_PASS, that checksum no longer
> matches. The stack then checks the packet again in software and calls
> netdev_rx_csum_fault().
> 
> On Cloudflare servers, an XDP load balancer removes the encapsulation
> of the packets that it accepts locally. Our production traffic hits
> netdev_rx_csum_fault() all the time.
> 
> Do not use GCS when the ring has an XDP program, as mlx5 has done since
> commit 5d0bb3bac4b9 ("net/mlx5e: XDP, Avoid checksum complete when XDP
> prog is loaded").
> 
> E830 also sets the L3L4P and checksum error bits, so the packet gets
> CHECKSUM_UNNECESSARY or CHECKSUM_NONE, as on E810. For example, a zero
> UDP checksum over IPv6 is marked as bad and gets CHECKSUM_NONE. A zero
> UDP checksum over IPv4 gets CHECKSUM_UNNECESSARY.
> 
> Two pending series [1][2] give XDP access to the checksum status.
> Neither of them supports CHECKSUM_COMPLETE.
> 
> ice_rx_csum() reads rx_ring->xdp_prog again after the poll loop ran XDP.
> While ICE_VSI_REBUILD_PENDING is set, ice_xdp_setup_prog() can replace
> the program without stopping NAPI, so the two reads can differ. At
> worst, a packet in that poll gets CHECKSUM_COMPLETE as before this
> patch. The pointer is only compared with NULL, so this cannot crash.
> 
> Link: https://lore.kernel.org/all/20260715-bpf-xdp-meta-rxcksum-v5-0-623d5c0d0ab7@kernel.org/ [1]
> Link: https://lore.kernel.org/all/cover.1794281983.git.tianyi@cloudflare.com/ [2]
> Fixes: 905d1a220e8d ("ice: Add E830 checksum offload support")
> Suggested-by: Jesse Brandeburg <jbrandeb@kernel.org>
> Signed-off-by: Tianyi Gao <tianyi@cloudflare.com>
> ---
> Tested on an E830 (8086:12d2, board N31483-007, fw.mgmt 7.9.5, DDP ICE
> COMMS 1.3.63.0) with an XDP program that removes a UDP encapsulation
> header with bpf_xdp_adjust_head() and returns XDP_PASS. The kernel was
> based on 6.18.64, where ice_rx_csum() is the same as in net:
> 
> - Before: 63322069 netdev_rx_csum_fault() calls in 30 s.
> - After: 0.
> - Without an XDP program, the port still reports CHECKSUM_COMPLETE.
> 
> On an E810, which has no GCS, drivers/net/xdp.py, ping.py and
> hw/csum.py give the same results with and without this patch.
> 
> Request for comment: I also prepared a drv-net selftest for net-next.
> It removes 16 bytes from the UDP payload with bpf_xdp_adjust_head()
> and fails if the packet reaches the stack with CHECKSUM_COMPLETE. I am
> not sure we want to enforce this for all NICs, so asking here.
> 
>  drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> index e695a664e53d..ad22d855436e 100644
> --- a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> @@ -123,6 +123,7 @@ ice_rx_csum(struct ice_rx_ring *ring, struct sk_buff *skb,
>  	rx_status1 = le16_to_cpu(rx_desc->wb.status_error1);
>  
>  	if ((ring->flags & ICE_RX_FLAGS_RING_GCS) &&
> +	    !READ_ONCE(ring->xdp_prog) &&
>  	    rx_desc->wb.rxdid == ICE_RXDID_FLEX_NIC &&
>  	    (decoded.inner_prot == LIBETH_RX_PT_INNER_TCP ||
>  	     decoded.inner_prot == LIBETH_RX_PT_INNER_UDP ||
> 
> base-commit: 92e97d7cffc7ec6adfa4699203c18b1ab0c8b314

I'm not sure this is the best fix for this. If we are needing all NICs
that support CHECKSUM_COMPLETE *and* XDP to report CHECKSUM_NONE in the
event of a frame being modified by XDP it really feels like we should
probably look at moving this further up the stack.

Otherwise the proper fix for this is probably going to need to be
spread out to far more drivers as I suspect the intersection of the two
is likely not that uncommon.

Also even if we go the multiple driver fix route I wonder if we
shouldn't look at adding a new XDP return type to indicate that we are
passing a modified frame so that we don't have every XDP program out
there forcing NICs into a state where they have to start turning off
various offloads across the board when they don't need to.

What we are going to end up with this current path is one group of XDP
programs dragging down the performance of others since they will take
the penalty for the ones that are making the dirty modifications.
Re: [PATCH net] ice: do not report CHECKSUM_COMPLETE when an XDP program is attached
#21310
Author: Alexander Duyck
Date: Mon, 23 Nov 2026 21:09
45 lines
14873 bytes
On Mon, Nov 23, 2026 at 12:35 PM Tianyi Gao <tianyi@cloudflare.com> wrote:
>
> On Mon, 2026-11-23 at 10:49 -0800, Alexander H Duyck wrote:
> > I'm not sure this is the best fix for this. If we are needing all NICs
> > that support CHECKSUM_COMPLETE *and* XDP to report CHECKSUM_NONE in the
> > event of a frame being modified by XDP it really feels like we should
> > probably look at moving this further up the stack.
>
> Thanks for the review, Alex.
>
> IMHO we should first make sure XDP programs do not cause "hw csum
> failure" in current kernels. Whatever an XDP program does, it should
> not be able to trigger a hw csum failure. It's not an uncommon use
> case, e.g., Katran from Meta [3] and Cloudflare's load balancer. And
> existing selftests already do it (test_xdp_native_adjst_head_* and
> test_xdp_native_adjst_tail_* in
> tools/testing/selftests/drivers/net/xdp.py).

That is exactly my point though. What we have is a divergence between
a number of the existing drivers in how they handle these things. As a
result the behavior is currently different depending on which NIC is
in use.

For example, one recent one I saw was an issue on the Tx side where an
outgoing XDP program was modifying the frame and actually not updating
the pseudoheader checksum. As a result it was breaking Tx checksum
offloads for NICs that were using the HW_CSUM that used that checksum
header. We could have fixed it by forcing all the drivers to
recalculate the pseudo-header checksum, but instead we pushed back on
the program that was making that change.

> > Also even if we go the multiple driver fix route I wonder if we
> > shouldn't look at adding a new XDP return type to indicate that we are
> > passing a modified frame
>
> IMHO that is for net-next. There we can add optimizations, such as a
> way to keep CHECKSUM_COMPLETE for programs that do not change the
> frame, potentially after [1] or [2] is accepted.

The point is you are fixing things for your use case, but anybody who
is using the CHECKSUM_COMPLETE to compute the checksum on the frames
and using XDP without changing the frames will see this as a
significant performance regression.
Re: [PATCH net] ice: do not report CHECKSUM_COMPLETE when an XDP program is attached
#21355
Author: Alexander Duyck
Date: Mon, 23 Nov 2026 22:42
78 lines
16518 bytes
On Mon, Nov 23, 2026 at 2:01 PM Tianyi Gao <tianyi@cloudflare.com> wrote:
>
> On Mon, 2026-11-23, Alexander H Duyck wrote:
> > For example, one recent one I saw was an issue on the Tx side where
> > an outgoing XDP program was modifying the frame and actually not
> > updating the pseudoheader checksum. As a result it was breaking Tx
> > checksum offloads for NICs that were using the HW_CSUM that used
> > that checksum header. We could have fixed it by forcing all the
> > drivers to recalculate the pseudo-header checksum, but instead we
> > pushed back on the program that was making that change.
>
> Thank you for the explanation, Alex.
>
> On Tx the checksum is in the frame, so the program can fix it. On Rx
> the program can't touch skb->csum at all, so there is nothing to push
> back on.
>
> > The point is you are fixing things for your use case, but anybody
> > who is using the CHECKSUM_COMPLETE to compute the checksum on the
> > frames and using XDP without changing the frames will see this as a
> > significant performance regression.
>
> Without GCS, TCP and UDP still get CHECKSUM_UNNECESSARY, same as
> E810. GCS only came in v6.15, so this just puts E830 with XDP back
> to where it was.
>
> The cases I can think of that are truly impacted are IPv6 with
> extension headers, and UDP tunnels that the NIC does not parse and
> that have a zero outer checksum. These fall back to software
> checksum.
>
> And programs that do change the frame are worse off today. Every
> packet gets summed again in software, plus the "hw csum failure".
>
> I don't see a fix that meets all of these:
>
> 1. It is small enough and can be backported to stable.
> 2. It fixes the problem fully. We could drop CHECKSUM_COMPLETE only
>    when the program moved data or data_end, but some in-place
>    writes, e.g. NAT or the IPv6 hop limit, would still trigger
>    "hw csum failure". IMO that brings more problems.
> 3. It keeps CHECKSUM_COMPLETE for programs that do not change the
>    frame. But that looks like a bigger change, which doesn't fit
>    net.
>
> If you have one, I am happy to take it. Otherwise, as I understand
> it, the choice is between:
>
> 1. A performance regression for some programs, but no "hw csum
>    failure".
> 2. No regression for those programs, but "hw csum failure" stays
>    for programs that change the frame.
>
> I would like to know how the community normally decides between
> these.

The thing is your fix isn't really complete. As I said it is primarily
just addressing your use case and sweeping follow-on issues under the
rug. In the mlx5e case they were disabling the feature via the private
control flag if it was enabled. In the case of your change you are
just disabling it without exposing that it is disabled.

From what I can tell you are just bypassing the checksum complete
logic, but you don't exit out of the function as a result. What
effects is that having on frames that would have been normally
checksum complete? Specifically, is it being treated as though the
frame is unrecognized, or is it falling through into the
CHECKSUM_UNNECESSARY path with all the indications that a tunnel was
still there even though you stripped the header?

The issue is that the driver is making a number of assumptions about
what is there based on what the hardware parsed for headers and such.
With the headers being stripped and/or replaced those aren't correct
anymore. That is why we should probably be looking at dropping more of
the existing logic or forcing a rescan of the packet once the headers
are replaced to update the descriptor data for the skb configuration.
Re: [PATCH net] ice: do not report CHECKSUM_COMPLETE when an XDP program is attached
#21391
Author: Alexander Duyck
Date: Tue, 24 Nov 2026 00:17
68 lines
16090 bytes
On Mon, Nov 23, 2026 at 3:26 PM Tianyi Gao <tianyi@cloudflare.com> wrote:
>
> Hi Alex,
>
> Thank you for being so responsive, and I really appreciate it.
>
> On Mon, 2026-11-23 at 14:42 -0800, Alexander Duyck wrote:
> > In the mlx5e case they were disabling the feature via the private
> > control flag if it was enabled. In the case of your change you are
> > just disabling it without exposing that it is disabled.
>
> mlx5 does not change the private flag when a program is attached. It
> sets MLX5E_RQ_STATE_NO_CSUM_COMPLETE on the RQ, and
> rx_no_csum_complete keeps its value ("off" by default).
>
> > is it falling through into the CHECKSUM_UNNECESSARY path with all
> > the indications that a tunnel was still there even though you
> > stripped the header?
>
> Yes, the same path as E810, and mlx5 does the same with a program
> attached.
>
> > The issue is that the driver is making a number of assumptions about
> > what is there based on what the hardware parsed for headers and such.
>
> This was discussed in the thread of [1], including the decap problem
> with csum_level. The summary there was that reporting
> CHECKSUM_COMPLETE on the XDP-to-skb path is unsafe, and that the
> safest option for now is CHECKSUM_UNNECESSARY only [3]. The decap
> case with CHECKSUM_UNNECESSARY was left open as a known problem.
>
> I am also working on the long-term design in [2], though there is
> still a long way to go. Please take a look if you are interested.
>
> For this patch, my aim is simple: stop the "hw csum failure", and
> make E830 with XDP report RX checksums the same way as E810, i.e. as
> before GCS was added.
>
> [3] https://lore.kernel.org/all/20260721183256.6f49d6e1@kernel.org/
>
> Thanks,
> Tianyi

Any reason why you couldn't just strip the GCS enable flags from the
rings when you add the XDP program in ndo_bpf instead of having to add
a check for every packet if the XDP program is present? That would be
closer to what they did for the Mellanox NIC and wouldn't be adding
code to the hot path. Then it is just a matter of also adding an info
message that you are disabling this in the log so if somebody does
have to figure out a regression it should be more obvious.

Thinking in terms of what the final fix for this might look like,
currently the drivers are already starting to carry stuff for frags to
determine if they support jumbo frames via frags or not. I suspect we
will likely need to do something similar when the time comes
indicating if the program can avoid corrupting a checksum or not when
it is stripping headers.

I am not super thrilled with the idea of this becoming standardized.
In theory this would be much better if there was some way to pass the
data out that the frame was mangled and what the checksum adjustment
is to the total frame. As it stands we are probably going to be
getting CHECKSUM_UNNECESSARY on everything even if we don't expect it.
For example I don't know what will happen with an ICMP frame sent over
this tunnel. I assume it is likely just discaring the
CHECKSUM_UNECESSARY since it isn't used.
Re: [PATCH net] ice: do not report CHECKSUM_COMPLETE when an XDP program is attached
#22669
Author: Alexander Duyck
Date: Wed, 25 Nov 2026 16:32
64 lines
15766 bytes
On Wed, Nov 25, 2026 at 1:08 AM Tianyi Gao <tianyi@cloudflare.com> wrote:
>
> On Mon, 2026-11-23 at 16:17 -0800, Alexander Duyck wrote:
> > Any reason why you couldn't just strip the GCS enable flags from the
> > rings when you add the XDP program in ndo_bpf instead of having to add
> > a check for every packet if the XDP program is present? That would be
> > closer to what they did for the Mellanox NIC and wouldn't be adding
> > code to the hot path. Then it is just a matter of also adding an info
> > message that you are disabling this in the log so if somebody does
> > have to figure out a regression it should be more obvious.
>
> Thank you for your valuable comments.
>
> Clearing the flag in ndo_bpf alone is not enough, because
> ice_vsi_alloc_rings() sets it again on a VSI rebuild, for example after
> "ethtool -L" or a PF reset, while the program stays attached.
>
> In v2 I will set ICE_RX_FLAGS_RING_GCS in ice_vsi_cfg_rxq(), which runs
> every time a ring comes up, similar to what mlx5 does when it opens the
> RQ.
>
> v2 also logs an info message when a program is attached on a port
> with GCS. I tested it on E830 with attach, detach and "ethtool -L",
> and I will send it soon.
>
> > Thinking in terms of what the final fix for this might look like,
> > currently the drivers are already starting to carry stuff for frags to
> > determine if they support jumbo frames via frags or not. I suspect we
> > will likely need to do something similar when the time comes
> > indicating if the program can avoid corrupting a checksum or not when
> > it is stripping headers.
> >
> > I am not super thrilled with the idea of this becoming standardized.
> > In theory this would be much better if there was some way to pass the
> > data out that the frame was mangled and what the checksum adjustment
> > is to the total frame.
>
> 100% agree. We should be able to tell whether a frame was modified,
> keep CHECKSUM_COMPLETE for the frames that were not, and give XDP
> programs kfuncs to read and set the checksum status.
>
> Unfortunately, today there is a big gap before we start that:
>
> - [1] lets a program read the checksum status, including the
>   CHECKSUM_COMPLETE value.
> - [2] lets a program set CHECKSUM_NONE or CHECKSUM_UNNECESSARY with
>   csum_level on the skb.
> - Nothing lets a program pass a corrected CHECKSUM_COMPLETE value to
>   the skb. [3] lists this as future work.

Realistically speaking there is an easy solution to this in the
program itself. It would be to look at using something like the
REDIRECT action instead of just stripping the tunnels and passing it
back to the original interface. It would then take the frame and stop
processing the remaining descriptor data. As it stands that would be
the more correct solution as you could then just redirect it to the
tunnel interface I assume you have stacked on top of it and have it
receive the frame instead of having received it at the interface that
just head the header stripped.

It would also match up better with how the stack would actually expect
this to work if you didn't have the XDP program in place.
Re: [PATCH net] ice: do not report CHECKSUM_COMPLETE when an XDP program is attached
#22774
Author: Alexander Duyck
Date: Wed, 25 Nov 2026 22:02
62 lines
16620 bytes
On Wed, Nov 25, 2026 at 10:31 AM Tianyi Gao <tianyi@cloudflare.com> wrote:
>
> On Wed, 2026-11-25 at 08:32 -0800, Alexander Duyck wrote:
> > Realistically speaking there is an easy solution to this in the
> > program itself. It would be to look at using something like the
> > REDIRECT action instead of just stripping the tunnels and passing it
> > back to the original interface. It would then take the frame and stop
> > processing the remaining descriptor data. As it stands that would be
> > the more correct solution as you could then just redirect it to the
> > tunnel interface I assume you have stacked on top of it and have it
> > receive the frame instead of having received it at the interface that
> > just head the header stripped.
> >
> > It would also match up better with how the stack would actually expect
> > this to work if you didn't have the XDP program in place.
>
> That is exactly what we are trying to do. Our traffic will be
> redirected anyway, to a cpumap for load balancing. We tried to keep the
> RX metadata across the redirect autonomously in [2], but this has been
> strongly opposed so far [5][6].
>
> [2] https://lore.kernel.org/all/cover.1794281983.git.tianyi@cloudflare.com/
> [5] https://lore.kernel.org/all/20261117161856.6f6c2ce9@kernel.org/
> [6] https://lore.kernel.org/all/20250716142015.0b309c71@kernel.org/

The thing is once you start making modifications to the frame all that
metadata should probably be thrown out anyway since none of it is
really valid. I would probably treat it like we would a namespace
leak. I get that you want things like the RSS hash to provide some
entropy but it is basically just snooping into fields that you
wouldn't want getting passed on anyway like details about the outer
headers. Same thing for CHECKSUM_UNNECESSARY. It was making
assumptions about the frame that you likely changed, as a result you
can't really trust the flag when it is provided.

If anything, the path you are taking now with disabling
CHECKSUM_COMPLETE is the opposite direction of how I would probably go
about this. If you are wanting something that is more universal
focusing more on CHECKSUM_COMPLETE would more than likely be the way
to go as it doesn't care about what the outer or inner protocols are
and the math is pretty lightweight as you only have to fold in the
header checksums as you modify them and don't have to mess with the
entire frame. Your modified frame could return whatever the value is
that you want to pass out to indicate that it is modified, and you
would then be able to just pass the checksum modification out as part
of the metadata in some expected format that the drivers could then
process.

By disabling it you are basically forcing yourself into a
vendor/protocol lock in as you can only get checksum info on the
packet types the hardware supports. The issue is that
CHECKSUM_UNNECESSARY doesn't convert well to anything once you strip
the header. That is why back in the day we had strongly encouraged
people to use non-zero UDP checksum on their tunnels and had added the
ability to convert the CHECKSUM_UNNECESSARY to CHECKSUM_COMPLETE when
decapsulating generic UDP tunnels. With that we could support most
NICs instead of the 2 or 3 that supported all the new tunnel types
that were coming out that then had to parse all the way to the inner
headers.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads