]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
networkd: drop DHCPv4 config on stop, keep on restart, by default
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 1 Oct 2019 15:12:31 +0000 (17:12 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 2 Oct 2019 12:01:42 +0000 (14:01 +0200)
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.

man/systemd.network.xml
src/network/networkd-link.c
src/network/networkd-network.c

index e5f9d6f470652dcd2e82cc0eca03ca62ddfa7c34..cd86a4f4be51cd0538700465034453a6a6456706 100644 (file)
           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 <literal>dhcp</literal>
           implies <literal>dhcp-on-stop</literal>, and <literal>yes</literal> implies
-          <literal>dhcp</literal> and <literal>static</literal>. Defaults to
-          <literal>dhcp-on-stop</literal>.</para>
+          <literal>dhcp</literal> and <literal>static</literal>. Defaults to <literal>no</literal>.
+          </para>
         </listitem>
       </varlistentry>
 
index 4c0daa4802dc32f4c6eca3403add20759a14f04f..a23bddde9b67675fd3d948f8074f922950b2d166 100644 (file)
@@ -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");
index 23a21d8c9e82ebe490037b69971d02545c6705a4..a1f285b8e5c39b5b608e7fdc91d59942530a6d0f 100644 (file)
@@ -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)