network: set bridge or bond properties after master ifindex is set

This commit is contained in:
Yu Watanabe
2021-06-08 06:39:48 +09:00
parent 1362bd6c64
commit 440d40dcc0
2 changed files with 16 additions and 1 deletions
+1
View File
@@ -139,6 +139,7 @@ typedef struct Link {
bool sr_iov_configured:1;
bool can_configured:1;
bool activated:1;
bool master_set:1;
bool entering_to_join_netdev:1;
bool stacked_netdevs_created:1;
bool stacked_netdevs_after_configured_created:1;
+15 -1
View File
@@ -29,6 +29,12 @@ static int get_link_default_handler(sd_netlink *rtnl, sd_netlink_message *m, Lin
return link_getlink_handler_internal(rtnl, m, link, "Failed to sync link information");
}
static int get_link_master_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
if (get_link_default_handler(rtnl, m, link) > 0)
link->master_set = true;
return 0;
}
static int set_link_handler_internal(
sd_netlink *rtnl,
sd_netlink_message *m,
@@ -118,7 +124,7 @@ static int link_set_mac_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *l
}
static int link_set_master_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
return set_link_handler_internal(rtnl, m, link, SET_LINK_MASTER, true, get_link_default_handler);
return set_link_handler_internal(rtnl, m, link, SET_LINK_MASTER, true, get_link_master_handler);
}
static int link_set_mtu_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
@@ -436,6 +442,12 @@ static bool link_is_ready_to_call_set_link(Request *req) {
return false;
switch (op) {
case SET_LINK_BOND:
case SET_LINK_BRIDGE:
case SET_LINK_BRIDGE_VLAN:
if (!link->master_set)
return false;
break;
case SET_LINK_MASTER: {
uint32_t m = 0;
@@ -629,6 +641,8 @@ int link_request_to_set_mac(Link *link) {
int link_request_to_set_master(Link *link) {
assert(link);
link->master_set = false;
return link_request_set_link(link, SET_LINK_MASTER, link_set_master_handler, NULL);
}