[PATCH net-next 0/6] bonding: refactor bond_enslave() to fix XDP ordering and error rollback

From
Hangbin Liu <hidden>
Date
2026-11-13 14:04:35
Also in
bpf, lkml
`bond_enslave()` is over 500 lines long with complex logic and numerous
error rollback paths. It has XDP ordering isssue and missing some error
rollbacks for historical reasons (found by Sashiko when review bond
patches). The fixes are trivial, I plan to refactor the function to make
the logic clearer and resolved the issues. This patch set is the first
phase.

This series hardens bond_enslave() in two stages: first fix real
ordering and rollback bugs, then factor the function so the
infallible commit point and fail-fast validation stay obvious.

Problems fixed (patches 1-3):

1. XDP capability checks ran after the slave was opened, linked and
   could already be visible to the datapath . A slave without
   ndo_xdp_xmit could therefore be reached from bond_xdp_xmit().
   Checks move to the top of bond_enslave(), before any mutation.

2. Fallible XDP setup (dev_xdp_propagate()) ran after publication.
   On failure the undo ladder jumped to err_sysfs_del and leaked:
   - promiscuity / allmulti / synced addresses
   - ns maddrs added just before the failure

3. Error paths were incomplete versus release:
   - bond_alb_init_slave() success + later failure skipped
     bond_alb_deinit_slave() (TLB/RLB state, borrowed MAC)
   - bond_3ad_bind_slave() + later failure skipped
     bond_3ad_unbind_slave() (port left on its aggregator)
   - automatic fail_over_mac = "active" was not restored on failure

Cleanup (patches 4-6), no intended behaviour change beyond patch 5's
extack string alignment:

4. bond_publish_slave() — explicit infallible commit point
5. bond_slave_xdp_check() — shared by bond_enslave() and bond_xdp_set()
6. bond_enslave_validate() — all read-only checks

Testing: build debug kernel and run all kernel selftests

Signed-off-by: Hangbin Liu <redacted>
---
Hangbin Liu (6):
      bonding: check XDP support before enslaving changes state
      bonding: finish XDP setup before publishing the slave
      bonding: complete rollback of bond_enslave() error paths
      bonding: factor out slave publication
      bonding: factor out XDP slave check
      bonding: factor out bond_enslave_validate

 drivers/net/bonding/bond_main.c | 174 ++++++++++++++++++++++++++--------------
 1 file changed, 116 insertions(+), 58 deletions(-)
---
base-commit: 573af801552999954caa8347e4490b04cf4763f0
change-id: 20261020-bond_enslave_restruct-30760e62def9

Best regards,
--  
Hangbin Liu [off-list ref]
Thread (14 messages) 14 messages, 3 authors, last reply 15h ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help