Thread View: linux.kernel.netdev
3 messages
3 total messages
Started by Jakub Kicinski
Thu, 12 Nov 2026 23:50
[PATCH net-next 3/5] net: record XDP programs propagated to lower devices
Author: Jakub Kicinski
Date: Thu, 12 Nov 2026 23:50
Date: Thu, 12 Nov 2026 23:50
261 lines
18760 bytes
18760 bytes
An upper device installs its XDP program on each lower with
dev_xdp_propagate(), which calls ndo_bpf() directly and records nothing
in the lower's xdp_state[]. netif_xdp_propagate() open-codes two of the
checks dev_xdp_install() makes, but the lower still looks program-free
to everything else, so the checks made in the opposite direction miss it
entirely:
ethtool -G $slave tcp-data-split on
is refused by dev_xdp_sb_prog_count() for a device running a
single-buffer XDP program, but not for a bond slave running the bond's,
even though netif_xdp_propagate() would have refused to install that
same program had header-data split been on already. Binding a memory
provider has the same asymmetry. The lower does not report the program
over rtnetlink either, so it is invisible to userspace as well.
Install it into xdp_state[] like any other program and mark it with
xdp_from_upper, rather than tracking it separately. Every other user of
dev_xdp_prog_count() and dev_xdp_sb_prog_count() then gets the right
answer with no changes. The flag is only needed where the owner matters:
bonding and netvsc read it to tell a lower's own program apart from the
one they pushed down, to refuse taking over such a device, and to let
their own program be replaced and taken back, and dev_xdp_attach() reads
it to keep the program from being replaced or removed behind the upper's
back.
The lower now holds its own reference and its own registration with the
XDP dispatcher, as it does for a program of its own, so that tearing it
down through dev_xdp_uninstall() when the lower goes away first stays
balanced. The upper's per-lower reference for the driver is unchanged.
An upper is expected to propagate NULL before it unlinks, but the lower
may refuse it - bonding and netvsc then only warn, and the program keeps
running. So when the master unlinks, let the device own whatever is left
rather than leave it with nobody allowed to remove it.
While here, refuse to propagate onto a device which has a program of its
own, the counterpart of the new check in dev_xdp_attach(). Bonding and
netvsc already check for this before taking a device over and before
installing.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
v2:
- register the lower's program with the XDP dispatcher as well, so
that dev_xdp_uninstall() of the lower stays balanced
- let the device own a program left behind when its master unlinks
- refuse removing the device's own program too, not only replacing it
- assert the lower's ops lock in netif_xdp_propagate()
- convert netvsc's checks of its VF to dev_xdp_has_own_prog()
- split out moving dev_xdp_set_link() and dev_xdp_set_prog() up
v1: https://lore.kernel.org/20260928223648.2739371-2-kuba@kernel.org
---
.../networking/net_cachelines/net_device.rst | 1 +
include/linux/netdevice.h | 7 +++
drivers/net/bonding/bond_main.c | 4 +-
drivers/net/hyperv/netvsc_bpf.c | 2 +-
drivers/net/hyperv/netvsc_drv.c | 5 +-
net/core/dev.c | 49 ++++++++++++++++++-
6 files changed, 62 insertions(+), 6 deletions(-)
diff --git a/Documentation/networking/net_cachelines/net_device.rst b/Documentation/networking/net_cachelines/net_device.rst
index 8eceaa80b686..7620d3fcb8dc 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_from_upper
struct list_head net_notifier_list
struct macsec_ops* macsec_ops
struct udp_tunnel_nic_info* udp_tunnel_nic_info
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index f18bafb4efe2..670fe869a875 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_from_upper: the program in @xdp_state was installed by an
+ * upper device with netif_xdp_propagate(); it belongs to the
+ * upper and can't be replaced or removed through this device.
+ */
+ unsigned long xdp_from_upper:1;
struct list_head net_notifier_list;
@@ -4445,6 +4451,7 @@ struct sk_buff *dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
int bpf_xdp_link_attach(const union bpf_attr *attr, struct bpf_prog *prog);
u8 dev_xdp_prog_count(struct net_device *dev);
+bool dev_xdp_has_own_prog(struct net_device *dev);
int netif_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf);
int dev_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf);
u8 dev_xdp_sb_prog_count(struct net_device *dev);
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 9249a79a168e..167503d1fd15 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2327,7 +2327,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
.extack = extack,
};
- if (dev_xdp_prog_count(slave_dev) > 0) {
+ if (dev_xdp_has_own_prog(slave_dev)) {
SLAVE_NL_ERR(bond_dev, slave_dev, extack,
"Slave has XDP program loaded, please unload before enslaving");
res = -EOPNOTSUPP;
@@ -5736,7 +5736,7 @@ static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog,
goto err;
}
- if (dev_xdp_prog_count(slave_dev) > 0) {
+ if (dev_xdp_has_own_prog(slave_dev)) {
SLAVE_NL_ERR(dev, slave_dev, extack,
"Slave has XDP program loaded, please unload before enslaving");
err = -EOPNOTSUPP;
diff --git a/drivers/net/hyperv/netvsc_bpf.c b/drivers/net/hyperv/netvsc_bpf.c
index 14bb520b44ed..fa6be9c71c81 100644
--- a/drivers/net/hyperv/netvsc_bpf.c
+++ b/drivers/net/hyperv/netvsc_bpf.c
@@ -228,7 +228,7 @@ int netvsc_bpf(struct net_device *dev, struct netdev_bpf *bpf)
/* The VF's own program is not ours: refuse to install over
* it, as bonding does, and leave it be on removal.
*/
- if (vf_netdev && dev_xdp_prog_count(vf_netdev)) {
+ if (vf_netdev && dev_xdp_has_own_prog(vf_netdev)) {
if (bpf->prog) {
NL_SET_ERR_MSG_MOD(extack,
"VF has an XDP program of its own");
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 61109ff9927f..6fb5c21b88dc 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -2332,7 +2332,7 @@ static int netvsc_register_vf(struct net_device *vf_netdev, int context)
return NOTIFY_DONE;
prog = netvsc_xdp_get(netvsc_dev);
- if (prog && dev_xdp_prog_count(vf_netdev)) {
+ if (prog && dev_xdp_has_own_prog(vf_netdev)) {
netdev_warn(ndev, "not using VF %s, it has an XDP program attached\n",
vf_netdev->name);
return NOTIFY_DONE;
@@ -2485,7 +2485,8 @@ static int netvsc_unregister_vf(struct net_device *vf_netdev)
* reach netvsc, but leave a program of the VF's own be.
*/
nvdev = rtnl_dereference(net_device_ctx->nvdev);
- if (nvdev && netvsc_xdp_get(nvdev) && !dev_xdp_prog_count(vf_netdev)) {
+ if (nvdev && netvsc_xdp_get(nvdev) &&
+ !dev_xdp_has_own_prog(vf_netdev)) {
netdev_lock_ops(vf_netdev);
ret = netvsc_vf_setxdp(vf_netdev, NULL);
netdev_unlock_ops(vf_netdev);
diff --git a/net/core/dev.c b/net/core/dev.c
index 69ee4342f43e..3a520c798d4a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -9326,6 +9326,9 @@ static void __netdev_upper_dev_unlink(struct net_device *dev,
__netdev_adjacent_dev_unlink_neighbour(dev, upper_dev);
+ if (changeupper_info.master)
+ dev->xdp_from_upper = 0;
+
call_netdevice_notifiers_info(NETDEV_CHANGEUPPER,
&changeupper_info.info);
@@ -10561,6 +10564,15 @@ u8 dev_xdp_prog_count(struct net_device *dev)
}
EXPORT_SYMBOL_GPL(dev_xdp_prog_count);
+/* Does the device have an XDP program, and was it installed directly on the
+ * device rather than propagated down by an upper with netif_xdp_propagate()?
+ */
+bool dev_xdp_has_own_prog(struct net_device *dev)
+{
+ return dev_xdp_prog_count(dev) && !dev->xdp_from_upper;
+}
+EXPORT_SYMBOL_GPL(dev_xdp_has_own_prog);
+
u8 dev_xdp_sb_prog_count(struct net_device *dev)
{
struct bpf_prog *prog;
@@ -10591,6 +10603,11 @@ static void dev_xdp_set_prog(struct net_device *dev, enum bpf_xdp_mode mode,
int netif_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf)
{
+ struct bpf_prog *old_prog;
+ int err;
+
+ netdev_assert_locked_ops_compat(dev);
+
if (!dev->netdev_ops->ndo_bpf)
return -EOPNOTSUPP;
@@ -10598,6 +10615,12 @@ int netif_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf)
if (bpf->command != XDP_SETUP_PROG)
return dev->netdev_ops->ndo_bpf(dev, bpf);
+ if (dev_xdp_has_own_prog(dev)) {
+ NL_SET_ERR_MSG(bpf->extack,
+ "unable to propagate XDP to device with an XDP program of its own");
+ return -EBUSY;
+ }
+
if (bpf->prog) {
if (dev->cfg->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED &&
!bpf->prog->aux->xdp_has_frags) {
@@ -10613,7 +10636,26 @@ int netif_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf)
}
}
- return dev->netdev_ops->ndo_bpf(dev, bpf);
+ err = dev->netdev_ops->ndo_bpf(dev, bpf);
+ if (err)
+ return err;
+ if (bpf->prog)
+ bpf_prog_inc(bpf->prog);
+
+ /* Record it like a program of our own, so that everything which asks
+ * whether XDP is running here gets the right answer. @xdp_from_upper
+ * keeps the two apart where it matters. Register it with the
+ * dispatcher too, dev_xdp_uninstall() will drop it from there if this
+ * device goes away first.
+ */
+ 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_from_upper = !!bpf->prog;
+ if (old_prog)
+ bpf_prog_put(old_prog);
+
+ return 0;
}
EXPORT_SYMBOL_GPL(netif_xdp_propagate);
@@ -10731,6 +10773,7 @@ static void dev_xdp_uninstall(struct net_device *dev)
dev_xdp_set_link(dev, mode, NULL);
}
+ dev->xdp_from_upper = 0;
}
static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extack,
@@ -10773,6 +10816,10 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extack
}
mode = dev_xdp_mode(dev, flags);
+ if (dev->xdp_from_upper) {
+ NL_SET_ERR_MSG(extack, "Can't replace an XDP program installed by an upper device");
+ return -EBUSY;
+ }
/* can't replace attached link */
if (dev_xdp_link(dev, mode)) {
NL_SET_ERR_MSG(extack, "Can't replace active BPF XDP link");
--
2.56.0
Re: [PATCH net-next 3/5] net: record XDP programs propagated to lower devices
Author: netdev-bot+sashiko
Date: Fri, 13 Nov 2026 23:53
Date: Fri, 13 Nov 2026 23:53
185 lines
15406 bytes
15406 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] netvsc_register_vf() (drivers/net/hyperv/netvsc_drv.c) calls
netvsc_vf_setxdp(vf_netdev, prog) before netvsc_vf_join() has created…
- [Low] The commit fixes a user-visible bug but has no Fixes: tag.
- [Low] dev_xdp_attach() in net/core/dev.c now checks dev->xdp_from_upper
before the existing 'don't allow if an upper device already has a…
- [Low] The comment on dev_xdp_has_own_prog() in net/core/dev.c says it
answers 'was it installed directly on the device rather than…
--
net: record XDP programs propagated to lower devices
This commit records XDP programs that an upper device propagates to its
lowers in the lower's xdp_state[], and marks them with a new
xdp_from_upper flag. It adds dev_xdp_has_own_prog() so bonding and netvsc
can tell a lower's own program apart from theirs, and refuses attach on a
lower while the flag is set. The flag is cleared when the master unlinks.
> ethtool -G $slave tcp-data-split on
>
> is refused by dev_xdp_sb_prog_count() for a device running a
> single-buffer XDP program, but not for a bond slave running the bond's,
> even though netif_xdp_propagate() would have refused to install that
> same program had header-data split been on already. Binding a memory
> provider has the same asymmetry.
[Severity: Low]
This describes a user-visible bug, but there is no Fixes: tag. The
install-direction checks in netif_xdp_propagate() came from these
commits, and neither of them covered the reverse direction:
2d46e481a9af ("net: disallow setup single buffer XDP when tcp-data-split is enabled.")
170aafe35cb9 ("netdev: support binding dma-buf to netdevice")
Should the commit carry Fixes: tags for them?
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 69ee4342f43ee..3a520c798d4a8 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -9326,6 +9326,9 @@ static void __netdev_upper_dev_unlink(struct net_device *dev,
>
> __netdev_adjacent_dev_unlink_neighbour(dev, upper_dev);
>
> + if (changeupper_info.master)
> + dev->xdp_from_upper = 0;
> +
> call_netdevice_notifiers_info(NETDEV_CHANGEUPPER,
> &changeupper_info.info);
>
[Severity: Medium]
The commit message says that clearing the flag here lets the device own a
leftover program "rather than leave it with nobody allowed to remove it".
Can a lower end up with xdp_from_upper set when no master link was ever
created, so that this code never runs?
netvsc_register_vf() propagates netvsc's program before it joins:
ret = netvsc_vf_setxdp(vf_netdev, prog);
...
if (netvsc_vf_join(vf_netdev, ndev, context) != 0) {
ret = prog ? netvsc_vf_setxdp(vf_netdev, NULL) : 0;
if (ret)
netdev_warn(ndev,
"failed to remove XDP program from VF %s: %d\n",
vf_netdev->name, ret);
return NOTIFY_DONE;
}
The first call stores the program in vf_netdev->xdp_state[XDP_MODE_DRV]
and sets xdp_from_upper. netvsc_vf_join() can fail in
netdev_rx_handler_register() or in netdev_master_upper_dev_link(). Both
failure paths return without a master link.
If the driver's ndo_bpf() then refuses the NULL program,
netif_xdp_propagate() returns before it touches xdp_state[] or the flag:
err = dev->netdev_ops->ndo_bpf(dev, bpf);
if (err)
return err;
netvsc returns NOTIFY_DONE without storing the VF in
net_device_ctx->vf_netdev, so it never comes back to this VF. No master
was linked, so __netdev_upper_dev_unlink() never clears the flag. Only
dev_xdp_uninstall() at unregister does.
>From then on, every IFLA_XDP set or remove and every BPF link attach on
the VF hits the new -EBUSY check in dev_xdp_attach(). netvsc's program
keeps running on the VF. Before this patch xdp_state[] was empty in this
case, so the user could attach a program and then detach it to clear
things up.
The only way out seems to be linking the VF to some master and then
unlinking it. Should the failed-join path, or netif_xdp_propagate(),
handle this case?
bond_xdp_set() has a smaller version of the same problem. If the unwind
call fails:
err_unwind = dev_xdp_propagate(slave_dev, &xdp);
the slave keeps the new program with xdp_from_upper set, while
bond->xdp_prog has been reset to old_prog. That slave can't be fixed
directly until it is released from the bond.
> @@ -10561,6 +10564,15 @@ u8 dev_xdp_prog_count(struct net_device *dev)
> }
> EXPORT_SYMBOL_GPL(dev_xdp_prog_count);
>
> +/* Does the device have an XDP program, and was it installed directly on the
> + * device rather than propagated down by an upper with netif_xdp_propagate()?
> + */
> +bool dev_xdp_has_own_prog(struct net_device *dev)
> +{
> + return dev_xdp_prog_count(dev) && !dev->xdp_from_upper;
> +}
> +EXPORT_SYMBOL_GPL(dev_xdp_has_own_prog);
[Severity: Low]
This isn't a bug, but does this comment still match what the function
returns? It describes where the program came from. The new kernel-doc in
include/linux/netdevice.h does too:
@xdp_from_upper: the program in @xdp_state was installed by an
upper device with netif_xdp_propagate(); it belongs to the
upper and can't be replaced or removed through this device.
__netdev_upper_dev_unlink() clears xdp_from_upper on any master unlink.
That includes the case where the upper's NULL propagate failed and
bonding or netvsc only warned. After that, dev_xdp_has_own_prog() returns
true for a program that an upper propagated.
Could both comments describe the flag as current ownership, including the
hand-over on master unlink?
[ ... ]
> @@ -10773,6 +10816,10 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extack
> }
>
> mode = dev_xdp_mode(dev, flags);
> + if (dev->xdp_from_upper) {
> + NL_SET_ERR_MSG(extack, "Can't replace an XDP program installed by an upper device");
> + return -EBUSY;
> + }
[Severity: Low]
This check now runs before the existing loop that refuses an attach when
an upper has a program:
netdev_for_each_upper_dev_rcu(dev, upper, iter) {
if (dev_xdp_prog_count(upper) > 0) {
NL_SET_ERR_MSG(extack, "Cannot attach when an upper device already has a program");
return -EEXIST;
}
}
For a direct bond slave or a joined netvsc VF, the upper keeps its
program in its own xdp_state[]. Attach, replace and detach on the lower
were therefore already refused, with -EEXIST. They now fail with -EBUSY
and a different extack message.
The commit message says dev_xdp_attach() reads the flag "to keep the
program from being replaced or removed behind the upper's back". However,
that protection is only new for nested lowers and for the netvsc window
before the join.
Is the errno and message change for the common direct-lower case
intended? If so, could the commit message mention it?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112235027.4072149-1-kuba%40kernel.org
Re: [PATCH net-next 3/5] net: record XDP programs propagated to lower devices
Author: Jakub Kicinski
Date: Sat, 14 Nov 2026 00:16
Date: Sat, 14 Nov 2026 00:16
147 lines
13989 bytes
13989 bytes
On Fri, 13 Nov 2026 23:53:16 +0000 netdev-bot+sashiko@kernel.org wrote:
> > diff --git a/net/core/dev.c b/net/core/dev.c
> > index 69ee4342f43ee..3a520c798d4a8 100644
> > --- a/net/core/dev.c
> > +++ b/net/core/dev.c
> > @@ -9326,6 +9326,9 @@ static void __netdev_upper_dev_unlink(struct net_device *dev,
> >
> > __netdev_adjacent_dev_unlink_neighbour(dev, upper_dev);
> >
> > + if (changeupper_info.master)
> > + dev->xdp_from_upper = 0;
> > +
> > call_netdevice_notifiers_info(NETDEV_CHANGEUPPER,
> > &changeupper_info.info);
> >
>
> [Severity: Medium]
> The commit message says that clearing the flag here lets the device own a
> leftover program "rather than leave it with nobody allowed to remove it".
> Can a lower end up with xdp_from_upper set when no master link was ever
> created, so that this code never runs?
>
> netvsc_register_vf() propagates netvsc's program before it joins:
>
> ret = netvsc_vf_setxdp(vf_netdev, prog);
> ...
> if (netvsc_vf_join(vf_netdev, ndev, context) != 0) {
> ret = prog ? netvsc_vf_setxdp(vf_netdev, NULL) : 0;
> if (ret)
> netdev_warn(ndev,
> "failed to remove XDP program from VF %s: %d\n",
> vf_netdev->name, ret);
> return NOTIFY_DONE;
> }
>
> The first call stores the program in vf_netdev->xdp_state[XDP_MODE_DRV]
> and sets xdp_from_upper. netvsc_vf_join() can fail in
> netdev_rx_handler_register() or in netdev_master_upper_dev_link(). Both
> failure paths return without a master link.
>
> If the driver's ndo_bpf() then refuses the NULL program,
> netif_xdp_propagate() returns before it touches xdp_state[] or the flag:
>
> err = dev->netdev_ops->ndo_bpf(dev, bpf);
> if (err)
> return err;
>
> netvsc returns NOTIFY_DONE without storing the VF in
> net_device_ctx->vf_netdev, so it never comes back to this VF. No master
> was linked, so __netdev_upper_dev_unlink() never clears the flag. Only
> dev_xdp_uninstall() at unregister does.
>
> From then on, every IFLA_XDP set or remove and every BPF link attach on
> the VF hits the new -EBUSY check in dev_xdp_attach(). netvsc's program
> keeps running on the VF. Before this patch xdp_state[] was empty in this
> case, so the user could attach a program and then detach it to clear
> things up.
>
> The only way out seems to be linking the VF to some master and then
> unlinking it. Should the failed-join path, or netif_xdp_propagate(),
> handle this case?
>
> bond_xdp_set() has a smaller version of the same problem. If the unwind
> call fails:
>
> err_unwind = dev_xdp_propagate(slave_dev, &xdp);
>
> the slave keeps the new program with xdp_from_upper set, while
> bond->xdp_prog has been reset to old_prog. That slave can't be fixed
> directly until it is released from the bond.
I guess AI semi-randomly anchored this comment here, it's basically
saying that since netvsc is buggy the state may get out of sync.
Yes, as mentioned in the netvsc series I didn't manage to cover all
the error paths there. And also that's the reason why I added the
clearing of "from upper" on unlink, to make the bad state recoverable.
IOW patch is working as intended. We're going from "no safety checks"
to "some already buggy driver error path may fail to clean up".
> > @@ -10561,6 +10564,15 @@ u8 dev_xdp_prog_count(struct net_device *dev)
> > }
> > EXPORT_SYMBOL_GPL(dev_xdp_prog_count);
> >
> > +/* Does the device have an XDP program, and was it installed directly on the
> > + * device rather than propagated down by an upper with netif_xdp_propagate()?
> > + */
> > +bool dev_xdp_has_own_prog(struct net_device *dev)
> > +{
> > + return dev_xdp_prog_count(dev) && !dev->xdp_from_upper;
> > +}
> > +EXPORT_SYMBOL_GPL(dev_xdp_has_own_prog);
>
> [Severity: Low]
> This isn't a bug, but does this comment still match what the function
> returns? It describes where the program came from. The new kernel-doc in
> include/linux/netdevice.h does too:
>
> @xdp_from_upper: the program in @xdp_state was installed by an
> upper device with netif_xdp_propagate(); it belongs to the
> upper and can't be replaced or removed through this device.
>
> __netdev_upper_dev_unlink() clears xdp_from_upper on any master unlink.
> That includes the case where the upper's NULL propagate failed and
> bonding or netvsc only warned. After that, dev_xdp_has_own_prog() returns
> true for a program that an upper propagated.
>
> Could both comments describe the flag as current ownership, including the
> hand-over on master unlink?
No, it's a failure mode / de-sync case. We shouldn't document it.
> > @@ -10773,6 +10816,10 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extack
> > }
> >
> > mode = dev_xdp_mode(dev, flags);
> > + if (dev->xdp_from_upper) {
> > + NL_SET_ERR_MSG(extack, "Can't replace an XDP program installed by an upper device");
> > + return -EBUSY;
> > + }
>
> [Severity: Low]
> This check now runs before the existing loop that refuses an attach when
> an upper has a program:
>
> netdev_for_each_upper_dev_rcu(dev, upper, iter) {
> if (dev_xdp_prog_count(upper) > 0) {
> NL_SET_ERR_MSG(extack, "Cannot attach when an upper device already has a program");
> return -EEXIST;
> }
> }
>
> For a direct bond slave or a joined netvsc VF, the upper keeps its
> program in its own xdp_state[]. Attach, replace and detach on the lower
> were therefore already refused, with -EEXIST. They now fail with -EBUSY
> and a different extack message.
>
> The commit message says dev_xdp_attach() reads the flag "to keep the
> program from being replaced or removed behind the upper's back". However,
> that protection is only new for nested lowers and for the netvsc window
> before the join.
>
> Is the errno and message change for the common direct-lower case
> intended? If so, could the commit message mention it?
Intended / doesn't matter.
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