summaryrefslogtreecommitdiff
path: root/src/dhcp-manager/nm-dhcp-client.c
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-11-03 14:39:25 -0600
committerDan Williams <dcbw@redhat.com>2014-11-07 11:23:30 -0600
commitb4999f8811d90dbb191b7d9b37e02a6379f98ea4 (patch)
treed80ec6a4648714cb639eab04cf85b56e444ec736 /src/dhcp-manager/nm-dhcp-client.c
parentda20334caf6a30a394f95e630d41ff3d8ef270ce (diff)
downloadNetworkManager-b4999f8811d90dbb191b7d9b37e02a6379f98ea4.tar.gz
dhcp: preserve DHCPv4 client ID for later use
If we can, read the existing client ID from the leasefile and preserve it for later use.
Diffstat (limited to 'src/dhcp-manager/nm-dhcp-client.c')
-rw-r--r--src/dhcp-manager/nm-dhcp-client.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/dhcp-manager/nm-dhcp-client.c b/src/dhcp-manager/nm-dhcp-client.c
index d6e308b959..0315539e7c 100644
--- a/src/dhcp-manager/nm-dhcp-client.c
+++ b/src/dhcp-manager/nm-dhcp-client.c
@@ -45,6 +45,7 @@ typedef struct {
guint32 priority;
guint32 timeout;
GByteArray * duid;
+ GBytes * client_id;
NMDhcpState state;
pid_t pid;
@@ -143,6 +144,29 @@ nm_dhcp_client_get_priority (NMDhcpClient *self)
return NM_DHCP_CLIENT_GET_PRIVATE (self)->priority;
}
+GBytes *
+nm_dhcp_client_get_client_id (NMDhcpClient *self)
+{
+ g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), NULL);
+
+ return NM_DHCP_CLIENT_GET_PRIVATE (self)->client_id;
+}
+
+void
+nm_dhcp_client_set_client_id (NMDhcpClient *self, GBytes *client_id)
+{
+ NMDhcpClientPrivate *priv;
+
+ g_return_if_fail (NM_IS_DHCP_CLIENT (self));
+
+ priv = NM_DHCP_CLIENT_GET_PRIVATE (self);
+
+ if (priv->client_id && g_bytes_equal (priv->client_id, client_id))
+ return;
+ g_clear_pointer (&priv->client_id, g_bytes_unref);
+ priv->client_id = client_id ? g_bytes_ref (client_id) : NULL;
+}
+
/********************************************/
static const char *state_table[NM_DHCP_STATE_MAX + 1] = {
@@ -374,7 +398,10 @@ nm_dhcp_client_start_ip4 (NMDhcpClient *self,
nm_log_info (LOGD_DHCP, "Activation (%s) Beginning DHCPv4 transaction (timeout in %d seconds)",
priv->iface, priv->timeout);
- return NM_DHCP_CLIENT_GET_CLASS (self)->ip4_start (self, dhcp_client_id, dhcp_anycast_addr, hostname);
+ if (dhcp_client_id)
+ nm_dhcp_client_set_client_id (self, nm_dhcp_utils_client_id_string_to_bytes (dhcp_client_id));
+
+ return NM_DHCP_CLIENT_GET_CLASS (self)->ip4_start (self, dhcp_anycast_addr, hostname);
}
/* uuid_parse does not work for machine-id, so we use our own converter */