From: sashiko-bot@kernel.org
To: "Jason Xing" <kerneljasonxing@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net v2 2/2] xsk: fill in header offsets for TX checksum offload
Date: Sat, 28 Nov 2026 10:54:17 +0000 [thread overview]
Message-ID: <sashiko-outbox-238639@kernel.org> (raw)
In-Reply-To: <20261127105347.72997-3-kerneljasonxing@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] xsk: skb_checksum_help() warning in xsk_skb_sw_csum() on
nonlinear skb
- [Medium] xsk: missing skb_checksum_help() fallback in
xsk_skb_sw_csum() for non-Ethernet devs
--
commit 56dbb0a2d6a12181bfa80e8eb8b24e6cbe5b0a5c
Author: Jason Xing <kerneljasonxing@gmail.com>
xsk: fill in header offsets for TX checksum offload
This commit parses the Ethernet and VLAN headers in xsk_skb_sw_csum() to
populate skb->protocol, the network header offset, and the transport
header offset for AF_XDP TX checksum offload, falling back to
skb_checksum_help() when header validation fails.
> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
> index 18cbd50047d80..3827d8e4b642a 100644
> --- a/net/xdp/xsk.c
> +++ b/net/xdp/xsk.c
[ ... ]
> @@ -1028,9 +1032,48 @@ static int xsk_skb_metadata(struct sk_buff *skb, void *buffer,
>
> static int xsk_skb_sw_csum(struct sk_buff *skb, struct xsk_buff_pool *pool)
> {
> - if (unlikely(pool->tx_sw_csum &&
> - skb->ip_summed == CHECKSUM_PARTIAL))
> + struct ethhdr eth_buf, *eth;
> + int nhoff = ETH_HLEN;
> + unsigned int l3_min;
> + __be16 proto;
> +
> + if (unlikely(skb->ip_summed != CHECKSUM_PARTIAL))
> + return 0;
> +
> + if (unlikely(pool->tx_sw_csum))
> + return skb_checksum_help(skb);
> +
> + if (unlikely(skb->dev->type != ARPHRD_ETHER))
> + return 0;
[Severity: Medium]
Should non-ARPHRD_ETHER devices fall back to software checksumming instead
of returning 0 here?
Returning 0 leaves skb->ip_summed as CHECKSUM_PARTIAL with skb->protocol
still 0 and csum_start unvalidated. On non-ARPHRD_ETHER devices that
advertise NETIF_F_HW_CSUM (such as loopback with ARPHRD_LOOPBACK or tunnel
devices), can_checksum_protocol() returns true even for protocol 0, so
validate_xmit_skb() does not call skb_checksum_help() either. On
loopback, if csum_start < ETH_HLEN, loopback_xmit() pulls ETH_HLEN bytes
and delivers a CHECKSUM_PARTIAL skb with a negative
skb_checksum_start_offset(), triggering a WARN_ONCE() in
skb_checksum_help() on the receive path.
> +
> + eth = skb_header_pointer(skb, 0, sizeof(*eth), ð_buf);
> + if (unlikely(!eth))
> + return skb_checksum_help(skb);
> +
> + proto = eth->h_proto;
> + if (eth_type_vlan(proto)) {
> + proto = __vlan_get_protocol(skb, proto, &nhoff);
> + if (unlikely(!proto))
> + return skb_checksum_help(skb);
> + }
> +
> + switch (proto) {
> + case htons(ETH_P_IP):
> + l3_min = sizeof(struct iphdr);
> + break;
> + case htons(ETH_P_IPV6):
> + l3_min = sizeof(struct ipv6hdr);
> + break;
> + default:
> return skb_checksum_help(skb);
> + }
> +
> + if (unlikely(skb_checksum_start_offset(skb) < nhoff + l3_min))
> + return skb_checksum_help(skb);
[Severity: Medium]
Can calling skb_checksum_help() on these fallback paths trigger a
WARN_ONCE() when the socket is bound to an IFF_TX_SKB_NO_LINEAR device
such as virtio_net?
d73a9a63f9f7 ("xsk: reject sw-csum UMEM binding to IFF_TX_SKB_NO_LINEAR
devices") rejected binding in xp_assign_dev() only when pool->tx_sw_csum
is set. When pool->tx_sw_csum is false, xsk_build_skb_zerocopy() still
builds skbs with skb_headlen(skb) == 0 on IFF_TX_SKB_NO_LINEAR devices.
If a frame with XDP_TXMD_FLAGS_CHECKSUM hits any of these fallback
branches (for example, a non-IP ethertype or a csum_start smaller than
nhoff + l3_min), skb_checksum_help() sees offset >= skb_headlen(skb),
fires WARN_ONCE(), and returns -EINVAL.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127105347.72997-1-kerneljasonxing@gmail.com?part=2
next prev parent reply other threads:[~2026-11-28 10:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 10:53 [PATCH net v2 0/2] xsk: handle two header issues Jason Xing
2026-11-27 10:53 ` [PATCH net v2 1/2] net: reset the mac header in __dev_direct_xmit() Jason Xing
2026-11-27 14:38 ` Björn Töpel
2026-11-27 10:53 ` [PATCH net v2 2/2] xsk: fill in header offsets for TX checksum offload Jason Xing
2026-11-27 16:40 ` Björn Töpel
2026-11-29 9:10 ` Jason Xing
2026-11-28 10:54 ` sashiko-bot [this message]
2026-11-28 11:47 ` netdev-bot+sashiko
2026-11-29 11:13 ` Jason Xing
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-238639@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=kerneljasonxing@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/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.