mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-04 05:10:17 +01:00
merge: branch 'bg/dhcp-iaid-rh1749358'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/315 https://bugzilla.redhat.com/show_bug.cgi?id=1749358
This commit is contained in:
commit
3165fd8e8e
24 changed files with 1281 additions and 685 deletions
|
|
@ -5639,6 +5639,9 @@ static const NMMetaPropertyInfo *const property_infos_IP4_CONFIG[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID,
|
||||
.property_type = &_pt_gobject_string,
|
||||
),
|
||||
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DHCP_IAID, DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_IAID,
|
||||
.property_type = &_pt_gobject_string,
|
||||
),
|
||||
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DHCP_TIMEOUT, DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT,
|
||||
.property_type = &_pt_gobject_int,
|
||||
.property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (gobject_int,
|
||||
|
|
@ -5884,6 +5887,9 @@ static const NMMetaPropertyInfo *const property_infos_IP6_CONFIG[] = {
|
|||
PROPERTY_INFO (NM_SETTING_IP6_CONFIG_DHCP_DUID, DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DHCP_DUID,
|
||||
.property_type = &_pt_gobject_string,
|
||||
),
|
||||
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DHCP_IAID, DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DHCP_IAID,
|
||||
.property_type = &_pt_gobject_string,
|
||||
),
|
||||
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DHCP_SEND_HOSTNAME,
|
||||
.property_type = &_pt_gobject_bool,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -207,6 +207,7 @@
|
|||
#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_IAID N_("A string containing the \"Identity Association Identifier\" (IAID) used by the DHCP client. The property is a 32-bit decimal value or a special value among \"mac\", \"perm-mac\", \"ifname\" and \"stable\". When set to \"mac\" (or \"perm-mac\"), the last 4 bytes of the current (or permanent) MAC address are used as IAID. When set to \"ifname\", the IAID is computed by hashing the interface name. The special value \"stable\" can be used to generate an IAID based on the stable-id (see connection.stable-id), a per-host key and the interface name. When the property is unset, the value from global configuration is used; if no global default is set then the IAID is assumed to be \"ifname\". Note that at the moment this property is ignored for IPv6 by dhclient, which always derives the IAID from the MAC address.")
|
||||
#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.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT N_("A timeout for a DHCP transaction in seconds.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DNS N_("Array of IP addresses of DNS servers.")
|
||||
|
|
@ -227,6 +228,7 @@
|
|||
#define DESCRIBE_DOC_NM_SETTING_IP6_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_IP6_CONFIG_DHCP_DUID N_("A string containing the DHCPv6 Unique Identifier (DUID) used by the dhcp client to identify itself to DHCPv6 servers (RFC 3315). The DUID is carried in the Client Identifier option. If the property is a hex string ('aa:bb:cc') it is interpreted as a binary DUID and filled as an opaque value in the Client Identifier option. The special value \"lease\" will retrieve the DUID previously used from the lease file belonging to the connection. If no DUID is found and \"dhclient\" is the configured dhcp client, the DUID is searched in the system-wide dhclient lease file. If still no DUID is found, or another dhcp client is used, a global and permanent DUID-UUID (RFC 6355) will be generated based on the machine-id. The special values \"llt\" and \"ll\" will generate a DUID of type LLT or LL (see RFC 3315) based on the current MAC address of the device. In order to try providing a stable DUID-LLT, the time field will contain a constant timestamp that is used globally (for all profiles) and persisted to disk. The special values \"stable-llt\", \"stable-ll\" and \"stable-uuid\" will generate a DUID of the corresponding type, derived from the connection's stable-id and a per-host unique key. You may want to include the \"${DEVICE}\" or \"${MAC}\" specifier in the stable-id, in case this profile gets activated on multiple devices. So, the link-layer address of \"stable-ll\" and \"stable-llt\" will be a generated address derived from the stable id. The DUID-LLT time value in the \"stable-llt\" option will be picked among a static timespan of three years (the upper bound of the interval is the same constant timestamp used in \"llt\"). When the property is unset, the global value provided for \"ipv6.dhcp-duid\" is used. If no global value is provided, the default \"lease\" value is assumed.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP6_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_IP6_CONFIG_DHCP_IAID N_("A string containing the \"Identity Association Identifier\" (IAID) used by the DHCP client. The property is a 32-bit decimal value or a special value among \"mac\", \"perm-mac\", \"ifname\" and \"stable\". When set to \"mac\" (or \"perm-mac\"), the last 4 bytes of the current (or permanent) MAC address are used as IAID. When set to \"ifname\", the IAID is computed by hashing the interface name. The special value \"stable\" can be used to generate an IAID based on the stable-id (see connection.stable-id), a per-host key and the interface name. When the property is unset, the value from global configuration is used; if no global default is set then the IAID is assumed to be \"ifname\". Note that at the moment this property is ignored for IPv6 by dhclient, which always derives the IAID from the MAC address.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP6_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.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DHCP_TIMEOUT N_("A timeout for a DHCP transaction in seconds.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DNS N_("Array of IP addresses of DNS servers.")
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -872,4 +872,6 @@ gboolean nm_utils_connection_is_adhoc_wpa (NMConnection *connection);
|
|||
|
||||
const char *nm_utils_wifi_freq_to_band (guint32 freq);
|
||||
|
||||
gboolean _nm_utils_iaid_verify (const char *str, gint64 *out_value);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3584,6 +3584,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMSettingIPConfig,
|
|||
PROP_MAY_FAIL,
|
||||
PROP_DAD_TIMEOUT,
|
||||
PROP_DHCP_TIMEOUT,
|
||||
PROP_DHCP_IAID,
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -3606,6 +3607,7 @@ typedef struct {
|
|||
gboolean may_fail;
|
||||
int dad_timeout;
|
||||
int dhcp_timeout;
|
||||
char *dhcp_iaid;
|
||||
} NMSettingIPConfigPrivate;
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE (NMSettingIPConfig, nm_setting_ip_config, NM_TYPE_SETTING)
|
||||
|
|
@ -4860,6 +4862,25 @@ nm_setting_ip_config_get_dhcp_timeout (NMSettingIPConfig *setting)
|
|||
return NM_SETTING_IP_CONFIG_GET_PRIVATE (setting)->dhcp_timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_ip_config_get_dhcp_iaid:
|
||||
* @setting: the #NMSettingIPConfig
|
||||
*
|
||||
* Returns the value contained in the #NMSettingIPConfig:dhcp-iaid
|
||||
* property.
|
||||
*
|
||||
* Returns: the configured DHCP IAID (Identity Association Identifier)
|
||||
*
|
||||
* Since: 1.22
|
||||
**/
|
||||
const char *
|
||||
nm_setting_ip_config_get_dhcp_iaid (NMSettingIPConfig *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_IP_CONFIG (setting), NULL);
|
||||
|
||||
return NM_SETTING_IP_CONFIG_GET_PRIVATE (setting)->dhcp_iaid;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
verify_label (const char *label)
|
||||
{
|
||||
|
|
@ -5020,6 +5041,19 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
|
|||
}
|
||||
}
|
||||
|
||||
if ( priv->dhcp_iaid
|
||||
&& !_nm_utils_iaid_verify (priv->dhcp_iaid, NULL)) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("'%s' is not a valid IAID"),
|
||||
priv->dhcp_iaid);
|
||||
g_prefix_error (error, "%s.%s: ",
|
||||
nm_setting_get_name (setting),
|
||||
NM_SETTING_IP_CONFIG_DHCP_IAID);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->gateway && priv->never_default) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
|
|
@ -5286,6 +5320,9 @@ get_property (GObject *object, guint prop_id,
|
|||
case PROP_DHCP_TIMEOUT:
|
||||
g_value_set_int (value, nm_setting_ip_config_get_dhcp_timeout (setting));
|
||||
break;
|
||||
case PROP_DHCP_IAID:
|
||||
g_value_set_string (value, nm_setting_ip_config_get_dhcp_iaid (setting));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -5386,6 +5423,9 @@ set_property (GObject *object, guint prop_id,
|
|||
case PROP_DHCP_TIMEOUT:
|
||||
priv->dhcp_timeout = g_value_get_int (value);
|
||||
break;
|
||||
case PROP_DHCP_IAID:
|
||||
priv->dhcp_iaid = g_value_dup_string (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -5415,6 +5455,7 @@ finalize (GObject *object)
|
|||
g_free (priv->method);
|
||||
g_free (priv->gateway);
|
||||
g_free (priv->dhcp_hostname);
|
||||
g_free (priv->dhcp_iaid);
|
||||
|
||||
g_ptr_array_unref (priv->dns);
|
||||
g_ptr_array_unref (priv->dns_search);
|
||||
|
|
@ -5777,5 +5818,29 @@ nm_setting_ip_config_class_init (NMSettingIPConfigClass *klass)
|
|||
NM_SETTING_PARAM_FUZZY_IGNORE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMSettingIPConfig:dhcp-iaid:
|
||||
*
|
||||
* A string containing the "Identity Association Identifier" (IAID) used
|
||||
* by the DHCP client. The property is a 32-bit decimal value or a
|
||||
* special value among "mac", "perm-mac", "ifname" and "stable". When
|
||||
* set to "mac" (or "perm-mac"), the last 4 bytes of the current (or
|
||||
* permanent) MAC address are used as IAID. When set to "ifname", the
|
||||
* IAID is computed by hashing the interface name. The special value
|
||||
* "stable" can be used to generate an IAID based on the stable-id (see
|
||||
* connection.stable-id), a per-host key and the interface name. When
|
||||
* the property is unset, the value from global configuration is used;
|
||||
* if no global default is set then the IAID is assumed to be
|
||||
* "ifname". Note that at the moment this property is ignored for IPv6
|
||||
* by dhclient, which always derives the IAID from the MAC address.
|
||||
*
|
||||
* Since: 1.22
|
||||
**/
|
||||
obj_properties[PROP_DHCP_IAID] =
|
||||
g_param_spec_string (NM_SETTING_IP_CONFIG_DHCP_IAID, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -324,6 +324,7 @@ char *nm_ip_routing_rule_to_string (const NMIPRoutingRule *self,
|
|||
#define NM_SETTING_IP_CONFIG_MAY_FAIL "may-fail"
|
||||
#define NM_SETTING_IP_CONFIG_DAD_TIMEOUT "dad-timeout"
|
||||
#define NM_SETTING_IP_CONFIG_DHCP_TIMEOUT "dhcp-timeout"
|
||||
#define NM_SETTING_IP_CONFIG_DHCP_IAID "dhcp-iaid"
|
||||
|
||||
/* these are not real GObject properties. */
|
||||
#define NM_SETTING_IP_CONFIG_ROUTING_RULES "routing-rules"
|
||||
|
|
@ -456,6 +457,8 @@ NM_AVAILABLE_IN_1_2
|
|||
int nm_setting_ip_config_get_dad_timeout (NMSettingIPConfig *setting);
|
||||
NM_AVAILABLE_IN_1_2
|
||||
int nm_setting_ip_config_get_dhcp_timeout (NMSettingIPConfig *setting);
|
||||
NM_AVAILABLE_IN_1_22
|
||||
const char *nm_setting_ip_config_get_dhcp_iaid (NMSettingIPConfig *setting);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -6120,3 +6120,25 @@ _nm_utils_bridge_vlan_verify_list (GPtrArray *vlans,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_nm_utils_iaid_verify (const char *str, gint64 *out_value)
|
||||
{
|
||||
gint64 iaid;
|
||||
|
||||
NM_SET_OUT (out_value, -1);
|
||||
|
||||
if (!str || !str[0])
|
||||
return FALSE;
|
||||
|
||||
if (NM_IAID_IS_SPECIAL (str))
|
||||
return TRUE;
|
||||
|
||||
if ( NM_STRCHAR_ALL (str, ch, ch >= '0' && ch <= '9')
|
||||
&& (str[0] != '0' || str[1] == '\0')
|
||||
&& (iaid = _nm_utils_ascii_str_to_int64 (str, 10, 0, G_MAXUINT32, -1)) != -1) {
|
||||
NM_SET_OUT (out_value, iaid);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3051,6 +3051,7 @@ test_connection_diff_a_only (void)
|
|||
{ NM_SETTING_IP_CONFIG_MAY_FAIL, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_DAD_TIMEOUT, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_DNS_PRIORITY, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_DHCP_IAID, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NULL, NM_SETTING_DIFF_RESULT_UNKNOWN },
|
||||
} },
|
||||
};
|
||||
|
|
|
|||
|
|
@ -712,6 +712,10 @@ ipv6.ip6-privacy=0
|
|||
<varlistentry>
|
||||
<term><varname>ipv4.dhcp-client-id</varname></term>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ipv4.dhcp-iaid</varname></term>
|
||||
<listitem><para>If left unspecified, it defaults to "ifname".</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ipv4.dhcp-timeout</varname></term>
|
||||
<listitem><para>If left unspecified, the default value for
|
||||
|
|
@ -736,6 +740,10 @@ ipv6.ip6-privacy=0
|
|||
<term><varname>ipv6.dhcp-duid</varname></term>
|
||||
<listitem><para>If left unspecified, it defaults to "lease".</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ipv6.dhcp-iaid</varname></term>
|
||||
<listitem><para>If left unspecified, it defaults to "ifname".</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ipv6.dhcp-timeout</varname></term>
|
||||
<listitem><para>If left unspecified, the default value for
|
||||
|
|
|
|||
|
|
@ -41,6 +41,20 @@ NM_CLONED_MAC_IS_SPECIAL (const char *str)
|
|||
NM_CLONED_MAC_STABLE);
|
||||
}
|
||||
|
||||
#define NM_IAID_MAC "mac"
|
||||
#define NM_IAID_PERM_MAC "perm-mac"
|
||||
#define NM_IAID_IFNAME "ifname"
|
||||
#define NM_IAID_STABLE "stable"
|
||||
|
||||
static inline gboolean
|
||||
NM_IAID_IS_SPECIAL (const char *str)
|
||||
{
|
||||
return NM_IN_STRSET (str,
|
||||
NM_IAID_MAC,
|
||||
NM_IAID_PERM_MAC,
|
||||
NM_IAID_IFNAME,
|
||||
NM_IAID_STABLE);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif /* __NM_COMMON_MACROS_H__ */
|
||||
|
|
|
|||
|
|
@ -1347,6 +1347,7 @@ _get_stable_id (NMDevice *self,
|
|||
NM_PRINT_FMT_QUOTED (stable_type == NM_UTILS_STABLE_TYPE_GENERATED, " from \"", generated, "\"", ""));
|
||||
}
|
||||
|
||||
nm_assert (priv->current_stable_id);
|
||||
*out_stable_type = priv->current_stable_id_type;
|
||||
return priv->current_stable_id;
|
||||
}
|
||||
|
|
@ -7904,6 +7905,144 @@ get_dhcp_timeout (NMDevice *self, int addr_family)
|
|||
return timeout ?: NM_DHCP_TIMEOUT_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* dhcp_get_iaid:
|
||||
* @self: the #NMDevice
|
||||
* @addr_family: the address family
|
||||
* @connection: the connection
|
||||
* @out_is_explicit: on return, %TRUE if the user set a valid IAID in
|
||||
* the connection or in global configuration; %FALSE if the connection
|
||||
* property was empty and no valid global configuration was provided.
|
||||
*
|
||||
* Returns: a IAID value for this device and the given connection.
|
||||
*/
|
||||
static guint32
|
||||
dhcp_get_iaid (NMDevice *self,
|
||||
int addr_family,
|
||||
NMConnection *connection,
|
||||
gboolean *out_is_explicit)
|
||||
{
|
||||
NMSettingIPConfig *s_ip;
|
||||
const char *iaid_str;
|
||||
gs_free char *iaid_str_free = NULL;
|
||||
guint32 iaid;
|
||||
const char *iface;
|
||||
const char *fail_reason;
|
||||
gboolean is_explicit = TRUE;
|
||||
|
||||
s_ip = nm_connection_get_setting_ip_config (connection, addr_family);
|
||||
iaid_str = nm_setting_ip_config_get_dhcp_iaid (s_ip);
|
||||
if (!iaid_str) {
|
||||
iaid_str_free = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
|
||||
addr_family == AF_INET
|
||||
? NM_CON_DEFAULT ("ipv4.dhcp-iaid")
|
||||
: NM_CON_DEFAULT ("ipv6.dhcp-iaid"),
|
||||
self);
|
||||
iaid_str = iaid_str_free;
|
||||
if (!iaid_str) {
|
||||
iaid_str = NM_IAID_IFNAME;
|
||||
is_explicit = FALSE;
|
||||
} else if (!_nm_utils_iaid_verify (iaid_str, NULL)) {
|
||||
_LOGW (LOGD_DEVICE, "invalid global default '%s' for ipv%c.dhcp-iaid",
|
||||
iaid_str,
|
||||
nm_utils_addr_family_to_char (addr_family));
|
||||
iaid_str = NM_IAID_IFNAME;
|
||||
is_explicit = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (nm_streq0 (iaid_str, NM_IAID_MAC)) {
|
||||
const NMPlatformLink *pllink;
|
||||
|
||||
pllink = nm_platform_link_get (nm_device_get_platform (self),
|
||||
nm_device_get_ip_ifindex (self));
|
||||
if (!pllink || pllink->l_address.len < 4) {
|
||||
fail_reason = "invalid link-layer address";
|
||||
goto out_fail;
|
||||
}
|
||||
|
||||
/* @iaid is in native endianness. Use unaligned_read_be32()
|
||||
* so that the IAID for a given MAC address is the same on
|
||||
* BE and LE machines. */
|
||||
iaid = unaligned_read_be32 (&pllink->l_address.data[pllink->l_address.len - 4]);
|
||||
goto out_good;
|
||||
} else if (nm_streq0 (iaid_str, NM_IAID_PERM_MAC)) {
|
||||
guint8 hwaddr_buf[NM_UTILS_HWADDR_LEN_MAX];
|
||||
const char *hwaddr_str;
|
||||
gsize hwaddr_len;
|
||||
|
||||
hwaddr_str = nm_device_get_permanent_hw_address (self);
|
||||
if (!hwaddr_str) {
|
||||
fail_reason = "no permanent link-layer address";
|
||||
goto out_fail;
|
||||
}
|
||||
|
||||
if (!_nm_utils_hwaddr_aton (hwaddr_str, hwaddr_buf, sizeof (hwaddr_buf), &hwaddr_len))
|
||||
g_return_val_if_reached (0);
|
||||
|
||||
if (hwaddr_len < 4) {
|
||||
fail_reason = "invalid link-layer address";
|
||||
goto out_fail;
|
||||
}
|
||||
|
||||
iaid = unaligned_read_be32 (&hwaddr_buf[hwaddr_len - 4]);
|
||||
goto out_good;
|
||||
} else if (nm_streq (iaid_str, "stable")) {
|
||||
nm_auto_free_checksum GChecksum *sum = NULL;
|
||||
guint8 digest[NM_UTILS_CHECKSUM_LENGTH_SHA1];
|
||||
NMUtilsStableType stable_type;
|
||||
const char *stable_id;
|
||||
guint32 salted_header;
|
||||
const guint8 *host_id;
|
||||
gsize host_id_len;
|
||||
|
||||
stable_id = _get_stable_id (self, connection, &stable_type);
|
||||
salted_header = htonl (53390459 + stable_type);
|
||||
nm_utils_host_id_get (&host_id, &host_id_len);
|
||||
iface = nm_device_get_ip_iface (self);
|
||||
|
||||
sum = g_checksum_new (G_CHECKSUM_SHA1);
|
||||
g_checksum_update (sum, (const guchar *) &salted_header, sizeof (salted_header));
|
||||
g_checksum_update (sum, (const guchar *) stable_id, strlen (stable_id) + 1);
|
||||
g_checksum_update (sum, (const guchar *) iface, strlen (iface) + 1);
|
||||
g_checksum_update (sum, (const guchar *) host_id, host_id_len);
|
||||
nm_utils_checksum_get_digest (sum, digest);
|
||||
|
||||
iaid = unaligned_read_be32 (digest);
|
||||
goto out_good;
|
||||
} else if ((iaid = _nm_utils_ascii_str_to_int64 (iaid_str, 10, 0, G_MAXUINT32, -1)) != -1) {
|
||||
goto out_good;
|
||||
} else {
|
||||
iface = nm_device_get_ip_iface (self);
|
||||
iaid = nm_utils_create_dhcp_iaid (TRUE,
|
||||
(const guint8 *) iface,
|
||||
strlen (iface));
|
||||
goto out_good;
|
||||
}
|
||||
|
||||
out_fail:
|
||||
nm_assert (fail_reason);
|
||||
_LOGW ( addr_family == AF_INET
|
||||
? (LOGD_DEVICE | LOGD_DHCP4 | LOGD_IP4)
|
||||
: (LOGD_DEVICE | LOGD_DHCP6 | LOGD_IP6),
|
||||
"ipv%c.dhcp-iaid: failure to generate IAID: %s. Using interface-name based IAID",
|
||||
nm_utils_addr_family_to_char (addr_family), fail_reason);
|
||||
is_explicit = FALSE;
|
||||
iface = nm_device_get_ip_iface (self);
|
||||
iaid = nm_utils_create_dhcp_iaid (TRUE,
|
||||
(const guint8 *) iface,
|
||||
strlen (iface));
|
||||
out_good:
|
||||
_LOGD ( addr_family == AF_INET
|
||||
? (LOGD_DEVICE | LOGD_DHCP4 | LOGD_IP4)
|
||||
: (LOGD_DEVICE | LOGD_DHCP6 | LOGD_IP6),
|
||||
"ipv%c.dhcp-iaid: using %u (0x%08x) IAID (str: '%s', explicit %d)",
|
||||
nm_utils_addr_family_to_char (addr_family), iaid, iaid,
|
||||
iaid_str, is_explicit);
|
||||
NM_SET_OUT (out_is_explicit, is_explicit);
|
||||
return iaid;
|
||||
}
|
||||
|
||||
static GBytes *
|
||||
dhcp4_get_client_id (NMDevice *self,
|
||||
NMConnection *connection,
|
||||
|
|
@ -7980,8 +8119,10 @@ dhcp4_get_client_id (NMDevice *self,
|
|||
}
|
||||
|
||||
if (nm_streq (client_id, "duid")) {
|
||||
guint32 iaid = dhcp_get_iaid (self, AF_INET, connection, NULL);
|
||||
|
||||
result = nm_utils_dhcp_client_id_systemd_node_specific (TRUE,
|
||||
nm_device_get_ip_iface (self));
|
||||
iaid);
|
||||
goto out_good;
|
||||
}
|
||||
|
||||
|
|
@ -7995,11 +8136,7 @@ dhcp4_get_client_id (NMDevice *self,
|
|||
gsize host_id_len;
|
||||
|
||||
stable_id = _get_stable_id (self, connection, &stable_type);
|
||||
if (!stable_id)
|
||||
g_return_val_if_reached (NULL);
|
||||
|
||||
salted_header = htonl (2011610591 + stable_type);
|
||||
|
||||
nm_utils_host_id_get (&host_id, &host_id_len);
|
||||
|
||||
sum = g_checksum_new (G_CHECKSUM_SHA1);
|
||||
|
|
@ -8723,8 +8860,6 @@ dhcp6_get_duid (NMDevice *self, NMConnection *connection, GBytes *hwaddr, gboole
|
|||
} digest;
|
||||
|
||||
stable_id = _get_stable_id (self, connection, &stable_type);
|
||||
if (!stable_id)
|
||||
g_return_val_if_reached (NULL);
|
||||
|
||||
if (NM_IN_STRSET (duid, "stable-ll", "stable-llt")) {
|
||||
/* for stable LL/LLT DUIDs, we still need a hardware address to detect
|
||||
|
|
@ -8853,6 +8988,8 @@ dhcp6_start_with_link_ready (NMDevice *self, NMConnection *connection)
|
|||
gboolean enforce_duid = FALSE;
|
||||
const NMPlatformLink *pllink;
|
||||
GError *error = NULL;
|
||||
guint32 iaid;
|
||||
gboolean iaid_explicit;
|
||||
|
||||
const NMPlatformIP6Address *ll_addr = NULL;
|
||||
|
||||
|
|
@ -8877,6 +9014,8 @@ dhcp6_start_with_link_ready (NMDevice *self, NMConnection *connection)
|
|||
bcast_hwaddr = nmp_link_address_get_as_bytes (&pllink->l_broadcast);
|
||||
}
|
||||
|
||||
iaid = dhcp_get_iaid (self, AF_INET6, connection, &iaid_explicit);
|
||||
|
||||
duid = dhcp6_get_duid (self, connection, hwaddr, &enforce_duid);
|
||||
priv->dhcp6.client = nm_dhcp_manager_start_ip6 (nm_dhcp_manager_get (),
|
||||
nm_device_get_multi_index (self),
|
||||
|
|
@ -8892,6 +9031,8 @@ dhcp6_start_with_link_ready (NMDevice *self, NMConnection *connection)
|
|||
nm_setting_ip_config_get_dhcp_hostname (s_ip6),
|
||||
duid,
|
||||
enforce_duid,
|
||||
iaid,
|
||||
iaid_explicit,
|
||||
get_dhcp_timeout (self, AF_INET6),
|
||||
priv->dhcp_anycast_address,
|
||||
(priv->dhcp6.mode == NM_NDISC_DHCP_LEVEL_OTHERCONF) ? TRUE : FALSE,
|
||||
|
|
@ -9162,13 +9303,12 @@ check_and_add_ipv6ll_addr (NMDevice *self)
|
|||
const char *stable_id;
|
||||
|
||||
stable_id = _get_stable_id (self, connection, &stable_type);
|
||||
if ( !stable_id
|
||||
|| !nm_utils_ipv6_addr_set_stable_privacy (stable_type,
|
||||
&lladdr,
|
||||
nm_device_get_iface (self),
|
||||
stable_id,
|
||||
priv->linklocal6_dad_counter++,
|
||||
&error)) {
|
||||
if (!nm_utils_ipv6_addr_set_stable_privacy (stable_type,
|
||||
&lladdr,
|
||||
nm_device_get_iface (self),
|
||||
stable_id,
|
||||
priv->linklocal6_dad_counter++,
|
||||
&error)) {
|
||||
_LOGW (LOGD_IP6, "linklocal6: failed to generate an address: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
linklocal6_failed (self);
|
||||
|
|
@ -9822,7 +9962,6 @@ addrconf6_start (NMDevice *self, NMSettingIP6ConfigPrivacy use_tempaddr)
|
|||
g_assert (s_ip6);
|
||||
|
||||
stable_id = _get_stable_id (self, connection, &stable_type);
|
||||
g_assert (stable_id);
|
||||
priv->ndisc = nm_lndp_ndisc_new (nm_device_get_platform (self),
|
||||
nm_device_get_ip_ifindex (self),
|
||||
nm_device_get_ip_iface (self),
|
||||
|
|
@ -14981,7 +15120,7 @@ nm_device_spawn_iface_helper (NMDevice *self)
|
|||
g_ptr_array_add (argv, g_strdup (nm_connection_get_uuid (connection)));
|
||||
|
||||
stable_id = _get_stable_id (self, connection, &stable_type);
|
||||
if (stable_id && stable_type != NM_UTILS_STABLE_TYPE_UUID) {
|
||||
if (stable_type != NM_UTILS_STABLE_TYPE_UUID) {
|
||||
g_ptr_array_add (argv, g_strdup ("--stable-id"));
|
||||
g_ptr_array_add (argv, g_strdup_printf ("%d %s", (int) stable_type, stable_id));
|
||||
}
|
||||
|
|
@ -16269,12 +16408,10 @@ _hw_addr_get_cloned (NMDevice *self, NMConnection *connection, gboolean is_wifi,
|
|||
}
|
||||
|
||||
stable_id = _get_stable_id (self, connection, &stable_type);
|
||||
if (stable_id) {
|
||||
hw_addr_generated = nm_utils_hw_addr_gen_stable_eth (stable_type, stable_id,
|
||||
nm_device_get_ip_iface (self),
|
||||
nm_device_get_initial_hw_address (self),
|
||||
_get_generate_mac_address_mask_setting (self, connection, is_wifi, &generate_mac_address_mask_tmp));
|
||||
}
|
||||
hw_addr_generated = nm_utils_hw_addr_gen_stable_eth (stable_type, stable_id,
|
||||
nm_device_get_ip_iface (self),
|
||||
nm_device_get_initial_hw_address (self),
|
||||
_get_generate_mac_address_mask_setting (self, connection, is_wifi, &generate_mac_address_mask_tmp));
|
||||
if (!hw_addr_generated) {
|
||||
g_set_error (error,
|
||||
NM_DEVICE_ERROR,
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMDhcpClient,
|
|||
PROP_ROUTE_TABLE,
|
||||
PROP_TIMEOUT,
|
||||
PROP_UUID,
|
||||
PROP_IAID,
|
||||
PROP_IAID_EXPLICIT,
|
||||
PROP_HOSTNAME,
|
||||
);
|
||||
|
||||
|
|
@ -65,9 +67,11 @@ typedef struct _NMDhcpClientPrivate {
|
|||
guint32 route_table;
|
||||
guint32 route_metric;
|
||||
guint32 timeout;
|
||||
guint32 iaid;
|
||||
NMDhcpState state;
|
||||
bool info_only:1;
|
||||
bool use_fqdn:1;
|
||||
bool iaid_explicit:1;
|
||||
} NMDhcpClientPrivate;
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE (NMDhcpClient, nm_dhcp_client, G_TYPE_OBJECT)
|
||||
|
|
@ -186,6 +190,22 @@ nm_dhcp_client_get_timeout (NMDhcpClient *self)
|
|||
return NM_DHCP_CLIENT_GET_PRIVATE (self)->timeout;
|
||||
}
|
||||
|
||||
guint32
|
||||
nm_dhcp_client_get_iaid (NMDhcpClient *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), 0);
|
||||
|
||||
return NM_DHCP_CLIENT_GET_PRIVATE (self)->iaid;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_dhcp_client_get_iaid_explicit (NMDhcpClient *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), FALSE);
|
||||
|
||||
return NM_DHCP_CLIENT_GET_PRIVATE (self)->iaid_explicit;
|
||||
}
|
||||
|
||||
GBytes *
|
||||
nm_dhcp_client_get_client_id (NMDhcpClient *self)
|
||||
{
|
||||
|
|
@ -928,6 +948,12 @@ get_property (GObject *object, guint prop_id,
|
|||
case PROP_UUID:
|
||||
g_value_set_string (value, priv->uuid);
|
||||
break;
|
||||
case PROP_IAID:
|
||||
g_value_set_uint (value, priv->iaid);
|
||||
break;
|
||||
case PROP_IAID_EXPLICIT:
|
||||
g_value_set_boolean (value, priv->iaid_explicit);
|
||||
break;
|
||||
case PROP_HOSTNAME:
|
||||
g_value_set_string (value, priv->hostname);
|
||||
break;
|
||||
|
|
@ -997,6 +1023,14 @@ set_property (GObject *object, guint prop_id,
|
|||
/* construct-only */
|
||||
priv->uuid = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_IAID:
|
||||
/* construct-only */
|
||||
priv->iaid = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_IAID_EXPLICIT:
|
||||
/* construct-only */
|
||||
priv->iaid_explicit = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_HOSTNAME:
|
||||
/* construct-only */
|
||||
priv->hostname = g_value_dup_string (value);
|
||||
|
|
@ -1116,6 +1150,18 @@ nm_dhcp_client_class_init (NMDhcpClientClass *client_class)
|
|||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_IAID] =
|
||||
g_param_spec_uint (NM_DHCP_CLIENT_IAID, "", "",
|
||||
0, G_MAXUINT32, 0,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_IAID_EXPLICIT] =
|
||||
g_param_spec_boolean (NM_DHCP_CLIENT_IAID_EXPLICIT, "", "",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_HOSTNAME] =
|
||||
g_param_spec_string (NM_DHCP_CLIENT_HOSTNAME, "", "",
|
||||
NULL,
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@
|
|||
#define NM_DHCP_CLIENT_ROUTE_TABLE "route-table"
|
||||
#define NM_DHCP_CLIENT_TIMEOUT "timeout"
|
||||
#define NM_DHCP_CLIENT_UUID "uuid"
|
||||
#define NM_DHCP_CLIENT_IAID "iaid"
|
||||
#define NM_DHCP_CLIENT_IAID_EXPLICIT "iaid-explicit"
|
||||
|
||||
#define NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED "state-changed"
|
||||
#define NM_DHCP_CLIENT_SIGNAL_PREFIX_DELEGATED "prefix-delegated"
|
||||
|
|
@ -130,6 +132,10 @@ void nm_dhcp_client_set_route_metric (NMDhcpClient *self, guint32 route_metric);
|
|||
|
||||
guint32 nm_dhcp_client_get_timeout (NMDhcpClient *self);
|
||||
|
||||
guint32 nm_dhcp_client_get_iaid (NMDhcpClient *self);
|
||||
|
||||
gboolean nm_dhcp_client_get_iaid_explicit (NMDhcpClient *self);
|
||||
|
||||
GBytes *nm_dhcp_client_get_client_id (NMDhcpClient *self);
|
||||
|
||||
const char *nm_dhcp_client_get_hostname (NMDhcpClient *self);
|
||||
|
|
|
|||
|
|
@ -522,6 +522,9 @@ ip6_start (NMDhcpClient *client,
|
|||
NMDhcpDhclient *self = NM_DHCP_DHCLIENT (client);
|
||||
NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (self);
|
||||
|
||||
if (nm_dhcp_client_get_iaid_explicit (client))
|
||||
_LOGW ("dhclient does not support specifying an IAID for DHCPv6, it will be ignored");
|
||||
|
||||
priv->conf_file = create_dhclient_config (self,
|
||||
AF_INET6,
|
||||
nm_dhcp_client_get_iface (client),
|
||||
|
|
|
|||
|
|
@ -213,6 +213,8 @@ client_start (NMDhcpManager *self,
|
|||
const struct in6_addr *ipv6_ll_addr,
|
||||
GBytes *dhcp_client_id,
|
||||
gboolean enforce_duid,
|
||||
guint32 iaid,
|
||||
gboolean iaid_explicit,
|
||||
guint32 timeout,
|
||||
const char *dhcp_anycast_addr,
|
||||
const char *hostname,
|
||||
|
|
@ -297,6 +299,8 @@ client_start (NMDhcpManager *self,
|
|||
NM_DHCP_CLIENT_HWADDR, hwaddr,
|
||||
NM_DHCP_CLIENT_BROADCAST_HWADDR, bcast_hwaddr,
|
||||
NM_DHCP_CLIENT_UUID, uuid,
|
||||
NM_DHCP_CLIENT_IAID, (guint) iaid,
|
||||
NM_DHCP_CLIENT_IAID_EXPLICIT, iaid_explicit,
|
||||
NM_DHCP_CLIENT_HOSTNAME, hostname,
|
||||
NM_DHCP_CLIENT_ROUTE_TABLE, (guint) route_table,
|
||||
NM_DHCP_CLIENT_ROUTE_METRIC, (guint) route_metric,
|
||||
|
|
@ -426,6 +430,8 @@ nm_dhcp_manager_start_ip4 (NMDhcpManager *self,
|
|||
NULL,
|
||||
dhcp_client_id,
|
||||
FALSE,
|
||||
0,
|
||||
FALSE,
|
||||
timeout,
|
||||
dhcp_anycast_addr,
|
||||
hostname,
|
||||
|
|
@ -453,6 +459,8 @@ nm_dhcp_manager_start_ip6 (NMDhcpManager *self,
|
|||
const char *dhcp_hostname,
|
||||
GBytes *duid,
|
||||
gboolean enforce_duid,
|
||||
guint32 iaid,
|
||||
gboolean iaid_explicit,
|
||||
guint32 timeout,
|
||||
const char *dhcp_anycast_addr,
|
||||
gboolean info_only,
|
||||
|
|
@ -483,6 +491,8 @@ nm_dhcp_manager_start_ip6 (NMDhcpManager *self,
|
|||
ll_addr,
|
||||
duid,
|
||||
enforce_duid,
|
||||
iaid,
|
||||
iaid_explicit,
|
||||
timeout,
|
||||
dhcp_anycast_addr,
|
||||
hostname,
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@ NMDhcpClient * nm_dhcp_manager_start_ip6 (NMDhcpManager *manager,
|
|||
const char *dhcp_hostname,
|
||||
GBytes *duid,
|
||||
gboolean enforce_duid,
|
||||
guint32 iaid,
|
||||
gboolean iaid_explicit,
|
||||
guint32 timeout,
|
||||
const char *dhcp_anycast_addr,
|
||||
gboolean info_only,
|
||||
|
|
|
|||
|
|
@ -883,7 +883,6 @@ ip6_start (NMDhcpClient *client,
|
|||
nm_auto (sd_dhcp6_client_unrefp) sd_dhcp6_client *sd_client = NULL;
|
||||
GBytes *hwaddr;
|
||||
const char *hostname;
|
||||
const char *iface;
|
||||
int r, i;
|
||||
const guint8 *duid_arr;
|
||||
gsize duid_len;
|
||||
|
|
@ -913,12 +912,8 @@ ip6_start (NMDhcpClient *client,
|
|||
if (nm_dhcp_client_get_info_only (client))
|
||||
sd_dhcp6_client_set_information_request (sd_client, 1);
|
||||
|
||||
iface = nm_dhcp_client_get_iface (client);
|
||||
|
||||
r = sd_dhcp6_client_set_iaid (sd_client,
|
||||
nm_utils_create_dhcp_iaid (TRUE,
|
||||
(const guint8 *) iface,
|
||||
strlen (iface)));
|
||||
nm_dhcp_client_get_iaid (client));
|
||||
if (r < 0) {
|
||||
nm_utils_error_set_errno (error, r, "failed to set IAID: %s");
|
||||
return FALSE;
|
||||
|
|
|
|||
|
|
@ -3621,9 +3621,7 @@ nm_utils_create_dhcp_iaid (gboolean legacy_unstable_byteorder,
|
|||
* @legacy_unstable_byteorder: historically, the code would generate a iaid
|
||||
* dependent on host endianness. This is undesirable, if backward compatibility
|
||||
* are not a concern, generate stable endianness.
|
||||
* @interface_id: a binary identifier that is hashed into the DUID.
|
||||
* Comonly this is the interface-name, but it may be the MAC address.
|
||||
* @interface_id_len: the length of @interface_id.
|
||||
* @iaid: the IAID (identity association identifier) in native byte order
|
||||
* @machine_id: the binary identifier for the machine. It is hashed
|
||||
* into the DUID. It commonly is /etc/machine-id (parsed in binary as NMUuid).
|
||||
* @machine_id_len: the length of the @machine_id.
|
||||
|
|
@ -3636,8 +3634,7 @@ nm_utils_create_dhcp_iaid (gboolean legacy_unstable_byteorder,
|
|||
*/
|
||||
GBytes *
|
||||
nm_utils_dhcp_client_id_systemd_node_specific_full (gboolean legacy_unstable_byteorder,
|
||||
const guint8 *interface_id,
|
||||
gsize interface_id_len,
|
||||
guint32 iaid,
|
||||
const guint8 *machine_id,
|
||||
gsize machine_id_len)
|
||||
{
|
||||
|
|
@ -3658,24 +3655,15 @@ nm_utils_dhcp_client_id_systemd_node_specific_full (gboolean legacy_unstable_byt
|
|||
} duid;
|
||||
} *client_id;
|
||||
guint64 u64;
|
||||
guint32 u32;
|
||||
|
||||
g_return_val_if_fail (interface_id, NULL);
|
||||
g_return_val_if_fail (interface_id_len > 0, NULL);
|
||||
g_return_val_if_fail (machine_id, NULL);
|
||||
g_return_val_if_fail (machine_id_len > 0, NULL);
|
||||
|
||||
client_id = g_malloc (sizeof (*client_id));
|
||||
|
||||
client_id->type = 255;
|
||||
|
||||
u32 = nm_utils_create_dhcp_iaid (legacy_unstable_byteorder,
|
||||
interface_id,
|
||||
interface_id_len);
|
||||
unaligned_write_be32 (&client_id->iaid, u32);
|
||||
|
||||
unaligned_write_be32 (&client_id->iaid, iaid);
|
||||
unaligned_write_be16 (&client_id->duid.type, DUID_TYPE_EN);
|
||||
|
||||
unaligned_write_be32 (&client_id->duid.en.pen, SYSTEMD_PEN);
|
||||
|
||||
u64 = htole64 (c_siphash_hash (HASH_KEY, machine_id, machine_id_len));
|
||||
|
|
@ -3687,13 +3675,10 @@ nm_utils_dhcp_client_id_systemd_node_specific_full (gboolean legacy_unstable_byt
|
|||
|
||||
GBytes *
|
||||
nm_utils_dhcp_client_id_systemd_node_specific (gboolean legacy_unstable_byteorder,
|
||||
const char *ifname)
|
||||
guint32 iaid)
|
||||
{
|
||||
g_return_val_if_fail (ifname && ifname[0], NULL);
|
||||
|
||||
return nm_utils_dhcp_client_id_systemd_node_specific_full (legacy_unstable_byteorder,
|
||||
(const guint8 *) ifname,
|
||||
strlen (ifname),
|
||||
iaid,
|
||||
(const guint8 *) nm_utils_machine_id_bin (),
|
||||
sizeof (NMUuid));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -389,13 +389,12 @@ guint32 nm_utils_create_dhcp_iaid (gboolean legacy_unstable_byteorder,
|
|||
gsize interface_id_len);
|
||||
|
||||
GBytes *nm_utils_dhcp_client_id_systemd_node_specific_full (gboolean legacy_unstable_byteorder,
|
||||
const guint8 *interface_id,
|
||||
gsize interface_id_len,
|
||||
guint32 iaid,
|
||||
const guint8 *machine_id,
|
||||
gsize machine_id_len);
|
||||
|
||||
GBytes *nm_utils_dhcp_client_id_systemd_node_specific (gboolean legacy_unstable_byteorder,
|
||||
const char *ifname);
|
||||
guint32 iaid);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -1628,6 +1628,11 @@ make_ip4_setting (shvarFile *ifcfg,
|
|||
if (v)
|
||||
g_object_set (s_ip4, NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, v, NULL);
|
||||
|
||||
nm_clear_g_free (&value);
|
||||
v = svGetValueStr (ifcfg, "DHCP_IAID", &value);
|
||||
if (v)
|
||||
g_object_set (s_ip4, NM_SETTING_IP_CONFIG_DHCP_IAID, v, NULL);
|
||||
|
||||
/* Read static IP addresses.
|
||||
* Read them even for AUTO method - in this case the addresses are
|
||||
* added to the automatic ones. Note that this is not currently supported by
|
||||
|
|
@ -2061,6 +2066,11 @@ make_ip6_setting (shvarFile *ifcfg,
|
|||
if (v)
|
||||
g_object_set (s_ip6, NM_SETTING_IP6_CONFIG_DHCP_DUID, v, NULL);
|
||||
|
||||
nm_clear_g_free (&value);
|
||||
v = svGetValueStr (ifcfg, "DHCPV6_IAID", &value);
|
||||
if (v)
|
||||
g_object_set (s_ip6, NM_SETTING_IP_CONFIG_DHCP_IAID, v, NULL);
|
||||
|
||||
nm_clear_g_free (&value);
|
||||
v = svGetValueStr (ifcfg, "DHCPV6_HOSTNAME", &value);
|
||||
/* Use DHCP_HOSTNAME as fallback if it is in FQDN format and ipv6.method is
|
||||
|
|
|
|||
|
|
@ -2604,6 +2604,9 @@ write_ip4_setting (NMConnection *connection,
|
|||
value = nm_setting_ip4_config_get_dhcp_client_id (NM_SETTING_IP4_CONFIG (s_ip4));
|
||||
svSetValueStr (ifcfg, "DHCP_CLIENT_ID", value);
|
||||
|
||||
value = nm_setting_ip_config_get_dhcp_iaid (s_ip4);
|
||||
svSetValueStr (ifcfg, "DHCP_IAID", value);
|
||||
|
||||
timeout = nm_setting_ip_config_get_dhcp_timeout (s_ip4);
|
||||
svSetValueInt64_cond (ifcfg,
|
||||
"IPV4_DHCP_TIMEOUT",
|
||||
|
|
@ -2782,6 +2785,7 @@ write_ip6_setting (NMConnection *connection,
|
|||
svUnsetValue (ifcfg, "IPV6_AUTOCONF");
|
||||
svUnsetValue (ifcfg, "DHCPV6C");
|
||||
svUnsetValue (ifcfg, "DHCPv6_DUID");
|
||||
svUnsetValue (ifcfg, "DHCPv6_IAID");
|
||||
svUnsetValue (ifcfg, "DHCPV6_HOSTNAME");
|
||||
svUnsetValue (ifcfg, "DHCPV6_SEND_HOSTNAME");
|
||||
svUnsetValue (ifcfg, "IPV6_DEFROUTE");
|
||||
|
|
@ -2831,6 +2835,8 @@ write_ip6_setting (NMConnection *connection,
|
|||
|
||||
svSetValueStr (ifcfg, "DHCPV6_DUID",
|
||||
nm_setting_ip6_config_get_dhcp_duid (NM_SETTING_IP6_CONFIG (s_ip6)));
|
||||
svSetValueStr (ifcfg, "DHCPV6_IAID",
|
||||
nm_setting_ip_config_get_dhcp_iaid (s_ip6));
|
||||
|
||||
write_ip6_setting_dhcp_hostname (s_ip6, ifcfg);
|
||||
|
||||
|
|
|
|||
|
|
@ -4458,6 +4458,7 @@ test_write_wired_dhcp (void)
|
|||
NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, "awesome-hostname",
|
||||
NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, TRUE,
|
||||
NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, TRUE,
|
||||
NM_SETTING_IP_CONFIG_DHCP_IAID, "2864434397",
|
||||
NULL);
|
||||
|
||||
nmtst_assert_connection_verifies (connection);
|
||||
|
|
|
|||
|
|
@ -2084,10 +2084,11 @@ test_nm_utils_dhcp_client_id_systemd_node_specific (gconstpointer test_data)
|
|||
gs_unref_bytes GBytes *client_id = NULL;
|
||||
const guint8 *cid;
|
||||
guint32 iaid = d->iaid_ifname;
|
||||
guint32 tmp;
|
||||
|
||||
tmp = nm_utils_create_dhcp_iaid (TRUE, (const guint8 *) d->ifname, strlen (d->ifname));
|
||||
client_id = nm_utils_dhcp_client_id_systemd_node_specific_full (legacy_unstable_byteorder,
|
||||
(const guint8 *) d->ifname,
|
||||
strlen (d->ifname),
|
||||
tmp,
|
||||
(const guint8 *) &d->machine_id,
|
||||
sizeof (d->machine_id));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue