summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-11-02 17:05:03 +0100
committerThomas Haller <thaller@redhat.com>2018-11-13 19:09:34 +0100
commit8861ac2976795e05aa6a5f5e6c822977bf950ed3 (patch)
tree7e80f5c18259b48522ff06d651dc2ab30f8ef595
parentdfdd4e3bd36057860460578cd8a677b35d15a101 (diff)
downloadNetworkManager-8861ac2976795e05aa6a5f5e6c822977bf950ed3.tar.gz
dhcp: add "ipv4.dhcp-client-id=duid" setting
Add a new mode for the DHCPv4 client identifier. "duid" is what the internal (systemd) DHCP client already does by default. It is also the same as used by systemd-networkd's "ClientIdentifier=duid" setting. What we still lack (compared to networkd) are a way to overwrite IAID and the DUID. Previously, this mode was used by the internal DHCP plugin by default. However, it could not be explicitly configured. In general, our default values should also be explicitly selectable. Now the "duid" client identifier can also be used with the "dhclient" plugin.
-rw-r--r--clients/common/settings-docs.h.in2
-rw-r--r--libnm-core/nm-setting-ip4-config.c3
-rw-r--r--src/devices/nm-device.c6
3 files changed, 10 insertions, 1 deletions
diff --git a/clients/common/settings-docs.h.in b/clients/common/settings-docs.h.in
index 1e63df32cc..e66f906315 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 you set the stable-id, you may want to include the \"${DEVICE}\" or \"{$MAC}\" specifier to get a per-device 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_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 \"duid\" generates a RFC4361-compliant client identifier based on a hash of the interface name as IAID and /etc/machine-id. 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 you set the stable-id, you may want to include the \"${DEVICE}\" or \"{$MAC}\" specifier to get a per-device 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 008b0f16cf..38056abc94 100644
--- a/libnm-core/nm-setting-ip4-config.c
+++ b/libnm-core/nm-setting-ip4-config.c
@@ -721,6 +721,9 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *klass)
* with type ethernet (01). Currently, these options only work for ethernet
* type of links.
*
+ * The special value "duid" generates a RFC4361-compliant client identifier based
+ * on a hash of the interface name as IAID and /etc/machine-id.
+ *
* 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 you set the
* stable-id, you may want to include the "${DEVICE}" or "{$MAC}" specifier to get a
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 862eb60c7c..82dd4482c1 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -7587,6 +7587,12 @@ dhcp4_get_client_id (NMDevice *self,
goto out_good;
}
+ if (nm_streq (client_id, "duid")) {
+ result = nm_utils_dhcp_client_id_systemd_node_specific (TRUE,
+ nm_device_get_ip_iface (self));
+ goto out_good;
+ }
+
if (nm_streq (client_id, "stable")) {
nm_auto_free_checksum GChecksum *sum = NULL;
guint8 digest[NM_UTILS_CHECKSUM_LENGTH_SHA1];