From: netdev-bot+sashiko@kernel.org
To: jiangjiehua1@huawei.com
Cc: netdev@vger.kernel.org, j.vosburgh@gmail.com,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, liuhangbin@kylinos.cn,
zhangchangzhong@huawei.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] bonding: clear stale usable_slaves in broadcast mode
Date: Wed, 25 Nov 2026 12:28:02 +0000 [thread overview]
Message-ID: <179560968241.3135.13874120007474157909@kernel.org> (raw)
In-Reply-To: <20261124130102.18807-1-jiangjiehua1@huawei.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 0
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).
- [High] The patch only fixes one target mode.
--
bonding: clear stale usable_slaves in broadcast mode
When the last slave is released in an xmit-hash mode, an empty
usable_slaves array is left published. If the bond is later switched to
broadcast mode, that array survives and makes bond_miimon_inspect()
ignore updelay. It also leaks from bond_uninit(). The patch frees the
array and clears the pointer in bond_option_mode_set() when the new mode
is broadcast.
> diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
> index 9efadeff6a223..f65916444fa1c 100644
> --- a/drivers/net/bonding/bond_options.c
> +++ b/drivers/net/bonding/bond_options.c
> @@ -936,6 +936,14 @@ static int bond_option_mode_set(struct bonding *bond,
> WRITE_ONCE(bond->params.arp_validate, BOND_ARP_VALIDATE_NONE);
> WRITE_ONCE(bond->params.mode, newval->value);
>
> + if (newval->value == BOND_MODE_BROADCAST) {
> + struct bond_up_slave *usable;
> +
> + usable = rtnl_dereference(bond->usable_slaves);
> + RCU_INIT_POINTER(bond->usable_slaves, NULL);
> + kfree_rcu(usable, rcu);
> + }
[Severity: High]
Does balance-rr still skip updelay after this change?
The commit message says the cause is that "later mode changes do not
clear it". It also says "Broadcast never publishes usable_slaves, so it
stays NULL". The same is true of BOND_MODE_ROUNDROBIN. Nothing in
balance-rr replaces or clears usable_slaves. bond_mode_can_use_xmit_hash()
covers only 8023AD, XOR, TLB and ALB, so these refreshes all skip
round-robin:
drivers/net/bonding/bond_main.c:bond_open() {
...
if (bond_mode_can_use_xmit_hash(bond))
bond_update_slave_arr(bond, NULL);
...
}
drivers/net/bonding/bond_main.c:bond_enslave() {
...
if (bond_mode_can_use_xmit_hash(bond) ||
BOND_MODE(bond) == BOND_MODE_BROADCAST)
bond_update_slave_arr(bond, NULL);
...
}
The same check gates the refreshes in __bond_release_one() and in the
NETDEV_UP/CHANGE/DOWN handler. The miimon and ARP commit paths refresh
the array only for XOR.
bond_miimon_inspect() handles every mode except active-backup the same
way, so round-robin also reaches this code:
usable_slaves = rcu_dereference(bond->usable_slaves);
if (usable_slaves && usable_slaves->count == 0)
ignore_updelay = true;
Here is the trigger. Release the last slave in balance-xor, 802.3ad,
balance-tlb or balance-alb. __bond_release_one()->bond_update_slave_arr()
then publishes a count-0 array. Switch to balance-rr, bring the bond up
and enslave a slave whose link is up. bond_enslave() puts the slave in
BOND_LINK_BACK with delay = updelay, but bond_miimon_inspect() skips the
delay because ignore_updelay is set.
The reproducer in the commit message, with "mode balance-rr" in place of
"mode broadcast", should still bring dummy0 up at once. The array does
not leak in balance-rr, because bond_uninit()->bond_set_slave_arr() takes
the non-broadcast path and frees it. Only the updelay bypass remains.
The balance-rr case looks like it dates back to f8a65ab2f3ff74.
The mode option requires BOND_OPTFLAG_NOSLAVES | BOND_OPTFLAG_IFDOWN.
bond_open() rebuilds the array for the modes that use it. Could the
broadcast-only condition be dropped, so that usable_slaves is cleared on
every mode change?
> /* When changing mode, the bond device is down, we may reduce
> * the bond_bcast_neigh_enabled in bond_close() if broadcast_neighbor
> * enabled in 8023ad mode. Therefore, only clear broadcast_neighbor
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124130102.18807-1-jiangjiehua1%40huawei.com
prev parent reply other threads:[~2026-11-25 12:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 13:01 JiangJieHua
2026-11-25 1:26 ` Hangbin Liu
2026-11-25 7:00 ` jiangjiehua (A)
2026-11-25 12:28 ` netdev-bot+sashiko [this message]
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=179560968241.3135.13874120007474157909@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=j.vosburgh@gmail.com \
--cc=jiangjiehua1@huawei.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuhangbin@kylinos.cn \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=zhangchangzhong@huawei.com \
/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
all inboxes | Powered by JetHome®