Re: [PATCH net-next v6 3/7] net: bcmgenet: add basic XDP support (PASS/DROP)

From: Nicolai Buchwitz

Date: Mon Apr 06 2026 - 14:57:37 EST


On 6.4.2026 10:35, Nicolai Buchwitz wrote:
Add XDP program attachment via ndo_bpf and execute XDP programs in the
RX path. XDP_PASS builds an SKB from the xdp_buff (handling
xdp_adjust_head/tail), XDP_DROP returns the page to page_pool without
SKB allocation.

[...]


/* Set up checksum offload */
if (dev->features & NETIF_F_RXCSUM) {
- rx_csum = (__force __be16)(status->rx_csum & 0xffff);
if (rx_csum) {
skb->csum = (__force __wsum)ntohs(rx_csum);
skb->ip_summed = CHECKSUM_COMPLETE;

Sashiko:
Will this cause hardware checksum validation failures if the XDP program
modifies the packet?
The driver saves the hardware checksum before executing the XDP program, and
then unconditionally applies CHECKSUM_COMPLETE if XDP_PASS is returned. If
the BPF program alters the packet payload or adjusts the headers, the saved
hardware checksum will no longer match the new packet contents.
When the networking stack later attempts to validate this checksum, won't it
result in a mismatch, causing the packet to be dropped and the stack to emit
a hardware checksum failure warning?
Does the driver need to clear the hardware checksum and set skb->ip_summed
to CHECKSUM_NONE when an XDP program is present, or otherwise ensure the
checksum is only applied when the packet is unmodified?

Reponse:
CHECKSUM_COMPLETE with a stale HW checksum causes the stack to fall back to
software verification, not a silent drop. This is how ice and other XDP drivers
handle it as well. Programs that modify packets typically return TX or REDIRECT,
not PASS.

@@ -3744,6 +3810,37 @@ static int bcmgenet_change_carrier(struct net_device *dev, bool new_carrier)
return 0;
}

[...]