]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: drop configurations in the previous .network file when entering unmanaged...
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 13 Jun 2021 21:58:06 +0000 (06:58 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 10 Aug 2021 05:44:39 +0000 (14:44 +0900)
When reconfiguring an interface and it will enter unmanaged state,
let's drop configurations from the previously assigned .network file.

src/network/networkd-link.c

index f8dee666a6d6ce802302d18d33690ef291d3824d..8900534cd675aea36208b32dee7cd8b68098dda1 100644 (file)
@@ -1235,23 +1235,22 @@ static int link_get_network(Link *link, Network **ret) {
 }
 
 static int link_reconfigure_impl(Link *link, bool force) {
-        Network *network;
+        Network *network = NULL;
         int r;
 
         assert(link);
 
         r = link_get_network(link, &network);
-        if (r == -ENOENT) {
-                link_set_state(link, LINK_STATE_UNMANAGED);
-                return 0;
-        }
-        if (r < 0)
+        if (r < 0 && r != -ENOENT)
                 return r;
 
         if (link->network == network && !force)
                 return 0;
 
-        log_link_info(link, "Re-configuring with %s", network->filename);
+        if (network)
+                log_link_info(link, "Reconfiguring with %s.", network->filename);
+        else
+                log_link_info(link, "Unmanaging interface.");
 
         /* Dropping old .network file */
         r = link_stop_engines(link, false);
@@ -1269,6 +1268,11 @@ static int link_reconfigure_impl(Link *link, bool force) {
         link->network = network_unref(link->network);
         link_unref(set_remove(link->manager->links_requesting_uuid, link));
 
+        if (!network) {
+                link_set_state(link, LINK_STATE_UNMANAGED);
+                return 0;
+        }
+
         /* Then, apply new .network file */
         link->network = network_ref(network);
         link_update_operstate(link, true);