* [PATCH net-next] bonding: roll back fail_over_mac if enslave fails
@ 2026-11-24 12:34 Hangbin Liu
2026-11-24 12:38 ` netdev-bot+sinfo
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Hangbin Liu @ 2026-11-24 12:34 UTC (permalink / raw)
To: Jay Vosburgh, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: Hangbin Liu, netdev, linux-kernel, Hangbin Liu
From: Hangbin Liu <liuhangbin@kylinos.cn>
bond_enslave() can change bond->params.fail_over_mac as a side
effect: when the first slave cannot set its own MAC address and the
bond is in active-backup mode, fail_over_mac is forced to "active" so
bonding never writes the slave MAC. If enslave fails later, the
forced value stays behind, silently changing a user-configured
option after a failed operation and affecting subsequent failover
behaviour.
Snapshot fail_over_mac on entry and restore it on the error path.
Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
drivers/net/bonding/bond_main.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 9249a79a168e..3817c82e89e2 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1890,6 +1890,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
{
struct bonding *bond = netdev_priv(bond_dev);
const struct net_device_ops *slave_ops = slave_dev->netdev_ops;
+ int orig_fail_over_mac = bond->params.fail_over_mac;
struct slave *new_slave = NULL, *prev_slave;
struct sockaddr_storage ss;
int res = 0, i;
@@ -2412,6 +2413,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
kobject_put(&new_slave->kobj);
err_undo_flags:
+ bond->params.fail_over_mac = orig_fail_over_mac;
/* Enslave of first slave has failed and we need to fix master's mac */
if (!bond_has_slaves(bond)) {
if (ether_addr_equal_64bits(bond_dev->dev_addr,
---
base-commit: 9545bf5293dfb83138faec013f7ce4184218f304
change-id: 20261124-bond_fail_over_mac-e7952797e80b
Best regards,
--
Hangbin Liu <liuhangbin@kylinos.cn>
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH net-next] bonding: roll back fail_over_mac if enslave fails
2026-11-24 12:34 [PATCH net-next] bonding: roll back fail_over_mac if enslave fails Hangbin Liu
@ 2026-11-24 12:38 ` netdev-bot+sinfo
2026-12-02 9:35 ` Paolo Abeni
2026-11-30 11:28 ` Daniel Machon
2026-12-03 2:02 ` willemb
2 siblings, 1 reply; 6+ messages in thread
From: netdev-bot+sinfo @ 2026-11-24 12:38 UTC (permalink / raw)
To: Hangbin Liu
Cc: Jay Vosburgh, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] bonding: roll back fail_over_mac if enslave fails
2026-11-24 12:38 ` netdev-bot+sinfo
@ 2026-12-02 9:35 ` Paolo Abeni
2026-12-03 1:40 ` Hangbin Liu
0 siblings, 1 reply; 6+ messages in thread
From: Paolo Abeni @ 2026-12-02 9:35 UTC (permalink / raw)
To: netdev-bot+sinfo, Hangbin Liu
Cc: Jay Vosburgh, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, netdev, linux-kernel
On 11/24/26 13:38, netdev-bot+sinfo@kernel.org wrote:
> Hi!
>
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
>
> - How the issue was discovered, e.g. hit in production, hit during
> development, syzbot report, manual code inspection, LLM or static
> analysis tool scan.
>
> - Whether the issue was actually triggered, or is only theoretical
> (e.g. found by LLM and not proven at runtime). If it was triggered
> please include the symptoms, like the stack trace or kernel messages.
>
> Please do not repost the series just to address the above. Instead,
> reply to this email with the missing information, so that reviewers
> can take it into account.
>
> *IMPORTANT*: If you do repost (for other reasons) - please include
> the relevant info in the cover letter or commit messages.
Please answer the above questions. Also any changes to have this
scenario covered by self-tests?
/P
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] bonding: roll back fail_over_mac if enslave fails
2026-12-02 9:35 ` Paolo Abeni
@ 2026-12-03 1:40 ` Hangbin Liu
0 siblings, 0 replies; 6+ messages in thread
From: Hangbin Liu @ 2026-12-03 1:40 UTC (permalink / raw)
To: Paolo Abeni
Cc: netdev-bot+sinfo, Jay Vosburgh, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, netdev, linux-kernel
Hi Paolo,
On Wed, Dec 02, 2026 at 10:35:53AM +0100, Paolo Abeni wrote:
> On 11/24/26 13:38, netdev-bot+sinfo@kernel.org wrote:
> > Hi!
> >
> > This is an automated message. This series looks like a fix, but its
> > commit messages seem to be missing some information:
> >
> > - How the issue was discovered, e.g. hit in production, hit during
> > development, syzbot report, manual code inspection, LLM or static
> > analysis tool scan.
> >
> > - Whether the issue was actually triggered, or is only theoretical
> > (e.g. found by LLM and not proven at runtime). If it was triggered
> > please include the symptoms, like the stack trace or kernel messages.
> >
> > Please do not repost the series just to address the above. Instead,
> > reply to this email with the missing information, so that reviewers
> > can take it into account.
> >
> > *IMPORTANT*: If you do repost (for other reasons) - please include
> > the relevant info in the cover letter or commit messages.
>
> Please answer the above questions.
Oh, I thought this is only for fixes to net.
The issue is discovered when I tried to restruct bond_enslave().
It could be reproduced via
bash-5.3# ip link add wg0 type wireguard
bash-5.3# ip link add bond0 type bond mode active-backup
bash-5.3# ip link set bond0 xdpdrv obj xdp_dummy.bpf.o sec xdp
bash-5.3# ip -d -j -p link show bond0 | grep fail_over_mac
"fail_over_mac": "none",
bash-5.3# ip link set wg0 master bond0
Error: Slave does not support XDP.
bash-5.3# ip -d -j -p link show bond0 | grep fail_over_mac
"fail_over_mac": "active",
After the patch, the fail_over_mac will not be changed by a failed enslave.
bash-5.3# ip -d -j -p link show bond0 | grep fail_over_mac
"fail_over_mac": "none",
> Also any changes to have this scenario covered by self-tests?
We generally try our best to avoid failures during enslavement, since we have
a lot of rollback work to handle. The reproducer for these bond_enslave
rollback paths relies on XDP checking failures. I’ve moved that XDP check
earlier in bond_enslave with the patch:
"bonding: check XDP support before enslaving changes state" [1].
Once that XDP patch is applied, this class of issue will become difficult
to reproduce. Therefore, I do not plan to add a selftest for it.
[1] https://lore.kernel.org/all/20261130-bond_xdp_fix-v3-1-49be5fcd9376@kylinos.cn/
Thanks
Hangbin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] bonding: roll back fail_over_mac if enslave fails
2026-11-24 12:34 [PATCH net-next] bonding: roll back fail_over_mac if enslave fails Hangbin Liu
2026-11-24 12:38 ` netdev-bot+sinfo
@ 2026-11-30 11:28 ` Daniel Machon
2026-12-03 2:02 ` willemb
2 siblings, 0 replies; 6+ messages in thread
From: Daniel Machon @ 2026-11-30 11:28 UTC (permalink / raw)
To: Hangbin Liu
Cc: Jay Vosburgh, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
> From: Hangbin Liu <liuhangbin@kylinos.cn>
>
> bond_enslave() can change bond->params.fail_over_mac as a side
> effect: when the first slave cannot set its own MAC address and the
> bond is in active-backup mode, fail_over_mac is forced to "active" so
> bonding never writes the slave MAC. If enslave fails later, the
> forced value stays behind, silently changing a user-configured
> option after a failed operation and affecting subsequent failover
> behaviour.
>
> Snapshot fail_over_mac on entry and restore it on the error path.
>
> Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] bonding: roll back fail_over_mac if enslave fails
2026-11-24 12:34 [PATCH net-next] bonding: roll back fail_over_mac if enslave fails Hangbin Liu
2026-11-24 12:38 ` netdev-bot+sinfo
2026-11-30 11:28 ` Daniel Machon
@ 2026-12-03 2:02 ` willemb
2 siblings, 0 replies; 6+ messages in thread
From: willemb @ 2026-12-03 2:02 UTC (permalink / raw)
To: Hangbin Liu, Jay Vosburgh, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Hangbin Liu, netdev, linux-kernel
Hangbin Liu wrote:
> From: Hangbin Liu <liuhangbin@kylinos.cn>
> bond_enslave() can change bond->params.fail_over_mac as a side
> effect: when the first slave cannot set its own MAC address and the
> bond is in active-backup mode, fail_over_mac is forced to "active" so
> bonding never writes the slave MAC. If enslave fails later, the
> forced value stays behind, silently changing a user-configured
> option after a failed operation and affecting subsequent failover
> behaviour.
> Snapshot fail_over_mac on entry and restore it on the error path.
> Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
When respinning, please fold the discovery context and the WireGuard +
XDP
reproducer from your reply to Paolo into the commit message (per sinfo),
and consider adding:
Fixes: 3915c1e8634a ("bonding: Add "follow" option to fail_over_mac")
Also if targeting net-next.
> ---
> drivers/net/bonding/bond_main.c | 2 ++
> 1 file changed, 2 insertions(+)
> diff --git a/drivers/net/bonding/bond_main.c
> b/drivers/net/bonding/bond_main.c
> index 9249a79a168e..3817c82e89e2 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -1890,6 +1890,7 @@ int bond_enslave(struct net_device *bond_dev,
> struct net_device *slave_dev,
> {
> struct bonding *bond = netdev_priv(bond_dev);
> const struct net_device_ops *slave_ops = slave_dev->netdev_ops;
> + int orig_fail_over_mac = bond->params.fail_over_mac;
> struct slave *new_slave = NULL, *prev_slave;
> struct sockaddr_storage ss;
> int res = 0, i;
> @@ -2412,6 +2413,7 @@ int bond_enslave(struct net_device *bond_dev,
> struct net_device *slave_dev,
> kobject_put(&new_slave->kobj);
> err_undo_flags:
> + bond->params.fail_over_mac = orig_fail_over_mac;
Since commits 4dc5a40b3bc9 ("bonding: annotate data-races in sysfs and
procfs") and 317cefdcaacc ("bonding: no longer rely on RTNL in
bond_fill_info()"), bond->params.fail_over_mac is read without RTNL via
READ_ONCE() in bonding_show_fail_over_mac() (bond_sysfs.c:268),
bond_info_show_master() (bond_procfs.c:71), and bond_fill_info()
(bond_netlink.c:804), paired with WRITE_ONCE() in
bond_option_fail_over_mac_set() (bond_options.c:1587).
Doing an unannotated plain store here — unconditionally on every failed
bond_enslave(), even when fail_over_mac did not change — introduces a
KCSAN data race against those lockless readers. Guard the restore and
use WRITE_ONCE():
if (bond->params.fail_over_mac != orig_fail_over_mac)
WRITE_ONCE(bond->params.fail_over_mac, orig_fail_over_mac);
(The pre-existing `bond->params.fail_over_mac = BOND_FOM_ACTIVE;` store
earlier in bond_enslave() at line 2018 is also missing WRITE_ONCE() and
is worth annotating in the same patch.)
> /* Enslave of first slave has failed and we need to fix master's mac */
> if (!bond_has_slaves(bond)) {
> if (ether_addr_equal_64bits(bond_dev->dev_addr,
> ---
> base-commit: 9545bf5293dfb83138faec013f7ce4184218f304
> change-id: 20261124-bond_fail_over_mac-e7952797e80b
> Best regards,
> --
> Hangbin Liu <liuhangbin@kylinos.cn>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-12-03 2:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 12:34 [PATCH net-next] bonding: roll back fail_over_mac if enslave fails Hangbin Liu
2026-11-24 12:38 ` netdev-bot+sinfo
2026-12-02 9:35 ` Paolo Abeni
2026-12-03 1:40 ` Hangbin Liu
2026-11-30 11:28 ` Daniel Machon
2026-12-03 2:02 ` willemb
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.