]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/network/networkd-setlink.h
network: Fix set bond device MAC address failed
authorJian Zhang <zhangjian.3032@bytedance.com>
Fri, 2 Dec 2022 12:08:38 +0000 (20:08 +0800)
committerJian Zhang <zhangjian.3032@bytedance.com>
Mon, 5 Dec 2022 11:48:45 +0000 (19:48 +0800)
commitf1a69d5accfd566c5af0210115f4b4a9743425ee
treeecbf085d166c80ae20b63d2742a40e94dafca2e7
parent8825e90a708a54ce202b327b93ed7e7955885dfe
network: Fix set bond device MAC address failed

Issue:
When device is in bond mode and booting up, there is a probability of
set bond MAC address failed due to `Device or resource busy` error.

In systemd-networkd, set MAC address steps are:
1. Try to set MAC address to device.
2. If failed with `Device or resource busy`, then `Down` the device.
3. Try to set MAC address to device again.

Currently, Even down the bond device, the bond device is still return
`Device or resource busy` error. So the MAC address set failed.

The root cause is that this not enough to down the bond device. We need
to down all the slaves of the bond device.
About this descprition, we could use those commands to check:
```shell
We have two network devices: eth0, bond1, eth0 is slave of bond1.
They are all up.

1. Down bond1, and set MAC address to bond1.
~# ip link set bond1 down
~# ip link set bond1 address 00:11:22:33:44:55
ip: SIOCSIFHWADDR: Device or resource busy

2. Down eth0, and set MAC address to bond1.
~# ip link set eth0 down
~# ip link set bond1 address 00:11:22:33:44:55
Set okay.
```

Fix:
When setting the mac for the second time, if the device kind is bond,
then we need to down the slave devices of bond device.

Tested: Verified in a long time test( reboot cycles ).

Fixes: #25627
Signed-off-by: Jian Zhang <zhangjian.3032@bytedance.com>
src/network/networkd-setlink.c
src/network/networkd-setlink.h