]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: do not free bound_by carrier map on reconfigure
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 31 Jan 2022 13:30:39 +0000 (22:30 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 1 Feb 2022 02:37:01 +0000 (11:37 +0900)
Otherwise, if a link enters unmanaged state, then its carrier state does
not propagated to other interfaces.

src/network/networkd-link.c

index b68ee82c51f8e48eace68d07af208c2d965899e3..75bc560a69cd822f7a236dfd4618eb2fb0d92d98 100644 (file)
@@ -894,24 +894,6 @@ static int link_new_bound_to_list(Link *link) {
         return 0;
 }
 
-static int link_new_carrier_maps(Link *link) {
-        int r;
-
-        r = link_new_bound_by_list(link);
-        if (r < 0)
-                return r;
-
-        r = link_handle_bound_by_list(link);
-        if (r < 0)
-                return r;
-
-        r = link_new_bound_to_list(link);
-        if (r < 0)
-                return r;
-
-        return link_handle_bound_to_list(link);
-}
-
 static void link_free_bound_to_list(Link *link) {
         bool updated = false;
         Link *bound_to;
@@ -1119,6 +1101,10 @@ static int link_configure(Link *link) {
 
         link_set_state(link, LINK_STATE_CONFIGURING);
 
+        r = link_new_bound_to_list(link);
+        if (r < 0)
+                return r;
+
         r = link_configure_traffic_control(link);
         if (r < 0)
                 return r;
@@ -1325,7 +1311,12 @@ static int link_reconfigure_impl(Link *link, bool force) {
                         return r;
         }
 
-        link_free_carrier_maps(link);
+        /* The bound_to map depends on .network file, hence it needs to be freed. But, do not free the
+         * bound_by map. Otherwise, if a link enters unmanaged state below, then its carrier state will
+         * not propagated to other interfaces anymore. Moreover, it is not necessary to recreate the
+         * map here, as it depends on .network files assigned to other links. */
+        link_free_bound_to_list(link);
+
         link_free_engines(link);
         link->network = network_unref(link->network);
 
@@ -1339,10 +1330,6 @@ static int link_reconfigure_impl(Link *link, bool force) {
         link_update_operstate(link, true);
         link_dirty(link);
 
-        r = link_new_carrier_maps(link);
-        if (r < 0)
-                return r;
-
         link_set_state(link, LINK_STATE_INITIALIZED);
         link->activated = false;
 
@@ -1496,10 +1483,6 @@ static int link_initialized_and_synced(Link *link) {
                 link_dirty(link);
         }
 
-        r = link_new_bound_to_list(link);
-        if (r < 0)
-                return r;
-
         return link_configure(link);
 }