Thread View: linux.kernel.netdev
5 messages
5 total messages
Started by Hangbin Liu
Fri, 13 Nov 2026 14:04
[PATCH net-next 0/6] bonding: refactor bond_enslave() to fix XDP ordering and error rollback
Author: Hangbin Liu
Date: Fri, 13 Nov 2026 14:04
Date: Fri, 13 Nov 2026 14:04
59 lines
10851 bytes
10851 bytes
`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 <liuhangbin@kylinos.cn>
---
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 <liuhangbin@kylinos.cn>
[PATCH net-next 2/6] bonding: finish XDP setup before publishing the slave
Author: Hangbin Liu
Date: Fri, 13 Nov 2026 14:04
Date: Fri, 13 Nov 2026 14:04
123 lines
12750 bytes
12750 bytes
From: Hangbin Liu <liuhangbin@kylinos.cn>
bond_enslave() currently runs the fallible XDP setup
(dev_xdp_propagate()) after the slave has already been published:
slave_cnt is incremented, ns maddrs are added and the active slave
may have been selected. If XDP setup then fails, the error path
jumps to err_sysfs_del and leaks:
- the promiscuity/allmulti increments and synced addresses applied
to the slave earlier in the function, which are only undone on
an immediate allmulti failure,
- the ns maddrs added just before the failure, which no enslave
error path ever removes.
Move dev_xdp_propagate() to the last fallible step, right after the
promiscuity/allmulti/address-sync block and before
WRITE_ONCE(bond->slave_cnt), so that no handled fallible call
follows the publication of the slave and a failure can no longer
leak slave_cnt or ns maddrs.
bond_xdp_set_features() is moved along with this reordering so XDP
features are updated before the slave is published. Route the XDP
failure through a new err_set_xdp label that undoes the promiscuity,
allmulti and address-sync state, mirroring what __bond_release_one()
does.
Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
drivers/net/bonding/bond_main.c | 52 +++++++++++++++++++++++++----------------
1 file changed, 32 insertions(+), 20 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 340af4c3fa20..80b6c18ee9c2 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2313,22 +2313,11 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
}
}
- WRITE_ONCE(bond->slave_cnt, bond->slave_cnt + 1);
- netdev_compute_master_upper_features(bond->dev, true);
- bond_set_carrier(bond);
-
- /* Needs to be called before bond_select_active_slave(), which will
- * remove the maddrs if the slave is selected as active slave.
+ /* XDP capability and prog-count were already validated above.
+ * Setup runs as the last fallible step before the slave is
+ * published, so no undo of this block can ever be needed and
+ * a failure here cannot leak slave_cnt or ns maddrs.
*/
- bond_slave_ns_maddrs_add(bond, new_slave);
-
- if (bond_uses_primary(bond)) {
- block_netpoll_tx();
- bond_select_active_slave(bond);
- unblock_netpoll_tx();
- }
-
- /* XDP capability and prog-count were already validated above */
if (bond->xdp_prog) {
struct netdev_bpf xdp = {
.command = XDP_SETUP_PROG,
@@ -2341,19 +2330,35 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
if (res < 0) {
/* ndo_bpf() sets extack error message */
slave_dbg(bond_dev, slave_dev, "Error %d calling ndo_bpf\n", res);
- goto err_dec_slave_cnt;
+ goto err_set_xdp;
}
if (bond->xdp_prog)
bpf_prog_inc(bond->xdp_prog);
}
+ bond_xdp_set_features(bond_dev);
+
+ /* Must called before bond_update_slave_arr() or bond_select_active_slave() */
+ WRITE_ONCE(bond->slave_cnt, bond->slave_cnt + 1);
+ netdev_compute_master_upper_features(bond->dev, true);
+ bond_set_carrier(bond);
+
+ /* Needs to be called before bond_select_active_slave(), which will
+ * remove the maddrs if the slave is selected as active slave.
+ */
+ bond_slave_ns_maddrs_add(bond, new_slave);
+
+ if (bond_uses_primary(bond)) {
+ block_netpoll_tx();
+ bond_select_active_slave(bond);
+ unblock_netpoll_tx();
+ }
+
/* broadcast mode uses the all_slaves to loop through slaves. */
if (bond_mode_can_use_xmit_hash(bond) ||
BOND_MODE(bond) == BOND_MODE_BROADCAST)
bond_update_slave_arr(bond, NULL);
- bond_xdp_set_features(bond_dev);
-
slave_info(bond_dev, slave_dev, "Enslaving as %s interface with %s link\n",
bond_is_active_slave(new_slave) ? "an active" : "a backup",
new_slave->link != BOND_LINK_DOWN ? "an up" : "a down");
@@ -2363,8 +2368,15 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
return 0;
/* Undo stages on error */
-err_dec_slave_cnt:
- WRITE_ONCE(bond->slave_cnt, bond->slave_cnt - 1);
+err_set_xdp:
+ 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);
--
2.56.0
[PATCH net-next 4/6] bonding: factor out slave publication
Author: Hangbin Liu
Date: Fri, 13 Nov 2026 14:04
Date: Fri, 13 Nov 2026 14:04
84 lines
11279 bytes
11279 bytes
From: Hangbin Liu <liuhangbin@kylinos.cn>
Factor the publication step of bond_enslave() into bond_publish_slave()
so the infallible "commit point" of the function is explicit and cannot
be interleaved with new fallible code by accident.
No functional change.
Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
drivers/net/bonding/bond_main.c | 49 ++++++++++++++++++++++++-----------------
1 file changed, 29 insertions(+), 20 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index f696a0d15034..bb3752683456 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1884,6 +1884,34 @@ void bond_xdp_set_features(struct net_device *bond_dev)
xdp_set_features_flag(bond_dev, val);
}
+/* Make the fully prepared slave visible to the rest of the bonding
+ * code. All fallible steps of bond_enslave() must have completed
+ * before this runs: error paths never undo the publication.
+ */
+static void bond_publish_slave(struct bonding *bond, struct slave *slave)
+{
+ /* Must called before bond_update_slave_arr() or bond_select_active_slave() */
+ WRITE_ONCE(bond->slave_cnt, bond->slave_cnt + 1);
+ netdev_compute_master_upper_features(bond->dev, true);
+ bond_set_carrier(bond);
+
+ /* Needs to be called before bond_select_active_slave(), which will
+ * remove the maddrs if the slave is selected as active slave.
+ */
+ bond_slave_ns_maddrs_add(bond, slave);
+
+ if (bond_uses_primary(bond)) {
+ block_netpoll_tx();
+ bond_select_active_slave(bond);
+ unblock_netpoll_tx();
+ }
+
+ /* broadcast mode uses the all_slaves to loop through slaves. */
+ if (bond_mode_can_use_xmit_hash(bond) ||
+ BOND_MODE(bond) == BOND_MODE_BROADCAST)
+ bond_update_slave_arr(bond, NULL);
+}
+
/* enslave device <slave> to bond device <master> */
int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
struct netlink_ext_ack *extack)
@@ -2341,26 +2369,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
bond_xdp_set_features(bond_dev);
- /* Must called before bond_update_slave_arr() or bond_select_active_slave() */
- WRITE_ONCE(bond->slave_cnt, bond->slave_cnt + 1);
- netdev_compute_master_upper_features(bond->dev, true);
- bond_set_carrier(bond);
-
- /* Needs to be called before bond_select_active_slave(), which will
- * remove the maddrs if the slave is selected as active slave.
- */
- bond_slave_ns_maddrs_add(bond, new_slave);
-
- if (bond_uses_primary(bond)) {
- block_netpoll_tx();
- bond_select_active_slave(bond);
- unblock_netpoll_tx();
- }
-
- /* broadcast mode uses the all_slaves to loop through slaves. */
- if (bond_mode_can_use_xmit_hash(bond) ||
- BOND_MODE(bond) == BOND_MODE_BROADCAST)
- bond_update_slave_arr(bond, NULL);
+ bond_publish_slave(bond, new_slave);
slave_info(bond_dev, slave_dev, "Enslaving as %s interface with %s link\n",
bond_is_active_slave(new_slave) ? "an active" : "a backup",
--
2.56.0
Re: [PATCH net-next 2/6] bonding: finish XDP setup before publishing the slave
Author: netdev-bot+sashiko
Date: Tue, 17 Nov 2026 14:40
Date: Tue, 17 Nov 2026 14:40
205 lines
15436 bytes
15436 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 1 · High: 0 · Medium: 0 · Low: 2
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).
- [Critical] Heap out-of-bounds write in bond_update_slave_arr(),
introduced by moving the XDP setup ahead of the slave_cnt increment.
- [Low] The commit fixes real, user-visible leaks on the bond_enslave()
XDP-failure path but has no Fixes: tag.
- [Low] The commit message describes a stale version of the error path.
--
bonding: finish XDP setup before publishing the slave
This patch moves dev_xdp_propagate() in bond_enslave() ahead of the
slave_cnt increment, the ns maddr setup and active slave selection, so the
XDP setup becomes the last fallible step. It also moves
bond_xdp_set_features() earlier. It replaces err_dec_slave_cnt with a new
err_set_xdp label that undoes the promiscuity, allmulti and address sync.
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 340af4c3fa201..80b6c18ee9c28 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -2313,22 +2313,11 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
> }
> }
>
> - WRITE_ONCE(bond->slave_cnt, bond->slave_cnt + 1);
> - netdev_compute_master_upper_features(bond->dev, true);
> - bond_set_carrier(bond);
> -
[ ... ]
> - /* XDP capability and prog-count were already validated above */
> if (bond->xdp_prog) {
> struct netdev_bpf xdp = {
> .command = XDP_SETUP_PROG,
> @@ -2341,19 +2330,35 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
> if (res < 0) {
> /* ndo_bpf() sets extack error message */
> slave_dbg(bond_dev, slave_dev, "Error %d calling ndo_bpf\n", res);
> - goto err_dec_slave_cnt;
> + goto err_set_xdp;
> }
> if (bond->xdp_prog)
> bpf_prog_inc(bond->xdp_prog);
> }
>
> + bond_xdp_set_features(bond_dev);
> +
> + /* Must called before bond_update_slave_arr() or bond_select_active_slave() */
> + WRITE_ONCE(bond->slave_cnt, bond->slave_cnt + 1);
[Severity: Critical]
After this reordering, dev_xdp_propagate() runs the slave driver's ndo_bpf
when the new slave is already on the bond's lower list
(bond_master_upper_dev_link() ran earlier) but slave_cnt has not been
incremented yet. If a notifier fires from inside ndo_bpf, can it rebuild
the slave arrays using the old slave_cnt?
For example, dpaa2_eth_setup_xdp() closes and reopens a running device:
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c:dpaa2_eth_setup_xdp() {
...
up = netif_running(dev);
...
if (up)
dev_close(dev);
...
if (up) {
err = dev_open(dev, NULL);
...
}
Take balance-xor or 802.3ad mode (802.3ad once there is an active
aggregator) with an XDP program attached to the bond. The call chain
looks like this:
bond_enslave()
dev_xdp_propagate()
dpaa2_eth_xdp()
dpaa2_eth_setup_xdp()
dev_close() /* NETDEV_DOWN */
bond_netdev_event()
bond_slave_netdev_event()
bond_update_slave_arr(bond, NULL)
bond_update_slave_arr() sizes the arrays from slave_cnt (N). It then walks
all N+1 slaves on the list with no bound:
usable_slaves = kzalloc_flex(*usable_slaves, arr, bond->slave_cnt);
all_slaves = kzalloc_flex(*all_slaves, arr, bond->slave_cnt);
...
bond_for_each_slave(bond, slave, iter) {
...
all_slaves->arr[all_slaves->count++] = slave;
Does this write one struct slave pointer past the end of all_slaves->arr[]
and usable_slaves->arr[]? The arrays are then published with a count
larger than their allocation, so the xmit hash path could read past them
too. dev_open() then raises NETDEV_UP, which would do the same thing again.
For the second slave, struct_size() comes to 32 bytes, which fills a
kmalloc-32 object exactly. The write to arr[1] would then hit the
neighbouring object.
The same applies to any other slave driver whose ndo_bpf synchronously
raises NETDEV_UP, NETDEV_DOWN or NETDEV_CHANGE.
Before this patch, slave_cnt was incremented before dev_xdp_propagate(),
so these rebuilds saw the right count. The new comment above says slave_cnt
must be updated before bond_update_slave_arr(), but calls that come in
through notifiers from ndo_bpf now break that rule.
This still seems to be there at the end of the series.
bond_publish_slave(), added in "bonding: factor out slave publication",
still runs after the XDP setup.
> + netdev_compute_master_upper_features(bond->dev, true);
> + bond_set_carrier(bond);
[ ... ]
> @@ -2363,8 +2368,15 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
> return 0;
>
> /* Undo stages on error */
> -err_dec_slave_cnt:
> - WRITE_ONCE(bond->slave_cnt, bond->slave_cnt - 1);
[Severity: Low]
The commit message says:
If XDP setup then fails, the error path
jumps to err_sysfs_del and leaks:
and:
follows the publication of the slave and a failure can no longer
leak slave_cnt or ns maddrs.
Does this match the parent commit? There, a dev_xdp_propagate() failure
already does goto err_dec_slave_cnt, which decrements slave_cnt. That
label came from a978095699641d ("bonding: fix slave_cnt leak on XDP
enslave failure").
In this hunk the patch actually removes err_dec_slave_cnt, which the
reorder makes unnecessary. Could the commit message say so and reference
a978095699641d?
Separately, there's a typo in the new comment:
/* Must called before bond_update_slave_arr() or bond_select_active_slave() */
"Must called" should be "Must be called". The typo is carried into
bond_publish_slave() by "bonding: factor out slave publication".
> +err_set_xdp:
> + 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);
> + }
[Severity: Low]
This block fixes leaks that users can actually hit, but the commit has no
Fixes: tag.
In non-primary modes, the parent code jumped from a dev_xdp_propagate()
failure to err_sysfs_del without undoing any of these:
- the promiscuity/allmulti increments
- the addresses added by dev_mc_sync_multiple()/dev_uc_sync_multiple()
and the LACPDU dev_mc_add()
- the ns target maddrs added by bond_slave_ns_maddrs_add()
The XDP setup placement comes from 9e2ee5c7e7c3 ("net, bonding: Add XDP
support to the bonding driver"). That is also the Fixes: target of
a978095699641d. Placing the ns maddrs before the XDP setup comes from
8eb36164d1a6 ("bonding: add ns target multicast address to slave
device").
This failure can really happen. For example, dpaa2_eth_setup_xdp() returns
-EINVAL when the MTU is not valid for XDP:
if (prog && !xdp_mtu_valid(priv, dev->mtu))
return -EINVAL;
Should this carry Fixes: 9e2ee5c7e7c3 and/or Fixes: 8eb36164d1a6?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113-bond_enslave_restruct-v1-0-364c549e78db%40kylinos.cn
Re: [PATCH net-next 4/6] bonding: factor out slave publication
Author: netdev-bot+sashiko
Date: Tue, 17 Nov 2026 14:40
Date: Tue, 17 Nov 2026 14:40
158 lines
13909 bytes
13909 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 new comment on bond_publish_slave() in
drivers/net/bonding/bond_main.c says the helper will "Make the fully…
- [Low] The commit message calls bond_publish_slave() the "infallible
'commit point'", and the new comment says "All fallible steps of…
- [Low] The commit author is 'Hangbin Liu <hangbin.liu@linux.dev>', but
the only Signed-off-by is 'Hangbin Liu <liuhangbin@kylinos.cn>'.
--
bonding: factor out slave publication
This commit moves the final block of bond_enslave() into a new helper,
bond_publish_slave(). That block bumps slave_cnt, recomputes upper
features and carrier, adds NS maddrs, selects the active slave and
rebuilds the xmit slave arrays. The commit message calls this the
infallible commit point of the function and says there is no functional
change.
> Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
[Severity: Low]
This isn't a bug, but the Author address (hangbin.liu@linux.dev) does not
match the only Signed-off-by (liuhangbin@kylinos.cn). checkpatch reports
this as "From:/Signed-off-by: email address mismatch".
The same mismatch shows up on all six patches in the series, from
"bonding: check XDP support before enslaving changes state" through
"bonding: factor out bond_enslave_validate".
Could the addresses be made to match, or a From: line or Signed-off-by
be added for the author address?
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index f696a0d150346..bb37526834562 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -1884,6 +1884,34 @@ void bond_xdp_set_features(struct net_device *bond_dev)
> xdp_set_features_flag(bond_dev, val);
> }
>
> +/* Make the fully prepared slave visible to the rest of the bonding
> + * code. All fallible steps of bond_enslave() must have completed
> + * before this runs: error paths never undo the publication.
> + */
[Severity: Low]
Is "visible to the rest of the bonding code" accurate here? By the time
bond_publish_slave() runs, bond_enslave() has already made the slave
reachable:
res = netdev_rx_handler_register(slave_dev, bond_handle_frame,
new_slave);
...
res = bond_master_upper_dev_link(bond, new_slave, extack);
...
res = bond_sysfs_slave_add(new_slave);
bond_for_each_slave() is netdev_for_each_lower_private(). So once
bond_master_upper_dev_link() returns, every bond_for_each_slave() walker
sees the new slave. bond_xdp_set_features(), called just before this
helper, already iterates over it.
In the default (trunk) mode, the switch in bond_enslave() also publishes
the slave as curr_active_slave. That happens before several steps that
can still fail (netpoll, rx_handler, upper link, sysfs, promisc/allmulti,
XDP):
if (!rcu_access_pointer(bond->curr_active_slave) &&
new_slave->link == BOND_LINK_UP)
rcu_assign_pointer(bond->curr_active_slave, new_slave);
The err_detach path then undoes that:
if (rcu_access_pointer(bond->curr_active_slave) == new_slave) {
block_netpoll_tx();
bond_change_active_slave(bond, NULL);
bond_select_active_slave(bond);
unblock_netpoll_tx();
}
So "error paths never undo the publication" does not seem to hold either.
The helper actually commits slave_cnt and rebuilds derived state: upper
features, carrier, NS maddrs, active slave selection and the xmit slave
arrays. Between bond_master_upper_dev_link() and bond_publish_slave(),
list walkers see N+1 slaves while slave_cnt is still N.
Could the comment say that instead? Otherwise a later change might assume
the slave cannot be reached before this point.
> +static void bond_publish_slave(struct bonding *bond, struct slave *slave)
> +{
[ ... ]
> + /* broadcast mode uses the all_slaves to loop through slaves. */
> + if (bond_mode_can_use_xmit_hash(bond) ||
> + BOND_MODE(bond) == BOND_MODE_BROADCAST)
> + bond_update_slave_arr(bond, NULL);
> +}
[Severity: Low]
The commit message calls this the infallible "commit point", and the
comment above says all fallible steps must be done before this runs. Can
bond_update_slave_arr() still fail here?
drivers/net/bonding/bond_main.c:bond_update_slave_arr() {
...
usable_slaves = kzalloc_flex(*usable_slaves, arr, bond->slave_cnt);
all_slaves = kzalloc_flex(*all_slaves, arr, bond->slave_cnt);
if (!usable_slaves || !all_slaves) {
ret = -ENOMEM;
goto out;
}
...
}
On that path bond_set_slave_arr() is never called. Since skipslave is
NULL, nothing else makes up for it.
bond_publish_slave() returns void, so the error is dropped and the
slave_arr work is not re-armed. bond_slave_arr_handler() does re-arm it
when the same call fails:
ret = bond_update_slave_arr(bond, NULL);
rtnl_unlock();
if (ret) {
pr_warn_ratelimited("Failed to update slave array from WT\n");
goto err;
}
return;
err:
bond_slave_arr_work_rearm(bond, 1);
If the allocation fails, bond_enslave() still returns 0 and slave_cnt
has already been incremented. all_slaves and usable_slaves still hold
the old slave set. bond_xmit_broadcast() skips the new slave, and
XOR/3ad/TLB hashing never picks it, until some unrelated event rebuilds
the arrays.
The unchecked call was already inline in bond_enslave() before this
patch. What is new is the void helper and the comment that call it
infallible.
Should the comment and commit message be corrected? Or should the helper
call bond_slave_arr_work_rearm(bond, 1) when bond_update_slave_arr()
fails?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113-bond_enslave_restruct-v1-0-364c549e78db%40kylinos.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