]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: set bridge or bond properties after master ifindex is set
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 28 May 2021 18:33:38 +0000 (03:33 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 7 Jun 2021 21:39:48 +0000 (06:39 +0900)
src/network/networkd-link.h
src/network/networkd-setlink.c

index bd6c1b2774ee93f3f9f6900e5b15f55448c69c96..600b5f5ee129e8a84057cd51ccb1fec8be036602 100644 (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;
index e25f681f50e4403e7287ed55bd5da4d2a7451233..1184fbfb43b77f5772e98c3a6e7a9d55a0d538e2 100644 (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);
 }