🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
3 messages
3 total messages Started by Jakub Kicinski Wed, 18 Nov 2026 23:23
[PATCH net-next 4/8] net: state the "XDP excludes LRO" rule in the core
#18802
Author: Jakub Kicinski
Date: Wed, 18 Nov 2026 23:23
159 lines
14243 bytes
LRO is the older take on the same thing as HW-GRO. And similarly to
HW-GRO XDP cannot be handed post-LRO frames. Drivers open-code
the exclusion just like they did for HW-GRO, and disagree just the
same: mlx5 and netvsc refuse the attach, bnxt and ixgbe clear the feature
from ndo_fix_features(), vmxnet3 writes dev->features behind the core's
back, and atlantic only minds single-buffer programs. Clear LRO next to
HW-GRO, with the same ordering and the same refusal if a driver insists
on keeping it.

atlantic loses LRO under a multi-buffer program now as well. XDP_TX and
redirect can't carry the GSO metadata of a coalesced frame, however
many buffers it spans.

Drop netif_disable_lro() from generic_xdp_install(), like the previous
patch dropped dev_disable_gro_hw(). The core covers the device itself,
and LRO no longer stays off after the detach.

This changes the behavior for lower devices. netif_disable_lro() walked
them, dev_disable_gro_hw() never did. And unlike HW-GRO, LRO is in
NETIF_F_UPPER_DISABLES, an upper which loses it clears it from the
wanted_features of its lowers for good. bond and team carry LRO only to
hand it down, so a program on a bond still turns LRO off on the slaves,
and they don't get it back after the detach. Making sure lowers don't
coalesce is a separate problem, for HW-GRO and LRO alike.

LRO state with the program [attached / after it's detached], netdevsim
as the single device, bond of two vmxnet3 ports:

  program on    device   w/o patch    w/ patch
  ------------  -------  -----------  ---------
  dev, native   dev      on  / on `1  off / on
  dev, generic  dev      off / off    off / on
  bond, native  bond     on  / on     off / on
                slaves   off / off`2  off / off
  bond, generic bond     off / off    off / on
                slaves   off / off    off / off

 `1 netdevsim ignores LRO under XDP, real drivers turned it off one
    way or another
 `2 vmxnet3 clears LRO from dev->features by itself and nothing turns
    it back on, bnxt slaves would get it back

Ideally we'd want [off / on] (XDP disables LRO, LRO comes back once
XDP is cleared). But the two "off"s after detach on slaves are not
worth the complexity IMHO.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 include/linux/netdev_features.h |  6 ++++++
 net/core/dev.c                  | 36 ++++++++++++++++++++-------------
 2 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h
index 8eb6b8033606..62a05df8ee68 100644
--- a/include/linux/netdev_features.h
+++ b/include/linux/netdev_features.h
@@ -234,6 +234,12 @@ static inline int find_next_netdev_feature(u64 feature, unsigned long start)
  */
 #define NETIF_F_UPPER_DISABLES	NETIF_F_LRO
 
+/*
+ * Receive offloads which coalesce frames. XDP has to see the frames as the
+ * wire delivered them, so these are disabled while a program is attached.
+ */
+#define NETIF_F_XDP_DISABLES	(NETIF_F_GRO_HW | NETIF_F_LRO)
+
 /* changeable features with no special hardware requirements */
 #define NETIF_F_SOFT_FEATURES	(NETIF_F_GSO | NETIF_F_GRO)
 
diff --git a/net/core/dev.c b/net/core/dev.c
index c0bb5eb9fdea..2b9c7aac0969 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6634,7 +6634,6 @@ static int generic_xdp_install(struct net_device *dev, struct netdev_bpf *xdp)
 			static_branch_dec(&generic_xdp_needed_key);
 		} else if (new && !old) {
 			static_branch_inc(&generic_xdp_needed_key);
-			netif_disable_lro(dev);
 		}
 		break;
 
@@ -10594,26 +10593,35 @@ 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.
+static const char *dev_xdp_rx_agg_name(netdev_features_t features)
+{
+	return features & NETIF_F_GRO_HW ? "HW-GRO" : "LRO";
+}
+
+/* Try to clear HW-GRO and LRO 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))
+	netdev_features_t agg = dev->features & NETIF_F_XDP_DISABLES;
+
+	if (!agg)
 		return 0;
-	if (!(dev->hw_features & NETIF_F_GRO_HW)) {
-		NL_SET_ERR_MSG(extack,
-			       "unable to disable HW-GRO, fixed on");
+	if (agg & ~dev->hw_features) {
+		NL_SET_ERR_MSG_FMT(extack, "unable to disable %s, fixed on",
+				   dev_xdp_rx_agg_name(agg & ~dev->hw_features));
 		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");
+	agg = dev->features & NETIF_F_XDP_DISABLES;
+	if (agg) {
+		NL_SET_ERR_MSG_FMT(extack,
+				   "unable to disable %s, required by another feature",
+				   dev_xdp_rx_agg_name(agg));
 		return -EBUSY;
 	}
 
@@ -10681,7 +10689,7 @@ int netif_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf)
 
 	if (old_prog) {
 		bpf_prog_put(old_prog);
-		/* The last program is gone, HW-GRO may be available again */
+		/* No program left, HW-GRO and LRO may be available again */
 		if (!bpf->prog)
 			netdev_update_features(dev);
 	}
@@ -10919,7 +10927,7 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extack
 	dev->xdp_pending = 0;
 	if (cur_prog) {
 		bpf_prog_put(cur_prog);
-		/* The last program is gone, HW-GRO may be available again */
+		/* No program left, HW-GRO and LRO may be available again */
 		if (!new_prog)
 			netdev_update_features(dev);
 	}
@@ -11431,9 +11439,9 @@ int __netdev_update_features(struct net_device *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 ((features & NETIF_F_XDP_DISABLES) && dev_xdp_prog_count(dev)) {
+		netdev_dbg(dev, "Dropping HW-GRO and LRO features since XDP is attached.\n");
+		features &= ~NETIF_F_XDP_DISABLES;
 	}
 
 	if (dev->netdev_ops->ndo_fix_features)
-- 
2.56.1
Re: [PATCH net-next 4/8] net: state the "XDP excludes LRO" rule in the core
#19453
Author: Willem de Bruijn
Date: Thu, 19 Nov 2026 23:02
51 lines
13578 bytes
Jakub Kicinski wrote:
> LRO is the older take on the same thing as HW-GRO. And similarly to
> HW-GRO XDP cannot be handed post-LRO frames. Drivers open-code
> the exclusion just like they did for HW-GRO, and disagree just the
> same: mlx5 and netvsc refuse the attach, bnxt and ixgbe clear the feature
> from ndo_fix_features(), vmxnet3 writes dev->features behind the core's
> back, and atlantic only minds single-buffer programs. Clear LRO next to
> HW-GRO, with the same ordering and the same refusal if a driver insists
> on keeping it.
> 
> atlantic loses LRO under a multi-buffer program now as well. XDP_TX and
> redirect can't carry the GSO metadata of a coalesced frame, however
> many buffers it spans.
> 
> Drop netif_disable_lro() from generic_xdp_install(), like the previous
> patch dropped dev_disable_gro_hw(). The core covers the device itself,
> and LRO no longer stays off after the detach.
> 
> This changes the behavior for lower devices. netif_disable_lro() walked
> them, dev_disable_gro_hw() never did. And unlike HW-GRO, LRO is in
> NETIF_F_UPPER_DISABLES, an upper which loses it clears it from the
> wanted_features of its lowers for good. bond and team carry LRO only to
> hand it down, so a program on a bond still turns LRO off on the slaves,
> and they don't get it back after the detach. Making sure lowers don't
> coalesce is a separate problem, for HW-GRO and LRO alike.
> 
> LRO state with the program [attached / after it's detached], netdevsim
> as the single device, bond of two vmxnet3 ports:
> 
>   program on    device   w/o patch    w/ patch
>   ------------  -------  -----------  ---------
>   dev, native   dev      on  / on `1  off / on
>   dev, generic  dev      off / off    off / on
>   bond, native  bond     on  / on     off / on
>                 slaves   off / off`2  off / off
>   bond, generic bond     off / off    off / on
>                 slaves   off / off    off / off
> 
>  `1 netdevsim ignores LRO under XDP, real drivers turned it off one
>     way or another
>  `2 vmxnet3 clears LRO from dev->features by itself and nothing turns
>     it back on, bnxt slaves would get it back
> 
> Ideally we'd want [off / on] (XDP disables LRO, LRO comes back once
> XDP is cleared). But the two "off"s after detach on slaves are not
> worth the complexity IMHO.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Reviewed-by: Willem de Bruijn <willemb@google.com>
Re: [PATCH net-next 4/8] net: state the "XDP excludes LRO" rule in the core
#20477
Author: netdev-bot+sashiko
Date: Sun, 22 Nov 2026 17:03
203 lines
15668 bytes
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

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

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] A failed XDP attach now permanently turns LRO off on the
  lowers of an upper device such as a bond.
- [Low] The netvsc documentation still tells users to disable LRO by hand
  before attaching XDP: "XDP program cannot run with LRO (RSC) enabled,…
- [Low] The atlantic driver still encodes the old rule that LRO conflicts
  only with single-buffer XDP.
- [Low] The comment above the XDP feature clearing in
  __netdev_update_features() (net/core/dev.c:11439-11441) still covers…

--

net: state the "XDP excludes LRO" rule in the core

This commit adds NETIF_F_XDP_DISABLES (GRO_HW | LRO). With it, the core
clears LRO next to HW-GRO when an XDP program is attached, and refuses the
attach if the driver keeps LRO on. It also drops netif_disable_lro() from
generic_xdp_install(), so LRO comes back on the device after detach.

> diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h
> index 8eb6b80336065..62a05df8ee686 100644
> --- a/include/linux/netdev_features.h
> +++ b/include/linux/netdev_features.h
> @@ -234,6 +234,12 @@ static inline int find_next_netdev_feature(u64 feature, unsigned long start)
>   */
>  #define NETIF_F_UPPER_DISABLES	NETIF_F_LRO
>  
> +/*
> + * Receive offloads which coalesce frames. XDP has to see the frames as the
> + * wire delivered them, so these are disabled while a program is attached.
> + */
> +#define NETIF_F_XDP_DISABLES	(NETIF_F_GRO_HW | NETIF_F_LRO)

[Severity: Low]
The commit message says atlantic now loses LRO under multi-buffer programs
too. Should the atlantic driver be updated to match? It still has the
single-buffer-only rule:

drivers/net/ethernet/aquantia/atlantic/aq_main.c:aq_ndev_fix_features() {
    ...
	prog = READ_ONCE(aq_nic->xdp_prog);
	if (prog && !prog->aux->xdp_has_frags &&
	    aq_nic->xdp_prog && features & NETIF_F_LRO) {
		netdev_err(ndev, "LRO is not supported with single buffer XDP, disabling\n");
		features &= ~NETIF_F_LRO;
	}
    ...
}

__netdev_update_features() now removes LRO before ndo_fix_features()
whenever dev_xdp_prog_count() is non-zero. That makes this branch dead.

aq_xdp_setup() also still writes ndev->features directly:

		if (prog && ndev->features & NETIF_F_LRO) {
			netdev_err(ndev,
				   "LRO is not supported with single buffer XDP, disabling\n");
			ndev->features &= ~NETIF_F_LRO;
		}

This check can no longer be true, because the core cleared LRO with
xdp_pending set before ndo_bpf runs.

Later patches in the series remove similar handling from mlx5, bnxt, qede
and gve. Nothing in the series touches drivers/net/ethernet/aquantia/.

[Severity: Low]
Documentation/networking/device_drivers/ethernet/microsoft/netvsc.rst
still says:

  XDP program cannot run with LRO (RSC) enabled, so you need to disable LRO
  before running XDP::

	ethtool -K eth0 lro off

Should this text be updated? netvsc puts NETIF_F_LRO in hw_features when
the host supports RSC. So dev_xdp_clear_rx_agg() now clears LRO before
netvsc_bpf()->netvsc_xdp_set() runs. The "XDP: not support LRO" refusal in
netvsc_xdp_set() can no longer be reached from the core attach paths.

The document also doesn't say that LRO now comes back when the program is
detached.

> +
>  /* changeable features with no special hardware requirements */
>  #define NETIF_F_SOFT_FEATURES	(NETIF_F_GSO | NETIF_F_GRO)
>  
> diff --git a/net/core/dev.c b/net/core/dev.c
> index c0bb5eb9fdea0..2b9c7aac09693 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c

[ ... ]

> @@ -10594,26 +10593,35 @@ static void dev_xdp_set_prog(struct net_device *dev, enum bpf_xdp_mode mode,

[ ... ]

>  static int dev_xdp_clear_rx_agg(struct net_device *dev,
>  				struct netlink_ext_ack *extack)
>  {
> -	if (!(dev->features & NETIF_F_GRO_HW))
> +	netdev_features_t agg = dev->features & NETIF_F_XDP_DISABLES;
> +
> +	if (!agg)
>  		return 0;
> -	if (!(dev->hw_features & NETIF_F_GRO_HW)) {
> -		NL_SET_ERR_MSG(extack,
> -			       "unable to disable HW-GRO, fixed on");
> +	if (agg & ~dev->hw_features) {
> +		NL_SET_ERR_MSG_FMT(extack, "unable to disable %s, fixed on",
> +				   dev_xdp_rx_agg_name(agg & ~dev->hw_features));
>  		return -EOPNOTSUPP;
>  	}
>  
>  	netdev_update_features(dev);

[Severity: Medium]
Now that LRO is in NETIF_F_XDP_DISABLES, can a rejected XDP attach leave
LRO off for good on the lowers of an upper device such as a bond?

dev_xdp_attach() sets xdp_pending and calls dev_xdp_clear_rx_agg() before
anything has had a chance to reject the program. Two sets of checks run
after it:

  - the checks in dev_xdp_install(): BPF_XDP_DEVMAP/CPUMAP attach type,
    device-bound mismatch, tcp-data-split, memory provider
  - the driver's ndo_bpf

A bond has LRO in hw_features and in features by default. LRO is also in
NETIF_F_UPPER_DISABLES. So this netdev_update_features() call reaches the
following for every slave:

__netdev_update_features(bond)
  netdev_sync_lower_features(bond, slave, features)
    lower->wanted_features &= ~feature;
    __netdev_update_features(lower);

bond_xdp_set() can then reject the program. One example:

	if (!bond_xdp_check(bond, BOND_MODE(bond))) {
		BOND_NL_ERR(dev, extack,
			    "No native XDP support for the current bonding mode");
		return -EOPNOTSUPP;
	}

Another is the "Slave device does not support XDP" error. In both cases
dev_xdp_attach() only does this:

err_clear_pending:
	dev->xdp_pending = 0;
	netdev_update_features(dev);

The bond gets LRO back from its own wanted_features. Nothing in net/core,
bonding or team puts LRO back into the slaves' wanted_features, and each
slave has already gone through an ndo_set_features() reconfiguration.

netif_xdp_propagate() clears and rolls back the same way when the lower
has lowers of its own.

Before this patch, GRO_HW was not in NETIF_F_UPPER_DISABLES.
netif_disable_lro() only ran from generic_xdp_install(), after all of the
dev_xdp_install() checks had passed.

The commit message covers slaves losing LRO after a successful attach and
detach, but not after a failed attach. Should that case be mentioned too,
or could clearing LRO on the lowers wait until the attach is known to
succeed?

[ ... ]

> @@ -11431,9 +11439,9 @@ int __netdev_update_features(struct net_device *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 ((features & NETIF_F_XDP_DISABLES) && dev_xdp_prog_count(dev)) {
> +		netdev_dbg(dev, "Dropping HW-GRO and LRO features since XDP is attached.\n");
> +		features &= ~NETIF_F_XDP_DISABLES;
>  	}

[Severity: Low]
This isn't a bug, but the comment above still only mentions GRO_HW. The
code under it now clears all of NETIF_F_XDP_DISABLES (GRO_HW and LRO).
This patch updated the matching comments in dev_xdp_clear_rx_agg(),
netif_xdp_propagate() and dev_xdp_attach(). Should this one be updated as
well?

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