From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
andrew+netdev@lunn.ch, horms@kernel.org, jv@jvosburgh.net,
haiyangz@microsoft.com, ast@kernel.org, hawk@kernel.org,
john.fastabend@gmail.com, sdf@fomichev.me, bpf@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org,
Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next 1/5] net: don't safety-check device features for XDP uninstall
Date: Thu, 12 Nov 2026 15:50:23 -0800 [thread overview]
Message-ID: <20261112235027.4072149-2-kuba@kernel.org> (raw)
In-Reply-To: <20261112235027.4072149-1-kuba@kernel.org>
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
next prev parent reply other threads:[~2026-11-12 23:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 23:50 [PATCH net-next 0/5] net: make xdp config checks effective vs netif_xdp_propagate() Jakub Kicinski
2026-11-12 23:50 ` Jakub Kicinski [this message]
2026-11-12 23:50 ` [PATCH net-next 2/5] net: move dev_xdp_set_link() and dev_xdp_set_prog() up Jakub Kicinski
2026-11-12 23:50 ` [PATCH net-next 3/5] net: record XDP programs propagated to lower devices Jakub Kicinski
2026-11-12 23:50 ` [PATCH net-next 4/5] selftests/bpf: check XDP attach on a nested bond slave Jakub Kicinski
2026-11-12 23:50 ` [PATCH net-next 5/5] selftests/bpf: check replacing and detaching XDP on a bond through a link Jakub Kicinski
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=20261112235027.4072149-2-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=haiyangz@microsoft.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=jv@jvosburgh.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
/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