network: enter initialized state when the interface will be reconfigured
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 20 Aug 2024 22:01:47 +0000 (07:01 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 20 Aug 2024 22:29:19 +0000 (07:29 +0900)
When the interface is in the failed state, link_getlink_handler_internal()
will do nothing and return zero, thus the interface will not be
reconfigured, especially when the reconfiguration is triggered in
link_enter_failed().

Follow-up for c2eb7753dd47ec04ae0d66400e70bc87fbf1adcc.

src/network/networkd-link-bus.c
src/network/networkd-link.c

index 84ed42987c51ec0b1cdcb2098377ebfaf8ba43ab..ef2e81125577f010c1eedf81cbc6a281ce2bab34 100644 (file)
@@ -669,7 +669,6 @@ int bus_link_method_reconfigure(sd_bus_message *message, void *userdata, sd_bus_
         if (r < 0)
                 return r;
         if (r > 0) {
-                link_set_state(l, LINK_STATE_INITIALIZED);
                 r = link_save_and_clean_full(l, /* also_save_manager = */ true);
                 if (r < 0)
                         return r;
index 3940aa79b37e64ac2d179a4e86e492c54f706027..2f7aaec2e5097ea443075fbd7809f97732bd53c5 100644 (file)
@@ -1454,6 +1454,9 @@ int link_reconfigure(Link *link, bool force) {
         if (r < 0)
                 return r;
 
+        if (force || link->state == LINK_STATE_FAILED)
+                link_set_state(link, LINK_STATE_INITIALIZED);
+
         return 1; /* 1 means the interface will be reconfigured. */
 }
 
@@ -1536,6 +1539,9 @@ int link_reconfigure_on_bus_method_reload(Link *link, sd_bus_message *message) {
         TAKE_PTR(data);
         link->manager->reloading++;
 
+        if (link->state == LINK_STATE_FAILED)
+                link_set_state(link, LINK_STATE_INITIALIZED);
+
         return 0;
 }