BPF List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: kuba@kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
	pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org,
	michael.chan@broadcom.com, manishc@marvell.com,
	joshwash@google.com, hramamurthy@google.com, tariqt@nvidia.com,
	saeedm@nvidia.com, daniel@iogearbox.net, hawk@kernel.org,
	sdf@fomichev.me, willemb@google.com,
	przemyslaw.kitszel@intel.com, bpf@vger.kernel.org,
	nktgrg@google.com
Subject: Re: [PATCH net-next v2 4/9] net: state the "XDP excludes HW-GRO" rule in the core
Date: Mon, 23 Nov 2026 01:33:47 +0000	[thread overview]
Message-ID: <179539762712.3135.2625842431945223640@kernel.org> (raw)
In-Reply-To: <20261122010112.1471146-5-kuba@kernel.org>

Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · Low: 1

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).

- [Medium] In dev_xdp_attach() (net/core/dev.c), dev->xdp_pending is set
  and dev_xdp_clear_rx_agg() runs before dev_xdp_install() validates the…
- [Medium] dev_xdp_clear_rx_agg() turns the old warn-and-proceed
  behaviour into a hard failure for every XDP attach mode, generic (SKB)…
- [Low] The commit message describes concrete user-visible bugs that this
  patch fixes, but there is no Fixes: tag.

--

net: state the "XDP excludes HW-GRO" rule in the core

This commit moves the rule that HW-GRO must be off while XDP is attached
into __netdev_update_features(). A new xdp_pending bit makes
dev_xdp_prog_count() report a program while one is being installed. The
attach paths now try to clear HW-GRO first and refuse the attach if they
can't, the detach paths refresh features, and dev_disable_gro_hw() is
removed.

> The device also lost the bit from wanted_features for good, so HW-GRO
> never came back after detach - on mlx5 that took header-data split
> with it, and with it devmem and io_uring zero-copy Rx.

[Severity: Low]
This isn't a bug, but the commit message describes user-visible problems
that this patch fixes, and there is no Fixes: tag. The problems are:

  - the WARN from generic_xdp_install()->dev_disable_gro_hw() on mlx5 with
    tcp-data-split
  - HW-GRO staying off after a generic XDP detach, because
    dev_disable_gro_hw() cleared it from wanted_features
  - idpf running RSC under XDP

idpf_set_netdev_features() advertises GRO_HW with no XDP interlock:

	if (idpf_is_cap_ena_all(adapter, IDPF_RSC_CAPS, IDPF_CAP_RSC))
		other_offloads |= NETIF_F_GRO_HW;

Should this have a Fixes: tag, or a note saying why it isn't meant for
stable?

> diff --git a/net/core/dev.c b/net/core/dev.c
> index 4ca8a9f5a7a5c..5d38cdb6c3260 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c

[ ... ]

> @@ -10617,6 +10599,32 @@ static void dev_xdp_set_prog(struct net_device *dev, enum bpf_xdp_mode mode,
>  	dev->xdp_state[mode].prog = prog;
>  }
>  
> +/* Try to clear HW-GRO before the driver reconfigures for XDP.
> + * Driver may add features back in via ndo_fix_features(), due to feature
> + * dependencies. In that case we can't run XDP at all.
> + */
> +static int dev_xdp_clear_rx_agg(struct net_device *dev,
> +				struct netlink_ext_ack *extack)
> +{
> +	if (!(dev->features & NETIF_F_GRO_HW))
> +		return 0;
> +	if (!(dev->hw_features & NETIF_F_GRO_HW)) {
> +		NL_SET_ERR_MSG(extack,
> +			       "unable to disable HW-GRO, fixed on");
> +		return -EOPNOTSUPP;
> +	}

[Severity: Medium]
Is it intended that generic XDP attach now fails on devices where GRO_HW
is fixed on? The old code warned and attached anyway. This check refuses
the attach in every mode, generic (SKB) mode included.

virtio_net is one such device. With VIRTIO_NET_F_GUEST_TSO4/6 negotiated
and VIRTIO_NET_F_CTRL_GUEST_OFFLOADS missing, virtnet_probe() puts GRO_HW
in features but never in hw_features:

drivers/net/virtio_net.c:virtnet_probe() {
    ...
	if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6))
		dev->features |= NETIF_F_GRO_HW;
    ...
	if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) &&
	    (vi->guest_offloads_capable & GUEST_OFFLOAD_GRO_HW_MASK))
		dev->hw_features |= NETIF_F_GRO_HW;
    ...
}

virtnet_xdp_set() already refuses native XDP in this configuration, so
xdpgeneric was the fallback. Before this patch,
generic_xdp_install()->dev_disable_gro_hw() warned and the program was
attached. Now dev_xdp_attach()->dev_xdp_clear_rx_agg() returns
-EOPNOTSUPP, so xdpgeneric attach fails on these guests.

The commit message covers the old splat and the "attached anyway" outcome.
It doesn't say that such attaches are now refused, and it doesn't mention
the fixed-on case. The later mlx5 patch in the series covers the -EBUSY
refusal for tcp-data-split, but nothing in the series covers virtio_net or
other fixed-on devices.

Could the commit message describe this behavior change?

> +
> +	netdev_update_features(dev);

[ ... ]

> @@ -10880,19 +10905,36 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extack
>  			return -EOPNOTSUPP;
>  		}
>  
> +		if (new_prog) {
> +			dev->xdp_pending = 1;
> +			err = dev_xdp_clear_rx_agg(dev, extack);
> +			if (err)
> +				goto err_clear_pending;
> +		}
> +
>  		err = dev_xdp_install(dev, mode, bpf_op, extack, flags, new_prog);
>  		if (err)
> -			return err;
> +			goto err_clear_pending;
>  	}

[ ... ]

> +
> +err_clear_pending:
> +	dev->xdp_pending = 0;
> +	netdev_update_features(dev);
> +	return err;
>  }

[Severity: Medium]
Should dev_xdp_clear_rx_agg() run only after dev_xdp_install() has
validated the program?

dev_xdp_clear_rx_agg() calls netdev_update_features(), which drops
NETIF_F_GRO_HW and reconfigures the device through ndo_set_features().
dev_xdp_install() can still reject the attach after that, for reasons
unrelated to HW-GRO:

net/core/dev.c:dev_xdp_install() {
    ...
		if (prog->expected_attach_type == BPF_XDP_DEVMAP) {
			NL_SET_ERR_MSG(extack, "BPF_XDP_DEVMAP programs can not be attached to a device");
			return -EINVAL;
		}
    ...
		if (dev->cfg->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED &&
		    !prog->aux->xdp_has_frags) {
    ...
		if (dev_get_min_mp_channel_count(dev)) {
    ...
}

The same applies to offloaded progs without HW_MODE, CPUMAP-typed progs,
and dev-bound progs on the wrong device or in SKB mode.

When that happens, err_clear_pending calls netdev_update_features() again
to turn HW-GRO back on. Nothing checks whether that call succeeded.

On bnxt, every TPA on/off transition in bnxt_set_features() sets re_init:

drivers/net/ethernet/broadcom/bnxt/bnxt.c:bnxt_set_features() {
    ...
	if (changes & BNXT_FLAG_TPA) {
		update_tpa = true;
		if ((bp->flags & BNXT_FLAG_TPA) == 0 ||
		    (flags & BNXT_FLAG_TPA) == 0 || ...)
			re_init = true;
	}
    ...
}

So a misconfigured attach on bnxt would close and reopen the NIC twice
before being refused. Examples are a DEVMAP-typed program, or any XDP
program on a port with tcp-data-split or a memory provider bound.

Each such attempt also sends two NETDEV_FEAT_CHANGE notifications. If the
restoring ndo_set_features() fails, HW-GRO stays off with no XDP program
attached.

The extack also changes. On mlx5 with tcp-data-split enabled,
mlx5e_fix_features() adds GRO_HW back:

drivers/net/ethernet/mellanox/mlx5/core/en_main.c:mlx5e_fix_features() {
    ...
	if (cfg && cfg->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED &&
	    !(features & NETIF_F_GRO_HW)) {
		...
		features |= NETIF_F_GRO_HW;
	}
    ...
}

A single-buffer program then gets "unable to disable HW-GRO, required by
another feature" instead of the more specific "unable to install XDP to
device using tcp-data-split".

netif_xdp_propagate() runs its hds_config and memory provider checks
before it sets xdp_pending and calls dev_xdp_clear_rx_agg(). Could
dev_xdp_attach() use the same order, so the checks in dev_xdp_install()
run before any features change?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122010112.1471146-1-kuba%40kernel.org

  reply	other threads:[~2026-11-23  1:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22  1:01 [PATCH net-next v2 0/9] net: make core auto-disable HW-GRO and LRO when XDP gets attached Jakub Kicinski
2026-11-22  1:01 ` [PATCH net-next v2 1/9] net: stop making HW-GRO depend on SW GRO Jakub Kicinski
2026-11-22  1:01 ` [PATCH net-next v2 2/9] selftests: drv-net: gro_stats: use the shared set_ethtool_feat() Jakub Kicinski
2026-11-22  1:01 ` [PATCH net-next v2 3/9] selftests: drv-net: drop the generic XDP hack from the HW GRO setup Jakub Kicinski
2026-11-22  1:01 ` [PATCH net-next v2 4/9] net: state the "XDP excludes HW-GRO" rule in the core Jakub Kicinski
2026-11-23  1:33   ` netdev-bot+sashiko [this message]
2026-11-22  1:01 ` [PATCH net-next v2 5/9] net: state the "XDP excludes LRO" " Jakub Kicinski
2026-11-23  1:33   ` netdev-bot+sashiko
2026-11-22  1:01 ` [PATCH net-next v2 6/9] eth: mlx5e: drop the now-dead HW-GRO and LRO vs XDP handling Jakub Kicinski
2026-11-23  1:01   ` sashiko-bot
2026-11-23  1:33   ` netdev-bot+sashiko
2026-11-22  1:01 ` [PATCH net-next v2 7/9] eth: bnxt_en: don't clear HW-GRO and LRO for XDP in ndo_fix_features Jakub Kicinski
2026-11-22  1:01 ` [PATCH net-next v2 8/9] eth: qede: drop the now-dead HW-GRO vs XDP handling Jakub Kicinski
2026-11-22  1:01 ` [PATCH net-next v2 9/9] eth: gve: drop the now-dead HW-GRO vs XDP interlock Jakub Kicinski
2026-11-23  1:33   ` netdev-bot+sashiko

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=179539762712.3135.2625842431945223640@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=hramamurthy@google.com \
    --cc=joshwash@google.com \
    --cc=kuba@kernel.org \
    --cc=manishc@marvell.com \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=nktgrg@google.com \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=saeedm@nvidia.com \
    --cc=sdf@fomichev.me \
    --cc=tariqt@nvidia.com \
    --cc=willemb@google.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox