🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
4 messages
4 total messages Started by Jakub Kicinski Wed, 18 Nov 2026 23:23
[PATCH net-next 3/8] net: state the "XDP excludes HW-GRO" rule in the core
#18800
Author: Jakub Kicinski
Date: Wed, 18 Nov 2026 23:23
262 lines
16539 bytes
XDP has to see the frames as the wire delivered them, so HW-GRO must be
off while a program is attached. Drivers currently open-code that policy,
and they diverge: mlx5, gve and virtio_net refuse the attach, bnxt and
qede clear the feature from ndo_fix_features(), and idpf does nothing
at all and happily runs RSC under XDP.

Clear HW-GRO in __netdev_update_features(), and make sure XDP setup
paths refresh the features.

Take extra care to make sure the disablement actually works, some
drivers add the feature back in ndo_fix_features, even when removed
from wanted features (mlx5 does for header-data-split).

This change also removes the warn-only check dev_disable_gro_hw()
performed. On mlx5 with tcp-data-split on, attaching a multi-buf
generic XDP program reached generic_xdp_install(), whose
dev_disable_gro_hw() cleared wanted_features, recomputed, saw
mlx5e_fix_features() put NETIF_F_GRO_HW straight back, and splatted:

  ------------[ cut here ]------------
  netdevice: eth0: failed to disable GRO_HW!
  WARNING: net/core/dev.c:1880 at generic_xdp_install+0x135/0x190, CPU#53: ip/667
  RIP: 0010:generic_xdp_install+0x17a/0x190
  Call Trace:
   <TASK>
   dev_xdp_install+0x2aa/0x380
   dev_xdp_attach+0x41f/0x460
   dev_change_xdp_fd+0xbb/0x110
   do_setlink+0xfb9/0x1030
   rtnl_newlink+0x9f5/0xaf0
   rtnetlink_rcv_msg+0x442/0x490
   netlink_rcv_skb+0x16a/0x1a0
   netlink_unicast+0x1fc/0x320
   netlink_sendmsg+0x2d6/0x380

and then attached anyway, leaving XDP looking at coalesced frames.
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.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 .../networking/net_cachelines/net_device.rst  |  1 +
 include/linux/netdevice.h                     |  6 ++
 net/core/dev.c                                | 97 ++++++++++++++-----
 3 files changed, 81 insertions(+), 23 deletions(-)

diff --git a/Documentation/networking/net_cachelines/net_device.rst b/Documentation/networking/net_cachelines/net_device.rst
index 7620d3fcb8dc..25cf02a184ec 100644
--- a/Documentation/networking/net_cachelines/net_device.rst
+++ b/Documentation/networking/net_cachelines/net_device.rst
@@ -169,6 +169,7 @@ unsigned_long:1                     see_all_hwtstamp_requests
 unsigned_long:1                     change_proto_down
 unsigned_long:1                     netns_immutable
 unsigned_long:1                     fcoe_mtu
+unsigned_long:1                     xdp_pending
 unsigned_long:1                     xdp_from_upper
 struct list_head                    net_notifier_list
 struct macsec_ops*                  macsec_ops
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 0325c6f2a7d1..049538b13e61 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2531,6 +2531,12 @@ struct net_device {
 	unsigned long		change_proto_down:1;
 	unsigned long		netns_immutable:1;
 	unsigned long		fcoe_mtu:1;
+	/**
+	 * @xdp_pending: an XDP program is being installed, but is not in
+	 *	@xdp_state yet. Most users should access it implicitly via
+	 *	helpers like dev_xdp_prog_count(), rather than directly.
+	 */
+	unsigned long		xdp_pending:1;
 	/**
 	 * @xdp_from_upper: the program in @xdp_state was installed by an
 	 *	upper device with netif_xdp_propagate(); it belongs to the
diff --git a/net/core/dev.c b/net/core/dev.c
index d88af07aea29..c0bb5eb9fdea 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1901,23 +1901,6 @@ void netif_disable_lro(struct net_device *dev)
 	}
 }
 
-/**
- *	dev_disable_gro_hw - disable HW Generic Receive Offload on a device
- *	@dev: device
- *
- *	Disable HW Generic Receive Offload (GRO_HW) on a net device.  Must be
- *	called under RTNL.  This is needed if Generic XDP is installed on
- *	the device.
- */
-static void dev_disable_gro_hw(struct net_device *dev)
-{
-	dev->wanted_features &= ~NETIF_F_GRO_HW;
-	netdev_update_features(dev);
-
-	if (unlikely(dev->features & NETIF_F_GRO_HW))
-		netdev_WARN(dev, "failed to disable GRO_HW!\n");
-}
-
 const char *netdev_cmd_to_name(enum netdev_cmd cmd)
 {
 #define N(val) 						\
@@ -6652,7 +6635,6 @@ static int generic_xdp_install(struct net_device *dev, struct netdev_bpf *xdp)
 		} else if (new && !old) {
 			static_branch_inc(&generic_xdp_needed_key);
 			netif_disable_lro(dev);
-			dev_disable_gro_hw(dev);
 		}
 		break;
 
@@ -10571,7 +10553,7 @@ u8 dev_xdp_prog_count(struct net_device *dev)
 	for (i = 0; i < __MAX_XDP_MODE; i++)
 		if (dev->xdp_state[i].prog || dev->xdp_state[i].link)
 			count++;
-	return count;
+	return count ?: !!dev->xdp_pending;
 }
 EXPORT_SYMBOL_GPL(dev_xdp_prog_count);
 
@@ -10612,6 +10594,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;
+	}
+
+	netdev_update_features(dev);
+
+	if (dev->features & NETIF_F_GRO_HW) {
+		NL_SET_ERR_MSG(extack,
+			       "unable to disable HW-GRO, required by another feature");
+		return -EBUSY;
+	}
+
+	return 0;
+}
+
 int netif_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf)
 {
 	struct bpf_prog *old_prog;
@@ -10645,11 +10653,17 @@ int netif_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf)
 				       "unable to propagate XDP to device using memory provider");
 			return -EBUSY;
 		}
+
+		dev->xdp_pending = 1;
+
+		err = dev_xdp_clear_rx_agg(dev, bpf->extack);
+		if (err)
+			goto err_clear_pending;
 	}
 
 	err = dev->netdev_ops->ndo_bpf(dev, bpf);
 	if (err)
-		return err;
+		goto err_clear_pending;
 	if (bpf->prog)
 		bpf_prog_inc(bpf->prog);
 
@@ -10662,11 +10676,22 @@ int netif_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf)
 	old_prog = dev_xdp_prog(dev, XDP_MODE_DRV);
 	bpf_prog_change_xdp(old_prog, bpf->prog);
 	dev_xdp_set_prog(dev, XDP_MODE_DRV, bpf->prog);
+	dev->xdp_pending = 0;
 	dev->xdp_from_upper = !!bpf->prog;
-	if (old_prog)
+
+	if (old_prog) {
 		bpf_prog_put(old_prog);
+		/* The last program is gone, HW-GRO may be available again */
+		if (!bpf->prog)
+			netdev_update_features(dev);
+	}
 
 	return 0;
+
+err_clear_pending:
+	dev->xdp_pending = 0;
+	netdev_update_features(dev);
+	return err;
 }
 EXPORT_SYMBOL_GPL(netif_xdp_propagate);
 
@@ -10875,19 +10900,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;
 	}
 
 	if (link)
 		dev_xdp_set_link(dev, mode, link);
 	else
 		dev_xdp_set_prog(dev, mode, new_prog);
-	if (cur_prog)
+	dev->xdp_pending = 0;
+	if (cur_prog) {
 		bpf_prog_put(cur_prog);
+		/* The last program is gone, HW-GRO may be available again */
+		if (!new_prog)
+			netdev_update_features(dev);
+	}
 
 	return 0;
+
+err_clear_pending:
+	dev->xdp_pending = 0;
+	netdev_update_features(dev);
+	return err;
 }
 
 static int dev_xdp_attach_link(struct net_device *dev,
@@ -10913,6 +10955,7 @@ static int dev_xdp_detach_link(struct net_device *dev,
 	bpf_op = dev_xdp_bpf_op(dev, mode);
 	WARN_ON(dev_xdp_install(dev, mode, bpf_op, NULL, 0, NULL));
 	dev_xdp_set_link(dev, mode, NULL);
+	netdev_update_features(dev);
 	return 0;
 }
 
@@ -11385,6 +11428,14 @@ int __netdev_update_features(struct net_device *dev)
 
 	features = netdev_get_wanted_features(dev);
 
+	/* GRO_HW may be added back in via ndo_fix_features e.g. if driver needs
+	 * it to honor the HDS config, clear it before the fix features call.
+	 */
+	if ((features & NETIF_F_GRO_HW) && dev_xdp_prog_count(dev)) {
+		netdev_dbg(dev, "Dropping HW-GRO feature since XDP is attached.\n");
+		features &= ~NETIF_F_GRO_HW;
+	}
+
 	if (dev->netdev_ops->ndo_fix_features)
 		features = dev->netdev_ops->ndo_fix_features(dev, features);
 
-- 
2.56.1
Re: [PATCH net-next 3/8] net: state the "XDP excludes HW-GRO" rule in the core
#19448
Author: Willem de Bruijn
Date: Thu, 19 Nov 2026 22:59
282 lines
21408 bytes
Jakub Kicinski wrote:
> XDP has to see the frames as the wire delivered them, so HW-GRO must be
> off while a program is attached. Drivers currently open-code that policy,
> and they diverge: mlx5, gve and virtio_net refuse the attach, bnxt and
> qede clear the feature from ndo_fix_features(), and idpf does nothing
> at all and happily runs RSC under XDP.
> 
> Clear HW-GRO in __netdev_update_features(), and make sure XDP setup
> paths refresh the features.
> 
> Take extra care to make sure the disablement actually works, some
> drivers add the feature back in ndo_fix_features, even when removed
> from wanted features (mlx5 does for header-data-split).
> 
> This change also removes the warn-only check dev_disable_gro_hw()
> performed. On mlx5 with tcp-data-split on, attaching a multi-buf
> generic XDP program reached generic_xdp_install(), whose
> dev_disable_gro_hw() cleared wanted_features, recomputed, saw
> mlx5e_fix_features() put NETIF_F_GRO_HW straight back, and splatted:
> 
>   ------------[ cut here ]------------
>   netdevice: eth0: failed to disable GRO_HW!
>   WARNING: net/core/dev.c:1880 at generic_xdp_install+0x135/0x190, CPU#53: ip/667
>   RIP: 0010:generic_xdp_install+0x17a/0x190
>   Call Trace:
>    <TASK>
>    dev_xdp_install+0x2aa/0x380
>    dev_xdp_attach+0x41f/0x460
>    dev_change_xdp_fd+0xbb/0x110
>    do_setlink+0xfb9/0x1030
>    rtnl_newlink+0x9f5/0xaf0
>    rtnetlink_rcv_msg+0x442/0x490
>    netlink_rcv_skb+0x16a/0x1a0
>    netlink_unicast+0x1fc/0x320
>    netlink_sendmsg+0x2d6/0x380
> 
> and then attached anyway, leaving XDP looking at coalesced frames.
> 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.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
>  .../networking/net_cachelines/net_device.rst  |  1 +
>  include/linux/netdevice.h                     |  6 ++
>  net/core/dev.c                                | 97 ++++++++++++++-----
>  3 files changed, 81 insertions(+), 23 deletions(-)
> 
> diff --git a/Documentation/networking/net_cachelines/net_device.rst b/Documentation/networking/net_cachelines/net_device.rst
> index 7620d3fcb8dc..25cf02a184ec 100644
> --- a/Documentation/networking/net_cachelines/net_device.rst
> +++ b/Documentation/networking/net_cachelines/net_device.rst
> @@ -169,6 +169,7 @@ unsigned_long:1                     see_all_hwtstamp_requests
>  unsigned_long:1                     change_proto_down
>  unsigned_long:1                     netns_immutable
>  unsigned_long:1                     fcoe_mtu
> +unsigned_long:1                     xdp_pending
>  unsigned_long:1                     xdp_from_upper
>  struct list_head                    net_notifier_list
>  struct macsec_ops*                  macsec_ops
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 0325c6f2a7d1..049538b13e61 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -2531,6 +2531,12 @@ struct net_device {
>  	unsigned long		change_proto_down:1;
>  	unsigned long		netns_immutable:1;
>  	unsigned long		fcoe_mtu:1;
> +	/**
> +	 * @xdp_pending: an XDP program is being installed, but is not in
> +	 *	@xdp_state yet. Most users should access it implicitly via
> +	 *	helpers like dev_xdp_prog_count(), rather than directly.
> +	 */
> +	unsigned long		xdp_pending:1;
>  	/**
>  	 * @xdp_from_upper: the program in @xdp_state was installed by an
>  	 *	upper device with netif_xdp_propagate(); it belongs to the
> diff --git a/net/core/dev.c b/net/core/dev.c
> index d88af07aea29..c0bb5eb9fdea 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -1901,23 +1901,6 @@ void netif_disable_lro(struct net_device *dev)
>  	}
>  }
>  
> -/**
> - *	dev_disable_gro_hw - disable HW Generic Receive Offload on a device
> - *	@dev: device
> - *
> - *	Disable HW Generic Receive Offload (GRO_HW) on a net device.  Must be
> - *	called under RTNL.  This is needed if Generic XDP is installed on
> - *	the device.
> - */
> -static void dev_disable_gro_hw(struct net_device *dev)
> -{
> -	dev->wanted_features &= ~NETIF_F_GRO_HW;
> -	netdev_update_features(dev);
> -
> -	if (unlikely(dev->features & NETIF_F_GRO_HW))
> -		netdev_WARN(dev, "failed to disable GRO_HW!\n");
> -}
> -
>  const char *netdev_cmd_to_name(enum netdev_cmd cmd)
>  {
>  #define N(val) 						\
> @@ -6652,7 +6635,6 @@ static int generic_xdp_install(struct net_device *dev, struct netdev_bpf *xdp)
>  		} else if (new && !old) {
>  			static_branch_inc(&generic_xdp_needed_key);
>  			netif_disable_lro(dev);
> -			dev_disable_gro_hw(dev);
>  		}
>  		break;
>  
> @@ -10571,7 +10553,7 @@ u8 dev_xdp_prog_count(struct net_device *dev)
>  	for (i = 0; i < __MAX_XDP_MODE; i++)
>  		if (dev->xdp_state[i].prog || dev->xdp_state[i].link)
>  			count++;
> -	return count;
> +	return count ?: !!dev->xdp_pending;
>  }
>  EXPORT_SYMBOL_GPL(dev_xdp_prog_count);
>  
> @@ -10612,6 +10594,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;
> +	}
> +
> +	netdev_update_features(dev);
> +
> +	if (dev->features & NETIF_F_GRO_HW) {
> +		NL_SET_ERR_MSG(extack,
> +			       "unable to disable HW-GRO, required by another feature");
> +		return -EBUSY;
> +	}
> +
> +	return 0;
> +}
> +
>  int netif_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf)
>  {
>  	struct bpf_prog *old_prog;
> @@ -10645,11 +10653,17 @@ int netif_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf)
>  				       "unable to propagate XDP to device using memory provider");
>  			return -EBUSY;
>  		}
> +
> +		dev->xdp_pending = 1;
> +
> +		err = dev_xdp_clear_rx_agg(dev, bpf->extack);
> +		if (err)
> +			goto err_clear_pending;
>  	}
>  
>  	err = dev->netdev_ops->ndo_bpf(dev, bpf);
>  	if (err)
> -		return err;
> +		goto err_clear_pending;
>  	if (bpf->prog)
>  		bpf_prog_inc(bpf->prog);
>  
> @@ -10662,11 +10676,22 @@ int netif_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf)
>  	old_prog = dev_xdp_prog(dev, XDP_MODE_DRV);
>  	bpf_prog_change_xdp(old_prog, bpf->prog);
>  	dev_xdp_set_prog(dev, XDP_MODE_DRV, bpf->prog);
> +	dev->xdp_pending = 0;
>  	dev->xdp_from_upper = !!bpf->prog;
> -	if (old_prog)
> +
> +	if (old_prog) {
>  		bpf_prog_put(old_prog);
> +		/* The last program is gone, HW-GRO may be available again */
> +		if (!bpf->prog)
> +			netdev_update_features(dev);
> +	}
>  
>  	return 0;
> +
> +err_clear_pending:
> +	dev->xdp_pending = 0;
> +	netdev_update_features(dev);
> +	return err;
>  }
>  EXPORT_SYMBOL_GPL(netif_xdp_propagate);
>  
> @@ -10875,19 +10900,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;
>  	}
>  
>  	if (link)
>  		dev_xdp_set_link(dev, mode, link);
>  	else
>  		dev_xdp_set_prog(dev, mode, new_prog);
> -	if (cur_prog)
> +	dev->xdp_pending = 0;
> +	if (cur_prog) {
>  		bpf_prog_put(cur_prog);
> +		/* The last program is gone, HW-GRO may be available again */
> +		if (!new_prog)
> +			netdev_update_features(dev);
> +	}
>  
>  	return 0;
> +
> +err_clear_pending:
> +	dev->xdp_pending = 0;
> +	netdev_update_features(dev);
> +	return err;
>  }
>  
>  static int dev_xdp_attach_link(struct net_device *dev,
> @@ -10913,6 +10955,7 @@ static int dev_xdp_detach_link(struct net_device *dev,
>  	bpf_op = dev_xdp_bpf_op(dev, mode);
>  	WARN_ON(dev_xdp_install(dev, mode, bpf_op, NULL, 0, NULL));
>  	dev_xdp_set_link(dev, mode, NULL);
> +	netdev_update_features(dev);
>  	return 0;
>  }
>  
> @@ -11385,6 +11428,14 @@ int __netdev_update_features(struct net_device *dev)
>  
>  	features = netdev_get_wanted_features(dev);
>  
> +	/* GRO_HW may be added back in via ndo_fix_features e.g. if driver needs
> +	 * it to honor the HDS config, clear it before the fix features call.
> +	 */
> +	if ((features & NETIF_F_GRO_HW) && dev_xdp_prog_count(dev)) {
> +		netdev_dbg(dev, "Dropping HW-GRO feature since XDP is attached.\n");
> +		features &= ~NETIF_F_GRO_HW;
> +	}
> +

Apparently drivers can enable HW_GRO in some edge case (that can be
plugged itself?):

    The rule is only enforced at attach time (dev_xdp_clear_rx_agg). Later
    recomputes don't re-check after ndo_fix_features. Example:
      1. Attach a multi-buf XDP program to mlx5 with HDS off. HW-GRO goes off.
      2. Enable tcp-data-split. rings.c:253 only refuses this for
         single-buffer XDP, via dev_xdp_sb_prog_count().
      3. The next feature recompute runs mlx5e_fix_features(), and its
         "Keeping HW-GRO enabled" block (en_main.c:4643) sets GRO_HW again,
         after this strip. HW-GRO is now on with XDP attached.
    This already happens today, but once 5/8 removes mlx5's own XDP check
    the core is the only guard, and it misses this case. Either add a
    post-fix_features check here (warn and strip, or refuse the change), or
    make the HDS-enable path in rings.c refuse while any XDP program is
    attached and the driver ties HDS to HW-GRO.

>  	if (dev->netdev_ops->ndo_fix_features)
>  		features = dev->netdev_ops->ndo_fix_features(dev, features);
>  
> -- 
> 2.56.1
> 
Re: [PATCH net-next 3/8] net: state the "XDP excludes HW-GRO" rule in the core
#19993
Author: Jakub Kicinski
Date: Fri, 20 Nov 2026 22:13
30 lines
9377 bytes
On Thu, 19 Nov 2026 17:59:08 -0500 Willem de Bruijn wrote:
> Apparently drivers can enable HW_GRO in some edge case (that can be
> plugged itself?):
> 
>     The rule is only enforced at attach time (dev_xdp_clear_rx_agg). Later
>     recomputes don't re-check after ndo_fix_features. Example:
>       1. Attach a multi-buf XDP program to mlx5 with HDS off. HW-GRO goes off.
>       2. Enable tcp-data-split. rings.c:253 only refuses this for
>          single-buffer XDP, via dev_xdp_sb_prog_count().
>       3. The next feature recompute runs mlx5e_fix_features(), and its
>          "Keeping HW-GRO enabled" block (en_main.c:4643) sets GRO_HW again,
>          after this strip. HW-GRO is now on with XDP attached.
>     This already happens today, but once 5/8 removes mlx5's own XDP check
>     the core is the only guard, and it misses this case. Either add a
>     post-fix_features check here (warn and strip, or refuse the change), or
>     make the HDS-enable path in rings.c refuse while any XDP program is
>     attached and the driver ties HDS to HW-GRO.

Enabling of HDS can't happen in the sequence you describe, driver
checks:

static bool mlx5e_ethtool_set_tcp_data_split(struct mlx5e_priv *priv, 
...
        if (tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_ENABLED &&                 
            !(dev->features & NETIF_F_GRO_HW)) {    

and with XDP attached GRO_HW is not in features (only wanted_features)

Thanks for the reviews, I'll spin v2 before EOD
Re: [PATCH net-next 3/8] net: state the "XDP excludes HW-GRO" rule in the core
#20476
Author: netdev-bot+sashiko
Date: Sun, 22 Nov 2026 17:03
179 lines
14633 bytes
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] Generic (SKB-mode) XDP attach now fails on devices where
  NETIF_F_GRO_HW is fixed on, i.e. present in dev->features but missing…
- [Medium] dev_xdp_attach() now sets dev->xdp_pending = 1 and calls
  dev_xdp_clear_rx_agg() before dev_xdp_install() runs its validation.
- [Low] The commit fixes concrete user-visible bugs but carries no Fixes:
  tag.

--

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

This commit moves the "XDP excludes HW-GRO" policy into the core. While an
XDP program is attached or pending, __netdev_update_features() now clears
NETIF_F_GRO_HW. The XDP attach paths call a new helper,
dev_xdp_clear_rx_agg(), which refuses the attach if HW-GRO cannot be
turned off, and the warn-only 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.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

[Severity: Low]
Should this carry a Fixes: tag? Two things combine to cause the splat and
the permanent loss of NETIF_F_GRO_HW from wanted_features:

  - the HDS-forces-GRO_HW logic in mlx5e_fix_features()
  - the warn-and-continue behavior of dev_disable_gro_hw()

The mlx5 logic was added by:

  Fixes: 46bcce5dfd33 ("net/mlx5e: Support ethtool tcp-data-split settings")

Without a tag, stable and backport tooling can't tell which kernels are
affected. If the series is meant only for net-next, this can be ignored.

> diff --git a/net/core/dev.c b/net/core/dev.c
> index d88af07aea290..c0bb5eb9fdea0 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c

[ ... ]

> @@ -10612,6 +10594,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]
Does this stop generic XDP from attaching to virtio_net devices where
GRO_HW is fixed on?

virtnet_probe() adds GRO_HW to dev->features whenever GUEST_TSO4/6 is
negotiated. It only adds it to hw_features when CTRL_GUEST_OFFLOADS is
negotiated, and that needs the optional ctrl vq:

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;
    ...
}

Before this patch, generic_xdp_install()->dev_disable_gro_hw() printed
the "failed to disable GRO_HW!" warning and then attached the program
anyway. Now dev_xdp_attach()->dev_xdp_clear_rx_agg() returns -EOPNOTSUPP
before dev_xdp_install() is reached.

virtnet_xdp_set() already refuses native XDP on these setups:

drivers/net/virtio_net.c:virtnet_xdp_set() {
    ...
		NL_SET_ERR_MSG_MOD(extack, "Can't set XDP while host is implementing GRO_HW/CSUM, disable GRO_HW/CSUM first");
		return -EOPNOTSUPP;
    ...
}

So xdpgeneric was the only option left, for example for loaders that fall
back from native to SKB mode.

The refusal matches the new rule. Even so, could the commit message say
that generic XDP attaches which used to succeed are now rejected? The
check is still there at the end of the series, where it also covers LRO.

[ ... ]

> @@ -10875,19 +10900,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;
>  	}

[Severity: Medium]
Is it intended that the hardware gets reconfigured here before
dev_xdp_install() has validated the request?

dev_xdp_clear_rx_agg() calls netdev_update_features(), which ends up in
ndo_set_features(). These checks in dev_xdp_install() only run after
that:

  - native and generic XDP active at the same time
  - an offloaded program without HW_MODE
  - a device-bound program on the wrong device or in SKB mode
  - a BPF_XDP_DEVMAP or BPF_XDP_CPUMAP attach type
  - tcp-data-split enabled with a non-frags program
  - a bound memory provider

The core used to reject such requests without touching the device. Now
it turns HW-GRO off first, the request fails, and err_clear_pending calls
netdev_update_features() again to turn HW-GRO back on.

On bnxt, a GRO_HW change toggles BNXT_FLAG_TPA, so
bnxt_set_features() calls bnxt_reinit_features():

drivers/net/ethernet/broadcom/bnxt/bnxt.c:bnxt_reinit_features() {
	bnxt_close_nic(bp, irq_re_init, link_re_init);
	bp->flags = flags;
	if (update_tpa)
		bnxt_set_ring_params(bp);
	return bnxt_open_nic(bp, irq_re_init, link_re_init);
}

One rejected attach therefore costs two full close/open cycles of the
NIC, memory provider queues included.

If either bnxt_open_nic() call fails, __netdev_update_features() only
logs "set_features() failed". Could that leave the device with its rings
freed while it is still IFF_UP?

netif_xdp_propagate() already runs its hds and memory provider checks
before it calls dev_xdp_clear_rx_agg(). Could dev_xdp_attach() also run
the dev_xdp_install() pre-checks before clearing rx aggregation? The
ordering is the same at the end of the series.

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

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads