From 07c160a65c16245bdc1fe8adee8c89370b149d39 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 13 Feb 2022 19:54:09 +0900 Subject: [PATCH 1/2] network: drop redundant condition The function `link_drop_foreign_addresses()` is only called in `link_drop_foreign_config()`, and the same condition is located in the caller. --- src/network/networkd-address.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index b083b632b1..35142093dd 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -848,10 +848,6 @@ int link_drop_foreign_addresses(Link *link) { assert(link); assert(link->network); - /* Keep all addresses when KeepConfiguration=yes. */ - if (link->network->keep_configuration == KEEP_CONFIGURATION_YES) - return 0; - /* First, mark all addresses. */ SET_FOREACH(address, link->addresses) { /* We consider IPv6LL addresses to be managed by the kernel, or dropped in link_drop_ipv6ll_addresses() */ From 81db4f3dd8cd5300b203379443091f4b462b5a29 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 13 Feb 2022 19:57:09 +0900 Subject: [PATCH 2/2] network: drop managed configs on reconfigure when KeepConfiguration=yes 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 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index de21343854..238b68579c 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -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