Re: [PATCH v2 net 1/4] net: enetc: let core segment GSO skb when TSO would not fit the TX ring
From: netdev-bot+sashiko
Date: Sun Nov 22 2026 - 19:28:59 EST
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] enetc_features_check()
(drivers/net/ethernet/freescale/enetc/enetc.c:1106-1122) decides…
--
net: enetc: let core segment GSO skb when TSO would not fit the TX ring
This patch adds an ndo_features_check() to enetc. For skbs that take the
software TSO path, it clears the GSO features when the descriptor estimate
is at least the TX ring size, so the core segments those skbs before
ndo_start_xmit(). The goal is to stop the TX queue from stalling on skbs
that could never fit in the ring.
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
> index c6571b5cc8425..1606ac57016f3 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc.c
[ ... ]
> @@ -1098,6 +1103,24 @@ netdev_tx_t enetc_xmit(struct sk_buff *skb, struct net_device *ndev)
> }
> EXPORT_SYMBOL_GPL(enetc_xmit);
>
> +netdev_features_t enetc_features_check(struct sk_buff *skb,
> + struct net_device *ndev,
> + netdev_features_t features)
> +{
> + struct enetc_ndev_priv *priv = netdev_priv(ndev);
> +
> + features = vlan_features_check(skb, features);
> +
> + if (!skb_is_gso(skb) || enetc_skb_uses_lso(priv, skb))
> + return features;
> +
> + if (tso_count_descs(skb) >= priv->tx_bd_count)
> + features &= ~NETIF_F_GSO_MASK;
[Severity: High]
Can SKB_GSO_DODGY skbs get past this check, given that their gso_segs is
still 0 when enetc_features_check() runs?
tso_count_descs() is computed from skb_shinfo(skb)->gso_segs.
virtio_net_hdr_to_skb() clears that field for untrusted skbs, for example
those sent by af_packet with PACKET_VNET_HDR:
include/linux/virtio_net.h:virtio_net_hdr_to_skb() {
...
shinfo->gso_type |= SKB_GSO_DODGY;
shinfo->gso_segs = 0;
...
}
With PACKET_QDISC_BYPASS, nothing recomputes gso_segs before the features
check. qdisc_pkt_len_segs_init() is only called from __dev_queue_xmit():
packet_xmit()
dev_direct_xmit()
__dev_direct_xmit()
validate_xmit_skb_list()
validate_xmit_skb()
enetc_features_check() <- gso_segs == 0, GSO features kept
The estimate is therefore just nr_frags, and NETIF_F_GSO_MASK stays set.
enetc does not advertise NETIF_F_GSO_ROBUST, so the skb goes through
__skb_gso_segment(), and tcp_gso_segment() takes this branch:
net/ipv4/tcp_offload.c:tcp_gso_segment() {
...
if (skb_gso_ok(skb, features | NETIF_F_GSO_ROBUST)) {
/* Packet is from an untrusted source, reset gso_segs. */
skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(skb->len, mss);
...
}
This returns NULL, so the original unsegmented skb is passed on, now with
its real gso_segs. With gso_size as small as 8 and a ~64KB payload, that
is roughly 8000 segments, or about 16000 BDs for a 2048-entry ring.
enetc_bd_unused() is at most bd_count - 1, so this check in
enetc_start_xmit() can never become false:
} else {
if (enetc_bd_unused(tx_ring) < tso_count_descs(skb)) {
netif_stop_subqueue(ndev, tx_ring->index);
return NETDEV_TX_BUSY;
}
dev_direct_xmit() frees the skb, but the subqueue stays stopped. The only
place that wakes it is enetc_clean_tx_ring(), and that needs completed
frames:
if (unlikely(tx_frm_cnt && netif_carrier_ok(ndev) &&
__netif_subqueue_stopped(ndev, tx_ring->index) &&
...
netif_wake_subqueue(ndev, tx_ring->index);
If the ring is idle when this happens, and with no ndo_tx_timeout, does
that TX queue stay stopped until the interface is bounced? That would be
the same stall the commit message describes as triggerable "from any
source that can craft gso_segs".
A tc egress BPF program can probably reach the same state as well.
bpf_skb_adjust_room() and similar helpers set gso_segs = 0 together with
SKB_GSO_DODGY, and sch_handle_egress() runs after
qdisc_pkt_len_segs_init().
The af_packet UDP_L4 case does not seem to trigger this, because
virtio_net_hdr_to_skb() caps it at UDP_MAX_SEGMENTS. The TCP case does
trigger it.
Later patches in the series do not appear to change this. At the end of
the series, enetc_features_check() still goes through
enetc_tso_count_descs(), which reads skb_shinfo(skb)->gso_segs.
Would it work to derive the segment count from skb->len, the header length
and gso_size here, at least for SKB_GSO_DODGY skbs? Another option would be
for enetc_start_xmit() to drop, instead of returning NETDEV_TX_BUSY for,
any skb whose estimate is >= tx_ring->bd_count.
> +
> + return features;
> +}
> +EXPORT_SYMBOL_GPL(enetc_features_check);
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118235055.1225115-1-vladimir.oltean%40nxp.com