From: Zbigniew Jędrzejewski-Szmek Date: Tue, 1 Oct 2019 15:12:31 +0000 (+0200) Subject: networkd: drop DHCPv4 config on stop, keep on restart, by default X-Git-Tag: v244-rc1~234^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=800603524a7ab076d40450286ff7802a04289b7f;p=thirdparty%2Fsystemd.git networkd: drop DHCPv4 config on stop, keep on restart, by default This partially reverts 95355a281c06c5970b7355c38b066910c3be4958. It seems that other parts of link_stop_clients() should be skipped when restarting, but I don't know enough about those other clients to have an opinion if it is better to stop&start them on restart or not. Anyway, that can be done in later patches now that the support for restarts is there. Fixes #13625. --- diff --git a/man/systemd.network.xml b/man/systemd.network.xml index e5f9d6f4706..cd86a4f4be5 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -876,8 +876,8 @@ lease expires. This is contrary to the DHCP specification, but may be the best choice if, e.g., the root filesystem relies on this connection. The setting dhcp implies dhcp-on-stop, and yes implies - dhcp and static. Defaults to - dhcp-on-stop. + dhcp and static. Defaults to no. + diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 4c0daa4802d..a23bddde9b6 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -770,8 +770,12 @@ int link_stop_clients(Link *link, bool may_keep_dhcp) { dhcp4_release_old_lease(link); - if (link->dhcp_client && (!may_keep_dhcp || !link->network || - !FLAGS_SET(link->network->keep_configuration, KEEP_CONFIGURATION_DHCP_ON_STOP))) { + bool keep_dhcp = may_keep_dhcp && + link->network && + (link->manager->restarting || + FLAGS_SET(link->network->keep_configuration, KEEP_CONFIGURATION_DHCP_ON_STOP)); + + if (link->dhcp_client && !keep_dhcp) { k = sd_dhcp_client_stop(link->dhcp_client); if (k < 0) r = log_link_warning_errno(link, k, "Could not stop DHCPv4 client: %m"); diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 23a21d8c9e8..a1f285b8e5c 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -268,13 +268,11 @@ int network_verify(Network *network) { /* CriticalConnection=yes also preserve foreign static configurations. */ network->keep_configuration = KEEP_CONFIGURATION_YES; else - /* For backward compatibility, we do not release DHCP addresses on manager stop. */ - network->keep_configuration = KEEP_CONFIGURATION_DHCP_ON_STOP; + network->keep_configuration = KEEP_CONFIGURATION_NO; } if (network->keep_configuration < 0) - /* For backward compatibility, we do not release DHCP addresses on manager stop. */ - network->keep_configuration = KEEP_CONFIGURATION_DHCP_ON_STOP; + network->keep_configuration = KEEP_CONFIGURATION_NO; LIST_FOREACH_SAFE(addresses, address, address_next, network->static_addresses) if (address_section_verify(address) < 0)