Commit f054c3fc authored by Francesco Giudici's avatar Francesco Giudici

dhcp: allow to skip DUID search from DHCP client global configuration

When the used client is dhclient we were used to search for DUID not
only in the specific lease files generated by NetworkManager, but also
in the global lease file generated outside NetworkManager.
Keep this capability but allow to just search in the NM lease files if
a value different from the default one is specified in dhcp-duid.
parent 0d841e74
......@@ -513,7 +513,7 @@ nm_dhcp_client_start_ip4 (NMDhcpClient *self,
}
static GBytes *
get_duid (NMDhcpClient *self)
get_duid (NMDhcpClient *self, gboolean global)
{
return NULL;
}
......@@ -541,19 +541,14 @@ nm_dhcp_client_start_ip6 (NMDhcpClient *self,
nm_assert (!priv->duid);
nm_assert (client_id);
switch (enforce_duid) {
case NM_DHCP_DUID_ENFORCE_NEVER:
case NM_DHCP_DUID_ENFORCE_LEASE_FALLBACK:
priv->duid = NM_DHCP_CLIENT_GET_CLASS (self)->get_duid (self);
if (priv->duid)
break;
/* fall through */
case NM_DHCP_DUID_ENFORCE_ALWAYS:
if (enforce_duid == NM_DHCP_DUID_ENFORCE_NEVER)
priv->duid = NM_DHCP_CLIENT_GET_CLASS (self)->get_duid (self, TRUE);
else if (enforce_duid == NM_DHCP_DUID_ENFORCE_LEASE_FALLBACK)
priv->duid = NM_DHCP_CLIENT_GET_CLASS (self)->get_duid (self, FALSE);
/* NM_DHCP_DUID_ENFORCE_ALWAYS and fallback */
if (!priv->duid)
priv->duid = g_bytes_ref (client_id);
break;
default:
nm_assert_not_reached ();
}
_LOGD ("DUID is '%s'", (str = nm_dhcp_utils_duid_to_string (priv->duid)));
......
......@@ -96,13 +96,15 @@ typedef struct {
/**
* get_duid:
* @self: the #NMDhcpClient
* @global: if set to #true, the duid should be searched also in the
* DHCP client's system-wide persistent configuration.
*
* Attempts to find an existing DHCPv6 DUID for this client in the DHCP
* client's persistent configuration. Returned DUID should be the binary
* representation of the DUID. If no DUID is found, %NULL should be
* returned.
*/
GBytes *(*get_duid) (NMDhcpClient *self);
GBytes *(*get_duid) (NMDhcpClient *self, gboolean global);
/* Signals */
void (*state_changed) (NMDhcpClient *self,
......
......@@ -582,7 +582,7 @@ state_changed (NMDhcpClient *client,
}
static GBytes *
get_duid (NMDhcpClient *client)
get_duid (NMDhcpClient *client, gboolean global)
{
NMDhcpDhclient *self = NM_DHCP_DHCLIENT (client);
NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self);
......@@ -607,7 +607,7 @@ get_duid (NMDhcpClient *client)
g_free (leasefile);
}
if (!duid) {
if (!duid && global) {
/* Otherwise read the default machine-wide DUID */
_LOGD ("looking for default DUID in '%s'", priv->def_leasefile);
duid = nm_dhcp_dhclient_read_duid (priv->def_leasefile, &error);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment