Merge pull request #25628 from zhangjian3032/dev/fix-set-bond-mac-failed

network: Fix set bond device MAC address failed
This commit is contained in:
Yu Watanabe 2022-12-07 13:34:39 +09:00 committed by GitHub
commit bf9afd7b31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 0 deletions

View file

@ -502,6 +502,14 @@ static int link_is_ready_to_set_link(Link *link, Request *req) {
r = link_down_now(link);
if (r < 0)
return r;
/* If the kind of the link is "bond", we need
* set the slave link down as well. */
if (streq_ptr(link->kind, "bond")) {
r = link_down_slave_links(link);
if (r < 0)
return r;
}
}
break;
@ -1226,6 +1234,21 @@ int link_down_now(Link *link) {
return 0;
}
int link_down_slave_links(Link *link) {
Link *slave;
int r;
assert(link);
SET_FOREACH(slave, link->slaves) {
r = link_down_now(slave);
if (r < 0)
return r;
}
return 0;
}
static int link_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
int r;

View file

@ -25,4 +25,5 @@ int link_request_to_activate(Link *link);
int link_request_to_bring_up_or_down(Link *link, bool up);
int link_down_now(Link *link);
int link_down_slave_links(Link *link);
int link_remove(Link *link);

View file

@ -4,3 +4,6 @@ Name=bond199
[Network]
IPv6AcceptRA=no
[Link]
MACAddress=00:11:22:33:44:55

View file

@ -3881,6 +3881,7 @@ class NetworkdBondTests(unittest.TestCase, Utilities):
output = check_output('ip -d link show bond199')
print(output)
self.assertRegex(output, 'primary dummy98')
self.assertIn('link/ether 00:11:22:33:44:55', output)
def test_bond_operstate(self):
copy_network_unit('25-bond.netdev', '11-dummy.netdev', '12-dummy.netdev',