Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Hangbin Liu
Wed, 02 Dec 2026 01:54
[PATCH net-next v2] bonding: restore slave addresses and flags when XDP setup fails
Author: Hangbin Liu
Date: Wed, 02 Dec 2026 01:54
Date: Wed, 02 Dec 2026 01:54
86 lines
11808 bytes
11808 bytes
From: Hangbin Liu <liuhangbin@kylinos.cn>
If XDP setup fails in bond_enslave() and we jump to err_dec_slave_cnt,
the function has already incremented the slave's promiscuity and allmulti
refcounts, synced bond addresses to the slave, and added the slave’s
ns multicast addresses via bond_slave_ns_maddrs_add(). None of the
existing error paths roll back these operations. As a result, a failed
enslavement leaves the slave with stale promisc/allmulti refcounts,
stale synced addresses and ns multicast addresses.
Add the missing rollback steps at err_dec_slave_cnt.
Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
For Sashiko:
1. Please ignore the potential `ndo_xdp_xmit` NULL pointer issue in
`bond_xdp_xmit()`. It will be addressed in a separate patch.
2. Please ignore the missing cleanup and 3AD unbind on XDP error in
`bond_enslave()`. This will also be fixed in another patch.
3. Please ignore this corner case: when a bond slave has a VLAN upper that
joined a multicast group also carried by the bond, subsequent
`dev_mc_unsync()` removes the VLAN’s filter from the slave. This is an
existing issue and should be fixed separately in `dev_addr_lists.c`.
Target this series to net-next, as these issues have existed for a long
time. They are not critical and haven't been reported by anyone before.
The issue is found when sashiko review my other patch. It could be
reproduced with
ip link add bond0 type bond mode balance-rr
ip link set bond0 xdpdrv obj xdp_dummy.bpf.o sec xdp
ip link set bond0 promisc on
ip link set dummy0 master bond0 # Error: Slave does not support XDP.
ip -d link show dummy0 # promiscuity 1
ip link add type veth
ip link set veth1 up
ip link add br0 type bridge
ip link add bond1 type bond mode active-backup arp_interval 100 arp_validate 1 ns_ip6_target 2001::254
ip link set bond1 xdpdrv obj xdp_dummy.bpf.o sec xdp
ip link set veth0 master bond1
ip link set br0 master bond1 # Error: Slave does not support XDP.
ip maddr show br0 # link 33:33:ff:00:02:54
After the patch, the promiscuity on dummy0 is 0 and there is no extra
maddr on br0.
---
Changes in v2:
- Drop the bond_slave_ns_maddrs_del call in err_close.
- Link to v1: https://patch.msgid.link/20261125-bond_xdp_rollback-v1-1-35dddaa337ba@kylinos.cn
---
drivers/net/bonding/bond_main.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 754048ef4835..986d314b9573 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2369,7 +2369,16 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
/* Undo stages on error */
err_dec_slave_cnt:
+ bond_slave_ns_maddrs_del(bond, new_slave);
WRITE_ONCE(bond->slave_cnt, bond->slave_cnt - 1);
+ if (!bond_uses_primary(bond)) {
+ if (bond_dev->flags & IFF_PROMISC)
+ dev_set_promiscuity(slave_dev, -1);
+ if (bond_dev->flags & IFF_ALLMULTI)
+ dev_set_allmulti(slave_dev, -1);
+ if (bond_dev->flags & IFF_UP)
+ bond_hw_addr_flush(bond_dev, slave_dev);
+ }
err_sysfs_del:
bond_sysfs_slave_del(new_slave);
---
base-commit: 81159a672c331993566a12ad8e07532b38355cba
change-id: 20261124-bond_xdp_rollback-187c07d3125d
Best regards,
--
Hangbin Liu <liuhangbin@kylinos.cn>
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