* [PATCH net] ice: do not report CHECKSUM_COMPLETE when an XDP program is attached
@ 2026-11-21 1:24 Tianyi Gao
2026-11-23 18:29 ` Maciej Fijalkowski
2026-11-23 18:49 ` Alexander H Duyck
0 siblings, 2 replies; 3+ messages in thread
From: Tianyi Gao @ 2026-11-21 1:24 UTC (permalink / raw)
To: netdev, intel-wired-lan, Tony Nguyen, Przemek Kitszel
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Paul Greenwalt, Alice Michael, Eric Joyner, Jesse Brandeburg,
Lorenzo Bianconi, bpf, kernel-team, tianyi.gao, Tianyi Gao
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
--
2.56.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net] ice: do not report CHECKSUM_COMPLETE when an XDP program is attached
2026-11-21 1:24 [PATCH net] ice: do not report CHECKSUM_COMPLETE when an XDP program is attached Tianyi Gao
@ 2026-11-23 18:29 ` Maciej Fijalkowski
2026-11-23 18:49 ` Alexander H Duyck
1 sibling, 0 replies; 3+ messages in thread
From: Maciej Fijalkowski @ 2026-11-23 18:29 UTC (permalink / raw)
To: Tianyi Gao
Cc: netdev, intel-wired-lan, Tony Nguyen, Przemek Kitszel,
Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Paul Greenwalt, Alice Michael, Eric Joyner, Jesse Brandeburg,
Lorenzo Bianconi, bpf, kernel-team, tianyi.gao
On Sat, Nov 21, 2026 at 01:24:02AM +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>
Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.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.
Anyone else besides mlx5 behaving this way?
>
> 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
> --
> 2.56.0
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net] ice: do not report CHECKSUM_COMPLETE when an XDP program is attached
2026-11-21 1:24 [PATCH net] ice: do not report CHECKSUM_COMPLETE when an XDP program is attached Tianyi Gao
2026-11-23 18:29 ` Maciej Fijalkowski
@ 2026-11-23 18:49 ` Alexander H Duyck
1 sibling, 0 replies; 3+ messages in thread
From: Alexander H Duyck @ 2026-11-23 18:49 UTC (permalink / raw)
To: Tianyi Gao, netdev, intel-wired-lan, Tony Nguyen, Przemek Kitszel
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
Paul Greenwalt, Alice Michael, Eric Joyner, Jesse Brandeburg,
Lorenzo Bianconi, bpf, kernel-team, tianyi.gao
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-23 18:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-21 1:24 [PATCH net] ice: do not report CHECKSUM_COMPLETE when an XDP program is attached Tianyi Gao
2026-11-23 18:29 ` Maciej Fijalkowski
2026-11-23 18:49 ` Alexander H Duyck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox