Thread View: linux.kernel.netdev
3 messages
3 total messages
Started by Jakub Kicinski
Thu, 12 Nov 2026 23:50
[PATCH net-next 1/5] net: don't safety-check device features for XDP uninstall
Author: Jakub Kicinski
Date: Thu, 12 Nov 2026 23:50
Date: Thu, 12 Nov 2026 23:50
90 lines
10985 bytes
10985 bytes
Commit ad27ed7d2309 ("bpf, xdp: move offload check into dev_xdp_install()")
lifted the safety checks from dev_xdp_attach() to dev_xdp_install()
to cover more paths. Since all these checks are prog
related they are under one big "if (prog)".
Lift the pre-existing checks under "if (prog)" as well,
and do the same thing in netif_xdp_propagate().
This way we don't have to worry about triggering WARN()s
on cleanup paths mistakenly trying to un-install a program
when there is none, and failing because device has a memory
provider.
This is a refactoring / consistency cleanup, later patches
don't depend on this change.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
net/core/dev.c | 48 +++++++++++++++++++++++++++---------------------
1 file changed, 27 insertions(+), 21 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index a230ecce9327..a5120da879d1 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -10580,17 +10580,23 @@ int netif_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf)
if (!dev->netdev_ops->ndo_bpf)
return -EOPNOTSUPP;
- if (dev->cfg->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED &&
- bpf->command == XDP_SETUP_PROG &&
- bpf->prog && !bpf->prog->aux->xdp_has_frags) {
- NL_SET_ERR_MSG(bpf->extack,
- "unable to propagate XDP to device using tcp-data-split");
- return -EBUSY;
- }
+ /* setup requires extra handling, bypass those for other commands */
+ if (bpf->command != XDP_SETUP_PROG)
+ return dev->netdev_ops->ndo_bpf(dev, bpf);
- if (dev_get_min_mp_channel_count(dev)) {
- NL_SET_ERR_MSG(bpf->extack, "unable to propagate XDP to device using memory provider");
- return -EBUSY;
+ if (bpf->prog) {
+ if (dev->cfg->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED &&
+ !bpf->prog->aux->xdp_has_frags) {
+ NL_SET_ERR_MSG(bpf->extack,
+ "unable to propagate XDP to device using tcp-data-split");
+ return -EBUSY;
+ }
+
+ if (dev_get_min_mp_channel_count(dev)) {
+ NL_SET_ERR_MSG(bpf->extack,
+ "unable to propagate XDP to device using memory provider");
+ return -EBUSY;
+ }
}
return dev->netdev_ops->ndo_bpf(dev, bpf);
@@ -10656,17 +10662,17 @@ static int dev_xdp_install(struct net_device *dev, enum bpf_xdp_mode mode,
NL_SET_ERR_MSG(extack, "BPF_XDP_CPUMAP programs can not be attached to a device");
return -EINVAL;
}
- }
-
- if (dev->cfg->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED &&
- prog && !prog->aux->xdp_has_frags) {
- NL_SET_ERR_MSG(extack, "unable to install XDP to device using tcp-data-split");
- return -EBUSY;
- }
-
- if (dev_get_min_mp_channel_count(dev)) {
- NL_SET_ERR_MSG(extack, "unable to install XDP to device using memory provider");
- return -EBUSY;
+ if (dev->cfg->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED &&
+ !prog->aux->xdp_has_frags) {
+ NL_SET_ERR_MSG(extack,
+ "unable to install XDP to device using tcp-data-split");
+ return -EBUSY;
+ }
+ if (dev_get_min_mp_channel_count(dev)) {
+ NL_SET_ERR_MSG(extack,
+ "unable to install XDP to device using memory provider");
+ return -EBUSY;
+ }
}
memset(&xdp, 0, sizeof(xdp));
--
2.56.0
Re: [PATCH net-next 1/5] net: don't safety-check device features for XDP uninstall
Author: netdev-bot+sashiko
Date: Fri, 13 Nov 2026 23:53
Date: Fri, 13 Nov 2026 23:53
82 lines
11122 bytes
11122 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message of "net: don't safety-check device features
for XDP uninstall" calls the change a "refactoring / consistency…
--
net: don't safety-check device features for XDP uninstall
This moves the tcp-data-split and memory provider checks in
dev_xdp_install() and netif_xdp_propagate() under "if (prog)", so they
only run when a program is being installed. netif_xdp_propagate() also
now hands commands other than XDP_SETUP_PROG straight to ndo_bpf.
> This way we don't have to worry about triggering WARN()s
> on cleanup paths mistakenly trying to un-install a program
> when there is none, and failing because device has a memory
> provider.
>
> This is a refactoring / consistency cleanup, later patches
> don't depend on this change.
[Severity: Low]
Is this really only a cleanup? It looks like it also fixes an XDP
uninstall failure that can be hit in the current tree.
Before this patch, netif_xdp_propagate() ran the memory provider check
unconditionally, so it also refused to propagate prog == NULL:
net/core/dev.c:netif_xdp_propagate() {
...
if (dev_get_min_mp_channel_count(dev)) {
NL_SET_ERR_MSG(bpf->extack, "unable to propagate XDP to device using memory provider");
return -EBUSY;
}
...
}
A lower device can run a program propagated from an upper device and
also have a memory provider bound. At this point in the tree,
netif_xdp_propagate() does not record the propagated program in the
lower device's xdp_state, so the reverse checks pass.
__netif_mp_open_rxq() only checks dev_xdp_prog_count(dev), and
ethnl_set_rings() only checks dev_xdp_sb_prog_count().
When a bond slave is in that state, removing XDP from the bond fails:
bond_xdp_set(bond_dev, NULL)
dev_xdp_propagate(slave_dev, &xdp) /* xdp.prog == NULL */
netif_xdp_propagate()
dev_get_min_mp_channel_count(dev) != 0 -> -EBUSY
bond_xdp_set() then rolls back, so XDP cannot be removed from the bond.
In __bond_release_one() the same failure only prints a warning:
if (dev_xdp_propagate(slave_dev, &xdp))
slave_warn(bond_dev, slave_dev, "failed to unload XDP program\n");
The released slave keeps running the bond's program, and nothing about
it is in the slave's xdp_state. The program then cannot be seen or
removed through that device. netvsc_vf_setxdp(vf, NULL) fails the same
way.
The check being relaxed here came from commit 170aafe35cb9 ("netdev:
support binding dma-buf to netdevice"), which is in current LTS trees.
Should this patch have a Fixes: tag for that commit? Could the commit
message also describe the uninstall failure, rather than calling the
change a refactoring?
A later patch in this series, "net: record XDP programs propagated to
lower devices", fixes the root cause (a memory provider coexisting with
a propagated program). That patch has no Fixes: tag either.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112235027.4072149-1-kuba%40kernel.org
Re: [PATCH net-next 1/5] net: don't safety-check device features for XDP uninstall
Author: Jakub Kicinski
Date: Sat, 14 Nov 2026 00:07
Date: Sat, 14 Nov 2026 00:07
12 lines
8502 bytes
8502 bytes
On Fri, 13 Nov 2026 23:53:14 +0000 netdev-bot+sashiko@kernel.org wrote: > Is this really only a cleanup? It looks like it also fixes an XDP > uninstall failure that can be hit in the current tree. TBH it's been a while since I wrote this commit so I could be misremembering, but IIRC what I mean to say in the commit msg is that I wrote the patch because the shape of the code was annoying me. There _may_ be some cases where we already got into bad state which this fixes. But fixing any specific case wasn't what made me write the patch. (And the whole XDP prog state got desynced area has too many bugs to claim this moves the needle).
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