dhcp: allow the plugin to be restarted

In the next commit, a mechanism will be added to stop the DHCP plugin
and restart it without destroying the NMDhcpClient object. For this to
work, we must reset some members of the object when stopping or
starting the plugin.
This commit is contained in:
Beniamino Galvani
2024-10-08 11:30:20 +02:00
parent b6676aa8ef
commit 1db882ca63
2 changed files with 4 additions and 3 deletions

View File

@@ -1360,6 +1360,8 @@ nm_dhcp_client_start(NMDhcpClient *self, GError **error)
g_return_val_if_fail(priv->config.uuid, FALSE);
nm_assert(!priv->effective_client_id);
priv->is_stopped = FALSE;
IS_IPv4 = NM_IS_IPv4(priv->config.addr_family);
if (!IS_IPv4) {
@@ -1473,6 +1475,7 @@ nm_dhcp_client_stop(NMDhcpClient *self, gboolean release)
if (priv->is_stopped)
return;
nm_clear_pointer(&priv->effective_client_id, g_bytes_unref);
nm_clear_g_source_inst(&priv->previous_lease_timeout_source);
priv->is_stopped = TRUE;
@@ -1980,8 +1983,6 @@ dispose(GObject *object)
nm_clear_g_source_inst(&priv->v6.dad_timeout_source);
}
nm_clear_pointer(&priv->effective_client_id, g_bytes_unref);
nm_assert(!priv->watch_source);
nm_assert(!priv->l3cd_next);
nm_assert(!priv->l3cd_curr);

View File

@@ -1323,7 +1323,7 @@ ip4_start(NMDhcpClient *client, GError **error)
g_return_val_if_fail(!priv->probe, FALSE);
g_return_val_if_fail(client_config, FALSE);
if (!nettools_create(self, &effective_client_id, error))
if (!priv->client && !nettools_create(self, &effective_client_id, error))
return FALSE;
r = n_dhcp4_client_probe_config_new(&config);