summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-10-29 12:47:27 +0100
committerThomas Haller <thaller@redhat.com>2018-11-13 19:09:34 +0100
commit5b9bc174d1f53c51a5afabd862fe859a4b4bbe62 (patch)
tree8d338f5283a60be4601e54682b7c74cc3c9c8a35
parentc3e7e6170dae14d553e650d9bd1d8b449e936f90 (diff)
downloadNetworkManager-5b9bc174d1f53c51a5afabd862fe859a4b4bbe62.tar.gz
dhcp: don't load IPv4 client-id from lease file
The client-id is something that we want to determine top-down. Meaning, if the user specifies it via ipv4.dhcp-client-id, then it should be used. If the user leaves it unspecified, we choose a default stable client-id. For the internal DHCP plugin, this is a node specific client-id based on - the predictable interface name - and /etc/machine-id It's not clear, why we should allow specifying the client-id in the lease file as a third source of configuration. It really pushes the configuration first down (when we do DHCP without lease file), to store an additional bit of configuration for future DHCP attempts. If the machine-id or the interface-name changes, then so does the default client-id. In this case, also "ipv4.dhcp-client-id=stable" changes. It's fair to require that the user keeps the machine-id stable, if the machine identity doesn't change. Also, the lease files are stored in /var/lib/NetworkManager, which is more volatile than /etc/machine-id. So, if we think that machine-id and interface-name is not stable, why would we assume that we have a suitable lease file? Also, if you do: nmcli connection add con-name "$PROFILE" ... ipv4.dhcp-client-id '' nmcli connection up $PROFILE nmcli connection modify "$PROFILE" ipv4.dhcp-client-id mac nmcli connection up $PROFILE nmcli connection modify "$PROFILE" ipv4.dhcp-client-id '' nmcli connection up $PROFILE wouldn't you expect that the original (default) client-id is used again? Also, this works badly with global connection defaults in NetworkManager.conf. If you configure a connection default, previously already this would always force the client-id and overrule the lease. That is reasonable, but in which case would you ever want to use the client-id from the lease?
-rw-r--r--clients/common/settings-docs.h.in2
-rw-r--r--libnm-core/nm-setting-ip4-config.c4
-rw-r--r--src/dhcp/nm-dhcp-systemd.c15
3 files changed, 3 insertions, 18 deletions
diff --git a/clients/common/settings-docs.h.in b/clients/common/settings-docs.h.in
index d9ab10f049..8ce156e112 100644
--- a/clients/common/settings-docs.h.in
+++ b/clients/common/settings-docs.h.in
@@ -197,7 +197,7 @@
#define DESCRIBE_DOC_NM_SETTING_IP_TUNNEL_TTL N_("The TTL to assign to tunneled packets. 0 is a special value meaning that packets inherit the TTL value.")
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_ADDRESSES N_("Array of IP addresses.")
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DAD_TIMEOUT N_("Timeout in milliseconds used to check for the presence of duplicate IP addresses on the network. If an address conflict is detected, the activation will fail. A zero value means that no duplicate address detection is performed, -1 means the default value (either configuration ipvx.dad-timeout override or zero). A value greater than zero is a timeout in milliseconds. The property is currently implemented only for IPv4.")
-#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID N_("A string sent to the DHCP server to identify the local machine which the DHCP server may use to customize the DHCP lease and options. When the property is a hex string ('aa:bb:cc') it is interpreted as a binary client ID, in which case the first byte is assumed to be the 'type' field as per RFC 2132 section 9.14 and the remaining bytes may be an hardware address (e.g. '01:xx:xx:xx:xx:xx:xx' where 1 is the Ethernet ARP type and the rest is a MAC address). If the property is not a hex string it is considered as a non-hardware-address client ID and the 'type' field is set to 0. The special values \"mac\" and \"perm-mac\" are supported, which use the current or permanent MAC address of the device to generate a client identifier with type ethernet (01). Currently, these options only work for ethernet type of links. The special value \"stable\" is supported to generate a type 0 client identifier based on the stable-id (see connection.stable-id) and a per-host key. If unset, a globally configured default is used. If still unset, the client-id from the last lease is reused.")
+#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID N_("A string sent to the DHCP server to identify the local machine which the DHCP server may use to customize the DHCP lease and options. When the property is a hex string ('aa:bb:cc') it is interpreted as a binary client ID, in which case the first byte is assumed to be the 'type' field as per RFC 2132 section 9.14 and the remaining bytes may be an hardware address (e.g. '01:xx:xx:xx:xx:xx:xx' where 1 is the Ethernet ARP type and the rest is a MAC address). If the property is not a hex string it is considered as a non-hardware-address client ID and the 'type' field is set to 0. The special values \"mac\" and \"perm-mac\" are supported, which use the current or permanent MAC address of the device to generate a client identifier with type ethernet (01). Currently, these options only work for ethernet type of links. The special value \"stable\" is supported to generate a type 0 client identifier based on the stable-id (see connection.stable-id) and a per-host key. If unset, a globally configured default is used. If still unset, the default depends on the DHCP plugin.")
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_FQDN N_("If the \"dhcp-send-hostname\" property is TRUE, then the specified FQDN will be sent to the DHCP server when acquiring a lease. This property and \"dhcp-hostname\" are mutually exclusive and cannot be set at the same time.")
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME N_("If the \"dhcp-send-hostname\" property is TRUE, then the specified name will be sent to the DHCP server when acquiring a lease. This property and \"dhcp-fqdn\" are mutually exclusive and cannot be set at the same time.")
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME N_("If TRUE, a hostname is sent to the DHCP server when acquiring a lease. Some DHCP servers use this hostname to update DNS databases, essentially providing a static hostname for the computer. If the \"dhcp-hostname\" property is NULL and this property is TRUE, the current persistent hostname of the computer is sent.")
diff --git a/libnm-core/nm-setting-ip4-config.c b/libnm-core/nm-setting-ip4-config.c
index 19f1cc8d40..686a50b044 100644
--- a/libnm-core/nm-setting-ip4-config.c
+++ b/libnm-core/nm-setting-ip4-config.c
@@ -724,8 +724,8 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *klass)
* The special value "stable" is supported to generate a type 0 client identifier based
* on the stable-id (see connection.stable-id) and a per-host key.
*
- * If unset, a globally configured default is used. If still unset, the
- * client-id from the last lease is reused.
+ * If unset, a globally configured default is used. If still unset, the default
+ * depends on the DHCP plugin.
**/
/* ---ifcfg-rh---
* property: dhcp-client-id
diff --git a/src/dhcp/nm-dhcp-systemd.c b/src/dhcp/nm-dhcp-systemd.c
index f8b7ad4675..655db15658 100644
--- a/src/dhcp/nm-dhcp-systemd.c
+++ b/src/dhcp/nm-dhcp-systemd.c
@@ -661,17 +661,6 @@ ip4_start (NMDhcpClient *client,
}
client_id = nm_dhcp_client_get_client_id (client);
- if ( !client_id
- && lease) {
- r = sd_dhcp_lease_get_client_id (lease,
- (const void **) &client_id_arr,
- &client_id_len);
- if ( r >= 0
- && client_id_len >= 2) {
- client_id_new = g_bytes_new (client_id_arr, client_id_len);
- client_id = client_id_new;
- }
- }
if (!client_id) {
client_id_new = nm_utils_dhcp_client_id_systemd_node_specific (TRUE,
nm_dhcp_client_get_iface (client));
@@ -900,7 +889,6 @@ ip6_start (NMDhcpClient *client,
{
NMDhcpSystemd *self = NM_DHCP_SYSTEMD (client);
NMDhcpSystemdPrivate *priv = NM_DHCP_SYSTEMD_GET_PRIVATE (self);
- const char *iface = nm_dhcp_client_get_iface (client);
GBytes *hwaddr;
const char *hostname;
int r, i;
@@ -918,9 +906,6 @@ ip6_start (NMDhcpClient *client,
if (!duid_arr || duid_len < 2)
g_return_val_if_reached (FALSE);
- g_free (priv->lease_file);
- priv->lease_file = get_leasefile_path (AF_INET6, iface, nm_dhcp_client_get_uuid (client));
-
r = sd_dhcp6_client_new (&priv->client6);
if (r < 0) {
nm_utils_error_set_errno (error, r, "failed to create dhcp-client: %s");