From: netdev-bot+sashiko@kernel.org
To: hangbin.liu@linux.dev
Cc: jv@jvosburgh.net, andrew+netdev@lunn.ch, davem@davemloft.net,
edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org,
john.fastabend@gmail.com, sdf@fomichev.me,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org
Subject: Re: [PATCH net-next 4/6] bonding: factor out slave publication
Date: Tue, 17 Nov 2026 14:40:12 +0000 [thread overview]
Message-ID: <179492641202.3136.3136612053973913945@kernel.org> (raw)
In-Reply-To: <20261113-bond_enslave_restruct-v1-4-364c549e78db@kylinos.cn>
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
next prev parent reply other threads:[~2026-11-17 14:40 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 14:04 [PATCH net-next 0/6] bonding: refactor bond_enslave() to fix XDP ordering and error rollback Hangbin Liu
2026-11-13 14:04 ` [PATCH net-next 1/6] bonding: check XDP support before enslaving changes state Hangbin Liu
2026-11-14 14:06 ` sashiko-bot
2026-11-17 14:40 ` netdev-bot+sashiko
2026-11-13 14:04 ` [PATCH net-next 2/6] bonding: finish XDP setup before publishing the slave Hangbin Liu
2026-11-14 14:06 ` sashiko-bot
2026-11-17 14:40 ` netdev-bot+sashiko
2026-11-13 14:04 ` [PATCH net-next 3/6] bonding: complete rollback of bond_enslave() error paths Hangbin Liu
2026-11-14 14:06 ` sashiko-bot
2026-11-17 5:30 ` Hangbin Liu
2026-11-17 14:40 ` netdev-bot+sashiko
2026-11-13 14:04 ` [PATCH net-next 4/6] bonding: factor out slave publication Hangbin Liu
2026-11-17 14:40 ` netdev-bot+sashiko [this message]
2026-11-13 14:04 ` [PATCH net-next 5/6] bonding: factor out XDP slave check Hangbin Liu
2026-11-13 14:04 ` [PATCH net-next 6/6] bonding: factor out bond_enslave_validate Hangbin Liu
2026-11-17 14:40 ` netdev-bot+sashiko
2026-11-13 14:11 ` [PATCH net-next 0/6] bonding: refactor bond_enslave() to fix XDP ordering and error rollback netdev-bot+sinfo
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=179492641202.3136.3136612053973913945@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hangbin.liu@linux.dev \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=jv@jvosburgh.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@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