Skip to content

Commit 8006035

Browse files
committed
networkd: drop DHCPv4 config on stop, keep on restart, by default
This partially reverts 95355a2. 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.
1 parent ab76be5 commit 8006035

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

man/systemd.network.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -876,8 +876,8 @@
876876
lease expires. This is contrary to the DHCP specification, but may be the best choice if,
877877
e.g., the root filesystem relies on this connection. The setting <literal>dhcp</literal>
878878
implies <literal>dhcp-on-stop</literal>, and <literal>yes</literal> implies
879-
<literal>dhcp</literal> and <literal>static</literal>. Defaults to
880-
<literal>dhcp-on-stop</literal>.</para>
879+
<literal>dhcp</literal> and <literal>static</literal>. Defaults to <literal>no</literal>.
880+
</para>
881881
</listitem>
882882
</varlistentry>
883883

src/network/networkd-link.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,12 @@ int link_stop_clients(Link *link, bool may_keep_dhcp) {
770770

771771
dhcp4_release_old_lease(link);
772772

773-
if (link->dhcp_client && (!may_keep_dhcp || !link->network ||
774-
!FLAGS_SET(link->network->keep_configuration, KEEP_CONFIGURATION_DHCP_ON_STOP))) {
773+
bool keep_dhcp = may_keep_dhcp &&
774+
link->network &&
775+
(link->manager->restarting ||
776+
FLAGS_SET(link->network->keep_configuration, KEEP_CONFIGURATION_DHCP_ON_STOP));
777+
778+
if (link->dhcp_client && !keep_dhcp) {
775779
k = sd_dhcp_client_stop(link->dhcp_client);
776780
if (k < 0)
777781
r = log_link_warning_errno(link, k, "Could not stop DHCPv4 client: %m");

src/network/networkd-network.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,11 @@ int network_verify(Network *network) {
268268
/* CriticalConnection=yes also preserve foreign static configurations. */
269269
network->keep_configuration = KEEP_CONFIGURATION_YES;
270270
else
271-
/* For backward compatibility, we do not release DHCP addresses on manager stop. */
272-
network->keep_configuration = KEEP_CONFIGURATION_DHCP_ON_STOP;
271+
network->keep_configuration = KEEP_CONFIGURATION_NO;
273272
}
274273

275274
if (network->keep_configuration < 0)
276-
/* For backward compatibility, we do not release DHCP addresses on manager stop. */
277-
network->keep_configuration = KEEP_CONFIGURATION_DHCP_ON_STOP;
275+
network->keep_configuration = KEEP_CONFIGURATION_NO;
278276

279277
LIST_FOREACH_SAFE(addresses, address, address_next, network->static_addresses)
280278
if (address_section_verify(address) < 0)

0 commit comments

Comments
 (0)