summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-02-14 15:45:29 +0100
committerThomas Haller <thaller@redhat.com>2018-02-15 16:23:20 +0100
commitf5bedd3655140e51020de720db576045281413be (patch)
tree3d2e6576863a5f3587be955770a838084744bb8d
parent7de078a3940ec31bca553aced4e5d56bdc5c661c (diff)
downloadNetworkManager-f5bedd3655140e51020de720db576045281413be.tar.gz
device: make ipv4.dhcp-client-id configurable via a global default
-rw-r--r--clients/common/settings-docs.h.in2
-rw-r--r--libnm-core/nm-setting-ip4-config.c3
-rw-r--r--man/NetworkManager.conf.xml3
-rw-r--r--src/devices/nm-device.c8
4 files changed, 15 insertions, 1 deletions
diff --git a/clients/common/settings-docs.h.in b/clients/common/settings-docs.h.in
index 4a295a4877..c7c9cc29ed 100644
--- a/clients/common/settings-docs.h.in
+++ b/clients/common/settings-docs.h.in
@@ -211,7 +211,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 3 seconds). A value greater than zero is a timeout in milliseconds.")
-#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.")
+#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. If unset, a globally configurable default is used. If still unset, the client-id from the last lease may be reused.")
#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 74c19b6a1c..a4e01c1675 100644
--- a/libnm-core/nm-setting-ip4-config.c
+++ b/libnm-core/nm-setting-ip4-config.c
@@ -719,6 +719,9 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *ip4_class)
* 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.
+ *
+ * If unset, a globally configurable default is used. If still unset, the
+ * client-id from the last lease may be reused.
**/
/* ---ifcfg-rh---
* property: dhcp-client-id
diff --git a/man/NetworkManager.conf.xml b/man/NetworkManager.conf.xml
index 074ddc0de1..9151b2414d 100644
--- a/man/NetworkManager.conf.xml
+++ b/man/NetworkManager.conf.xml
@@ -686,6 +686,9 @@ ipv6.ip6-privacy=0
<term><varname>ipv4.dad-timeout</varname></term>
</varlistentry>
<varlistentry>
+ <term><varname>ipv4.dhcp-client-id</varname></term>
+ </varlistentry>
+ <varlistentry>
<term><varname>ipv4.dhcp-timeout</varname></term>
<listitem><para>If left unspecified, the default value for
the interface type is used.</para></listitem>
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index fb6c980c04..7cdc0d4427 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -6398,10 +6398,18 @@ dhcp4_get_client_id (NMDevice *self, NMConnection *connection)
{
NMSettingIPConfig *s_ip4;
const char *client_id;
+ gs_free char *client_id_default = NULL;
s_ip4 = nm_connection_get_setting_ip4_config (connection);
client_id = nm_setting_ip4_config_get_dhcp_client_id (NM_SETTING_IP4_CONFIG (s_ip4));
+ if (!client_id) {
+ client_id_default = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
+ "ipv4.dhcp-client-id", self);
+ if (client_id_default && client_id_default[0])
+ client_id = client_id_default;
+ }
+
return client_id
? nm_dhcp_utils_client_id_string_to_bytes (client_id)
: NULL;