]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: drop managed configs on reconfigure when KeepConfiguration=yes 22496/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 13 Feb 2022 10:57:09 +0000 (19:57 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 13 Feb 2022 11:01:42 +0000 (20:01 +0900)
Otherwise, the managed configs, that is addresses, routes and so on
configured by the previously assigned .network file will not be dropped
on reconfiguring the interface.

src/network/networkd-link.c

index de21343854d335f7f2e0e2595f142cbf44fa2cd1..238b68579c5b72f415dc2dc9afdeb3963fce393e 100644 (file)
@@ -1240,10 +1240,13 @@ static int link_reconfigure_impl(Link *link, bool force) {
 
         link_drop_requests(link);
 
-        if (network && !force)
+        if (network && !force && network->keep_configuration != KEEP_CONFIGURATION_YES)
                 /* When a new/updated .network file is assigned, first make all configs (addresses,
                  * routes, and so on) foreign, and then drop unnecessary configs later by
-                 * link_drop_foreign_config() in link_configure(). */
+                 * link_drop_foreign_config() in link_configure().
+                 * Note, when KeepConfiguration=yes, link_drop_foreign_config() does nothing. Hence,
+                 * here we need to drop the configs such as addresses, routes, and so on configured by
+                 * the previously assigned .network file. */
                 link_foreignize_config(link);
         else {
                 /* Remove all managed configs. Note, foreign configs are removed in later by