From: Yu Watanabe Date: Sun, 13 Jun 2021 21:58:06 +0000 (+0900) Subject: network: drop configurations in the previous .network file when entering unmanaged... X-Git-Tag: v250-rc1~857^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cb71e9c6066a430a6c7ff503d3d3787e3d3a9f0e;p=thirdparty%2Fsystemd.git network: drop configurations in the previous .network file when entering unmanaged state When reconfiguring an interface and it will enter unmanaged state, let's drop configurations from the previously assigned .network file. --- diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index f8dee666a6d..8900534cd67 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -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);