mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 14:30:09 +01:00
merge: branch 'bg/dhcp-fqdn-flags'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/198 https://bugzilla.redhat.com/show_bug.cgi?id=1649368
This commit is contained in:
commit
d439798c41
29 changed files with 1444 additions and 713 deletions
|
|
@ -5666,6 +5666,14 @@ static const NMMetaPropertyInfo *const property_infos_IP4_CONFIG[] = {
|
|||
PROPERTY_INFO_WITH_DESC (NM_SETTING_IP4_CONFIG_DHCP_FQDN,
|
||||
.property_type = &_pt_gobject_string,
|
||||
),
|
||||
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DHCP_HOSTNAME_FLAGS, DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME_FLAGS,
|
||||
.property_type = &_pt_gobject_enum,
|
||||
.property_typ_data = DEFINE_PROPERTY_TYP_DATA (
|
||||
PROPERTY_TYP_DATA_SUBTYPE (gobject_enum,
|
||||
.get_gtype = nm_dhcp_hostname_flags_get_type,
|
||||
),
|
||||
)
|
||||
),
|
||||
PROPERTY_INFO (NM_SETTING_IP_CONFIG_NEVER_DEFAULT, DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_NEVER_DEFAULT,
|
||||
.property_type = &_pt_gobject_bool,
|
||||
),
|
||||
|
|
@ -5896,6 +5904,14 @@ static const NMMetaPropertyInfo *const property_infos_IP6_CONFIG[] = {
|
|||
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DHCP_HOSTNAME,
|
||||
.property_type = &_pt_gobject_string,
|
||||
),
|
||||
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DHCP_HOSTNAME_FLAGS, DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DHCP_HOSTNAME_FLAGS,
|
||||
.property_type = &_pt_gobject_enum,
|
||||
.property_typ_data = DEFINE_PROPERTY_TYP_DATA (
|
||||
PROPERTY_TYP_DATA_SUBTYPE (gobject_enum,
|
||||
.get_gtype = nm_dhcp_hostname_flags_get_type,
|
||||
),
|
||||
)
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_IP6_CONFIG_TOKEN,
|
||||
.property_type = &_pt_gobject_string,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -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_HOSTNAME_FLAGS N_("Flags for the DHCP hostname and FQDN. Currently this property only includes flags to control the FQDN flags set in the DHCP FQDN option. Supported FQDN flags are NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE (0x1), NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED (0x2) and NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE (0x4). When no FQDN flag is set and NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS (0x8) is set, the DHCP FQDN option will contain no flag. Otherwise, if no FQDN flag is set and NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS (0x8) is not set, the standard FQDN flags are set in the request: NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE (0x1), NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED (0x2) for IPv4 and NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE (0x1) for IPv6. When this property is set to the default value NM_DHCP_HOSTNAME_FLAG_NONE (0x0), a global default is looked up in NetworkManager configuration. If that value is unset or also NM_DHCP_HOSTNAME_FLAG_NONE (0x0), then the standard FQDN flags described above are sent in the DHCP requests.")
|
||||
#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.")
|
||||
|
|
@ -228,6 +229,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_HOSTNAME_FLAGS N_("Flags for the DHCP hostname and FQDN. Currently this property only includes flags to control the FQDN flags set in the DHCP FQDN option. Supported FQDN flags are NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE (0x1), NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED (0x2) and NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE (0x4). When no FQDN flag is set and NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS (0x8) is set, the DHCP FQDN option will contain no flag. Otherwise, if no FQDN flag is set and NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS (0x8) is not set, the standard FQDN flags are set in the request: NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE (0x1), NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED (0x2) for IPv4 and NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE (0x1) for IPv6. When this property is set to the default value NM_DHCP_HOSTNAME_FLAG_NONE (0x0), a global default is looked up in NetworkManager configuration. If that value is unset or also NM_DHCP_HOSTNAME_FLAG_NONE (0x0), then the standard FQDN flags described above are sent in the DHCP requests.")
|
||||
#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.")
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -135,6 +135,21 @@ const char *nm_bluetooth_capability_to_string (NMBluetoothCapabilities capabilit
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define NM_DHCP_HOSTNAME_FLAGS_FQDN_MASK \
|
||||
( NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED \
|
||||
| NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE \
|
||||
| NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE \
|
||||
| NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS)
|
||||
|
||||
#define NM_DHCP_HOSTNAME_FLAGS_FQDN_DEFAULT_IP4 \
|
||||
( NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED \
|
||||
| NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE)
|
||||
|
||||
#define NM_DHCP_HOSTNAME_FLAGS_FQDN_DEFAULT_IP6 \
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef enum { /*< skip >*/
|
||||
NM_SETTING_PARSE_FLAGS_NONE = 0,
|
||||
NM_SETTING_PARSE_FLAGS_STRICT = 1LL << 0,
|
||||
|
|
@ -874,6 +889,10 @@ const char *nm_utils_wifi_freq_to_band (guint32 freq);
|
|||
|
||||
gboolean _nm_utils_iaid_verify (const char *str, gint64 *out_value);
|
||||
|
||||
gboolean _nm_utils_validate_dhcp_hostname_flags (NMDhcpHostnameFlags flags,
|
||||
int addr_family,
|
||||
GError **error);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean _nmtst_variant_attribute_spec_assert_sorted (const NMVariantAttributeSpec *const*array,
|
||||
|
|
@ -882,5 +901,4 @@ gboolean _nmtst_variant_attribute_spec_assert_sorted (const NMVariantAttributeSp
|
|||
const NMVariantAttributeSpec *_nm_variant_attribute_spec_find_binary_search (const NMVariantAttributeSpec *const*array,
|
||||
gsize len,
|
||||
const char *name);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3575,6 +3575,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMSettingIPConfig,
|
|||
PROP_IGNORE_AUTO_ROUTES,
|
||||
PROP_IGNORE_AUTO_DNS,
|
||||
PROP_DHCP_HOSTNAME,
|
||||
PROP_DHCP_HOSTNAME_FLAGS,
|
||||
PROP_DHCP_SEND_HOSTNAME,
|
||||
PROP_NEVER_DEFAULT,
|
||||
PROP_MAY_FAIL,
|
||||
|
|
@ -3604,6 +3605,7 @@ typedef struct {
|
|||
int dad_timeout;
|
||||
int dhcp_timeout;
|
||||
char *dhcp_iaid;
|
||||
guint dhcp_hostname_flags;
|
||||
} NMSettingIPConfigPrivate;
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE (NMSettingIPConfig, nm_setting_ip_config, NM_TYPE_SETTING)
|
||||
|
|
@ -4838,6 +4840,25 @@ nm_setting_ip_config_get_dad_timeout (NMSettingIPConfig *setting)
|
|||
return NM_SETTING_IP_CONFIG_GET_PRIVATE (setting)->dad_timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_ip_config_get_dhcp_hostname_flags:
|
||||
* @setting: the #NMSettingIPConfig
|
||||
*
|
||||
* Returns the value contained in the #NMSettingIPConfig:dhcp-hostname-flags
|
||||
* property.
|
||||
*
|
||||
* Returns: flags for the DHCP hostname and FQDN
|
||||
*
|
||||
* Since: 1.22
|
||||
*/
|
||||
NMDhcpHostnameFlags
|
||||
nm_setting_ip_config_get_dhcp_hostname_flags (NMSettingIPConfig *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_IP_CONFIG (setting), NM_DHCP_HOSTNAME_FLAG_NONE);
|
||||
|
||||
return NM_SETTING_IP_CONFIG_GET_PRIVATE (setting)->dhcp_hostname_flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_ip_config_get_dhcp_timeout:
|
||||
* @setting: the #NMSettingIPConfig
|
||||
|
|
@ -5050,6 +5071,30 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* Validate DHCP hostname flags */
|
||||
if ( priv->dhcp_hostname_flags != NM_DHCP_HOSTNAME_FLAG_NONE
|
||||
&& !priv->dhcp_send_hostname) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("the property cannot be set when '%s' is disabled"),
|
||||
NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME);
|
||||
g_prefix_error (error, "%s.%s: ",
|
||||
nm_setting_get_name (setting),
|
||||
NM_SETTING_IP_CONFIG_DHCP_HOSTNAME_FLAGS);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!_nm_utils_validate_dhcp_hostname_flags (priv->dhcp_hostname_flags,
|
||||
NM_SETTING_IP_CONFIG_GET_FAMILY (setting),
|
||||
error)) {
|
||||
g_prefix_error (error, "%s.%s: ",
|
||||
nm_setting_get_name (setting),
|
||||
NM_SETTING_IP_CONFIG_DHCP_HOSTNAME_FLAGS);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Normalizable errors */
|
||||
if (priv->gateway && priv->never_default) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
|
|
@ -5319,6 +5364,9 @@ get_property (GObject *object, guint prop_id,
|
|||
case PROP_DHCP_IAID:
|
||||
g_value_set_string (value, nm_setting_ip_config_get_dhcp_iaid (setting));
|
||||
break;
|
||||
case PROP_DHCP_HOSTNAME_FLAGS:
|
||||
g_value_set_uint (value, nm_setting_ip_config_get_dhcp_hostname_flags (setting));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -5422,6 +5470,9 @@ set_property (GObject *object, guint prop_id,
|
|||
case PROP_DHCP_IAID:
|
||||
priv->dhcp_iaid = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_DHCP_HOSTNAME_FLAGS:
|
||||
priv->dhcp_hostname_flags = g_value_get_uint (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -5838,5 +5889,37 @@ nm_setting_ip_config_class_init (NMSettingIPConfigClass *klass)
|
|||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMSettingIPConfig:dhcp-hostname-flags:
|
||||
*
|
||||
* Flags for the DHCP hostname and FQDN.
|
||||
*
|
||||
* Currently this property only includes flags to control the FQDN flags
|
||||
* set in the DHCP FQDN option. Supported FQDN flags are
|
||||
* %NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE,
|
||||
* %NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED and
|
||||
* %NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE. When no FQDN flag is set and
|
||||
* %NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS is set, the DHCP FQDN option will
|
||||
* contain no flag. Otherwise, if no FQDN flag is set and
|
||||
* %NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS is not set, the standard FQDN flags
|
||||
* are set in the request:
|
||||
* %NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE,
|
||||
* %NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED for IPv4 and
|
||||
* %NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE for IPv6.
|
||||
*
|
||||
* When this property is set to the default value %NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
* a global default is looked up in NetworkManager configuration. If that value
|
||||
* is unset or also %NM_DHCP_HOSTNAME_FLAG_NONE, then the standard FQDN flags
|
||||
* described above are sent in the DHCP requests.
|
||||
*
|
||||
* Since: 1.22
|
||||
*/
|
||||
obj_properties[PROP_DHCP_HOSTNAME_FLAGS] =
|
||||
g_param_spec_uint (NM_SETTING_IP_CONFIG_DHCP_HOSTNAME_FLAGS, "", "",
|
||||
0, G_MAXUINT32,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -307,25 +307,26 @@ char *nm_ip_routing_rule_to_string (const NMIPRoutingRule *self,
|
|||
|
||||
#define NM_SETTING_IP_CONFIG_DAD_TIMEOUT_MAX 30000
|
||||
|
||||
#define NM_SETTING_IP_CONFIG_METHOD "method"
|
||||
#define NM_SETTING_IP_CONFIG_DNS "dns"
|
||||
#define NM_SETTING_IP_CONFIG_DNS_SEARCH "dns-search"
|
||||
#define NM_SETTING_IP_CONFIG_DNS_OPTIONS "dns-options"
|
||||
#define NM_SETTING_IP_CONFIG_DNS_PRIORITY "dns-priority"
|
||||
#define NM_SETTING_IP_CONFIG_ADDRESSES "addresses"
|
||||
#define NM_SETTING_IP_CONFIG_GATEWAY "gateway"
|
||||
#define NM_SETTING_IP_CONFIG_ROUTES "routes"
|
||||
#define NM_SETTING_IP_CONFIG_ROUTE_METRIC "route-metric"
|
||||
#define NM_SETTING_IP_CONFIG_ROUTE_TABLE "route-table"
|
||||
#define NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES "ignore-auto-routes"
|
||||
#define NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS "ignore-auto-dns"
|
||||
#define NM_SETTING_IP_CONFIG_DHCP_HOSTNAME "dhcp-hostname"
|
||||
#define NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME "dhcp-send-hostname"
|
||||
#define NM_SETTING_IP_CONFIG_NEVER_DEFAULT "never-default"
|
||||
#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"
|
||||
#define NM_SETTING_IP_CONFIG_METHOD "method"
|
||||
#define NM_SETTING_IP_CONFIG_DNS "dns"
|
||||
#define NM_SETTING_IP_CONFIG_DNS_SEARCH "dns-search"
|
||||
#define NM_SETTING_IP_CONFIG_DNS_OPTIONS "dns-options"
|
||||
#define NM_SETTING_IP_CONFIG_DNS_PRIORITY "dns-priority"
|
||||
#define NM_SETTING_IP_CONFIG_ADDRESSES "addresses"
|
||||
#define NM_SETTING_IP_CONFIG_GATEWAY "gateway"
|
||||
#define NM_SETTING_IP_CONFIG_ROUTES "routes"
|
||||
#define NM_SETTING_IP_CONFIG_ROUTE_METRIC "route-metric"
|
||||
#define NM_SETTING_IP_CONFIG_ROUTE_TABLE "route-table"
|
||||
#define NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES "ignore-auto-routes"
|
||||
#define NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS "ignore-auto-dns"
|
||||
#define NM_SETTING_IP_CONFIG_DHCP_HOSTNAME "dhcp-hostname"
|
||||
#define NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME "dhcp-send-hostname"
|
||||
#define NM_SETTING_IP_CONFIG_DHCP_HOSTNAME_FLAGS "dhcp-hostname-flags"
|
||||
#define NM_SETTING_IP_CONFIG_NEVER_DEFAULT "never-default"
|
||||
#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"
|
||||
|
|
@ -360,6 +361,45 @@ typedef struct {
|
|||
gpointer padding[8];
|
||||
} NMSettingIPConfigClass;
|
||||
|
||||
/**
|
||||
* NMDhcpHostnameFlags:
|
||||
* @NM_DHCP_HOSTNAME_FLAG_NONE: no flag set. The default value from
|
||||
* Networkmanager global configuration is used. If such value is unset
|
||||
* or still zero, the DHCP request will use standard FQDN flags, i.e.
|
||||
* %NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE and
|
||||
* %NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED for IPv4 and
|
||||
* %NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE for IPv6.
|
||||
* @NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE: whether the server should
|
||||
* do the A RR (FQDN-to-address) DNS updates.
|
||||
* @NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED: if set, the FQDN is encoded
|
||||
* using canonical wire format. Otherwise it uses the deprecated
|
||||
* ASCII encoding. This flag is allowed only for DHCPv4.
|
||||
* @NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE: when not set, request the
|
||||
* server to perform updates (the PTR RR and possibly the A RR
|
||||
* based on the %NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE flag). If
|
||||
* this is set, the %NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE flag
|
||||
* should be cleared.
|
||||
* @NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS: when set, no FQDN flags are
|
||||
* sent in the DHCP FQDN option. When cleared and all other FQDN
|
||||
* flags are zero, standard FQDN flags are sent. This flag is
|
||||
* incompatible with any other FQDN flag.
|
||||
* *
|
||||
* #NMDhcpHostnameFlags describe flags related to the DHCP hostname and
|
||||
* FQDN.
|
||||
*
|
||||
* Since: 1.22
|
||||
*/
|
||||
typedef enum { /*< flags >*/
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE = 0x0,
|
||||
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE = 0x1,
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED = 0x2,
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE = 0x4,
|
||||
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS = 0x8,
|
||||
|
||||
} NMDhcpHostnameFlags;
|
||||
|
||||
GType nm_setting_ip_config_get_type (void);
|
||||
|
||||
const char *nm_setting_ip_config_get_method (NMSettingIPConfig *setting);
|
||||
|
|
@ -461,6 +501,9 @@ int nm_setting_ip_config_get_dhcp_timeout (NMSettingIPConfig
|
|||
NM_AVAILABLE_IN_1_22
|
||||
const char *nm_setting_ip_config_get_dhcp_iaid (NMSettingIPConfig *setting);
|
||||
|
||||
NM_AVAILABLE_IN_1_22
|
||||
NMDhcpHostnameFlags nm_setting_ip_config_get_dhcp_hostname_flags (NMSettingIPConfig *setting);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* NM_SETTING_IP_CONFIG_H */
|
||||
|
|
|
|||
|
|
@ -194,6 +194,18 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if ( NM_FLAGS_ANY (nm_setting_ip_config_get_dhcp_hostname_flags (s_ip),
|
||||
NM_DHCP_HOSTNAME_FLAGS_FQDN_MASK)
|
||||
&& !priv->dhcp_fqdn) {
|
||||
/* Currently we send a FQDN option only when ipv4.dhcp-fqdn is set */
|
||||
g_set_error_literal (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("FQDN flags requires a FQDN set"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME_FLAGS);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Failures from here on are NORMALIZABLE_ERROR... */
|
||||
|
||||
if ( nm_streq (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED)
|
||||
|
|
@ -763,6 +775,13 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *klass)
|
|||
* ---end---
|
||||
*/
|
||||
|
||||
/* ---ifcfg-rh---
|
||||
* property: dhcp-hostname-flags
|
||||
* variable: DHCP_HOSTNAME_FLAGS
|
||||
* description: flags for the DHCP hostname and FQDN properties
|
||||
* example: DHCP_HOSTNAME_FLAGS=5
|
||||
*/
|
||||
|
||||
/**
|
||||
* NMSettingIP4Config:dhcp-fqdn:
|
||||
*
|
||||
|
|
|
|||
|
|
@ -657,6 +657,13 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *klass)
|
|||
* ---end---
|
||||
*/
|
||||
|
||||
/* ---ifcfg-rh---
|
||||
* property: dhcp-hostname-flags
|
||||
* variable: DHCPV6_HOSTNAME_FLAGS
|
||||
* description: flags for the DHCP hostname property
|
||||
* example: DHCPV6_HOSTNAME_FLAGS=5
|
||||
*/
|
||||
|
||||
/* ---ifcfg-rh---
|
||||
* property: never-default
|
||||
* variable: IPV6_DEFROUTE(+), (and IPV6_DEFAULTGW, IPV6_DEFAULTDEV in /etc/sysconfig/network)
|
||||
|
|
|
|||
|
|
@ -6185,3 +6185,56 @@ _nm_utils_iaid_verify (const char *str, gint64 *out_value)
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_nm_utils_validate_dhcp_hostname_flags (NMDhcpHostnameFlags flags,
|
||||
int addr_family,
|
||||
GError **error)
|
||||
{
|
||||
NMDhcpHostnameFlags unknown;
|
||||
|
||||
unknown = flags;
|
||||
unknown &= ~( NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED
|
||||
| NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE
|
||||
| NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE
|
||||
| NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS);
|
||||
if (unknown) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("unknown flags 0x%x"), (guint) unknown);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (NM_FLAGS_ALL (flags,
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE
|
||||
| NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE)) {
|
||||
g_set_error_literal (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("'fqdn-no-update' and 'fqdn-serv-update' flags cannot be set at the same time"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( NM_FLAGS_HAS (flags, NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS)
|
||||
&& NM_FLAGS_ANY (flags, NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE
|
||||
| NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED
|
||||
| NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE)) {
|
||||
g_set_error_literal (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("'fqdn-clear-flags' flag is incompatible with other FQDN flags"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( addr_family == AF_INET6
|
||||
&& (flags & NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED)) {
|
||||
g_set_error_literal (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("DHCPv6 does not support the E (encoded) FQDN flag"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3051,6 +3051,7 @@ test_connection_diff_a_only (void)
|
|||
{ NM_SETTING_IP_CONFIG_DHCP_TIMEOUT, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_DHCP_HOSTNAME_FLAGS,NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP4_CONFIG_DHCP_FQDN, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_NEVER_DEFAULT, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_MAY_FAIL, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
|
|
|
|||
|
|
@ -1645,6 +1645,8 @@ global:
|
|||
nm_client_reload_finish;
|
||||
nm_device_get_interface_flags;
|
||||
nm_device_interface_flags_get_type;
|
||||
nm_dhcp_hostname_flags_get_type;
|
||||
nm_manager_reload_flags_get_type;
|
||||
nm_setting_gsm_get_auto_config;
|
||||
nm_setting_ip_config_get_dhcp_hostname_flags;
|
||||
} libnm_1_20_0;
|
||||
|
|
|
|||
|
|
@ -716,6 +716,10 @@ ipv6.ip6-privacy=0
|
|||
<term><varname>ipv4.dhcp-iaid</varname></term>
|
||||
<listitem><para>If left unspecified, it defaults to "ifname".</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ipv4.dhcp-hostname-flags</varname></term>
|
||||
<listitem><para>If left unspecified, the value 3 (fqdn-encoded,fqdn-serv-update) is used.</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ipv4.dhcp-timeout</varname></term>
|
||||
<listitem><para>If left unspecified, the default value for
|
||||
|
|
@ -744,6 +748,10 @@ ipv6.ip6-privacy=0
|
|||
<term><varname>ipv6.dhcp-iaid</varname></term>
|
||||
<listitem><para>If left unspecified, it defaults to "ifname".</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ipv6.dhcp-hostname-flags</varname></term>
|
||||
<listitem><para>If left unspecified, the value 1 (fqdn-serv-update) is used.</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ipv6.dhcp-timeout</varname></term>
|
||||
<listitem><para>If left unspecified, the default value for
|
||||
|
|
|
|||
|
|
@ -55,6 +55,5 @@ NM_IAID_IS_SPECIAL (const char *str)
|
|||
NM_IAID_IFNAME,
|
||||
NM_IAID_STABLE);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif /* __NM_COMMON_MACROS_H__ */
|
||||
|
|
|
|||
|
|
@ -8092,6 +8092,53 @@ out_good:
|
|||
return iaid;
|
||||
}
|
||||
|
||||
static NMDhcpHostnameFlags
|
||||
get_dhcp_hostname_flags (NMDevice *self, int addr_family)
|
||||
{
|
||||
NMConnection *connection;
|
||||
NMSettingIPConfig *s_ip;
|
||||
NMDhcpHostnameFlags flags;
|
||||
gs_free_error GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (NM_IS_DEVICE (self), NM_DHCP_HOSTNAME_FLAG_NONE);
|
||||
|
||||
connection = nm_device_get_applied_connection (self);
|
||||
s_ip = nm_connection_get_setting_ip_config (connection, addr_family);
|
||||
g_return_val_if_fail (s_ip, NM_DHCP_HOSTNAME_FLAG_NONE);
|
||||
|
||||
if (!nm_setting_ip_config_get_dhcp_send_hostname (s_ip))
|
||||
return NM_DHCP_HOSTNAME_FLAG_NONE;
|
||||
|
||||
flags = nm_setting_ip_config_get_dhcp_hostname_flags (s_ip);
|
||||
if (flags != NM_DHCP_HOSTNAME_FLAG_NONE)
|
||||
return flags;
|
||||
|
||||
flags = nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
|
||||
addr_family == AF_INET
|
||||
? NM_CON_DEFAULT ("ipv4.dhcp-hostname-flags")
|
||||
: NM_CON_DEFAULT ("ipv6.dhcp-hostname-flags"),
|
||||
self,
|
||||
0, NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS,
|
||||
0);
|
||||
|
||||
if (!_nm_utils_validate_dhcp_hostname_flags (flags, addr_family, &error)) {
|
||||
_LOGW (LOGD_DEVICE, "invalid global default value 0x%x for ipv%d.%s: %s",
|
||||
(guint) flags,
|
||||
addr_family == AF_INET ? 4 : 6,
|
||||
NM_SETTING_IP_CONFIG_DHCP_HOSTNAME_FLAGS,
|
||||
error->message);
|
||||
flags = NM_DHCP_HOSTNAME_FLAG_NONE;
|
||||
}
|
||||
|
||||
if (flags != NM_DHCP_HOSTNAME_FLAG_NONE)
|
||||
return flags;
|
||||
|
||||
if (addr_family == AF_INET)
|
||||
return NM_DHCP_HOSTNAME_FLAGS_FQDN_DEFAULT_IP4;
|
||||
else
|
||||
return NM_DHCP_HOSTNAME_FLAGS_FQDN_DEFAULT_IP6;
|
||||
}
|
||||
|
||||
static GBytes *
|
||||
dhcp4_get_client_id (NMDevice *self,
|
||||
NMConnection *connection,
|
||||
|
|
@ -8265,12 +8312,12 @@ dhcp4_start (NMDevice *self)
|
|||
nm_setting_ip_config_get_dhcp_send_hostname (s_ip4),
|
||||
nm_setting_ip_config_get_dhcp_hostname (s_ip4),
|
||||
nm_setting_ip4_config_get_dhcp_fqdn (NM_SETTING_IP4_CONFIG (s_ip4)),
|
||||
get_dhcp_hostname_flags (self, AF_INET),
|
||||
client_id,
|
||||
get_dhcp_timeout (self, AF_INET),
|
||||
priv->dhcp_anycast_address,
|
||||
NULL,
|
||||
&error);
|
||||
|
||||
if (!priv->dhcp4.client) {
|
||||
_LOGW (LOGD_DHCP4, "failure to start DHCP: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
|
|
@ -9078,6 +9125,7 @@ dhcp6_start_with_link_ready (NMDevice *self, NMConnection *connection)
|
|||
nm_device_get_route_metric (self, AF_INET6),
|
||||
nm_setting_ip_config_get_dhcp_send_hostname (s_ip6),
|
||||
nm_setting_ip_config_get_dhcp_hostname (s_ip6),
|
||||
get_dhcp_hostname_flags (self, AF_INET6),
|
||||
duid,
|
||||
enforce_duid,
|
||||
iaid,
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMDhcpClient,
|
|||
PROP_IAID,
|
||||
PROP_IAID_EXPLICIT,
|
||||
PROP_HOSTNAME,
|
||||
PROP_HOSTNAME_FLAGS,
|
||||
);
|
||||
|
||||
typedef struct _NMDhcpClientPrivate {
|
||||
|
|
@ -69,6 +70,7 @@ typedef struct _NMDhcpClientPrivate {
|
|||
guint32 timeout;
|
||||
guint32 iaid;
|
||||
NMDhcpState state;
|
||||
NMDhcpHostnameFlags hostname_flags;
|
||||
bool info_only:1;
|
||||
bool use_fqdn:1;
|
||||
bool iaid_explicit:1;
|
||||
|
|
@ -286,6 +288,14 @@ nm_dhcp_client_get_hostname (NMDhcpClient *self)
|
|||
return NM_DHCP_CLIENT_GET_PRIVATE (self)->hostname;
|
||||
}
|
||||
|
||||
NMDhcpHostnameFlags
|
||||
nm_dhcp_client_get_hostname_flags (NMDhcpClient *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), NM_DHCP_HOSTNAME_FLAG_NONE);
|
||||
|
||||
return NM_DHCP_CLIENT_GET_PRIVATE (self)->hostname_flags;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_dhcp_client_get_info_only (NMDhcpClient *self)
|
||||
{
|
||||
|
|
@ -1035,6 +1045,10 @@ set_property (GObject *object, guint prop_id,
|
|||
/* construct-only */
|
||||
priv->hostname = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_HOSTNAME_FLAGS:
|
||||
/* construct-only */
|
||||
priv->hostname_flags = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_ROUTE_TABLE:
|
||||
priv->route_table = g_value_get_uint (value);
|
||||
break;
|
||||
|
|
@ -1168,6 +1182,12 @@ nm_dhcp_client_class_init (NMDhcpClientClass *client_class)
|
|||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_HOSTNAME_FLAGS] =
|
||||
g_param_spec_uint (NM_DHCP_CLIENT_HOSTNAME_FLAGS, "", "",
|
||||
0, G_MAXUINT32, NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_ROUTE_TABLE] =
|
||||
g_param_spec_uint (NM_DHCP_CLIENT_ROUTE_TABLE, "", "",
|
||||
0, G_MAXUINT32, RT_TABLE_MAIN,
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
#define NM_DHCP_CLIENT_UUID "uuid"
|
||||
#define NM_DHCP_CLIENT_IAID "iaid"
|
||||
#define NM_DHCP_CLIENT_IAID_EXPLICIT "iaid-explicit"
|
||||
#define NM_DHCP_CLIENT_HOSTNAME_FLAGS "hostname-flags"
|
||||
|
||||
#define NM_DHCP_CLIENT_SIGNAL_STATE_CHANGED "state-changed"
|
||||
#define NM_DHCP_CLIENT_SIGNAL_PREFIX_DELEGATED "prefix-delegated"
|
||||
|
|
@ -140,6 +141,8 @@ GBytes *nm_dhcp_client_get_client_id (NMDhcpClient *self);
|
|||
|
||||
const char *nm_dhcp_client_get_hostname (NMDhcpClient *self);
|
||||
|
||||
NMDhcpHostnameFlags nm_dhcp_client_get_hostname_flags (NMDhcpClient *self);
|
||||
|
||||
gboolean nm_dhcp_client_get_info_only (NMDhcpClient *self);
|
||||
|
||||
gboolean nm_dhcp_client_get_use_fqdn (NMDhcpClient *self);
|
||||
|
|
|
|||
|
|
@ -93,21 +93,11 @@ grab_request_options (GPtrArray *store, const char* line)
|
|||
}
|
||||
|
||||
static void
|
||||
add_hostname4 (GString *str, const char *hostname, gboolean use_fqdn)
|
||||
{
|
||||
if (hostname) {
|
||||
if (use_fqdn) {
|
||||
g_string_append_printf (str, FQDN_FORMAT "\n", hostname);
|
||||
g_string_append (str,
|
||||
"send fqdn.encoded on;\n"
|
||||
"send fqdn.server-update on;\n");
|
||||
} else
|
||||
g_string_append_printf (str, HOSTNAME4_FORMAT "\n", hostname);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
add_ip4_config (GString *str, GBytes *client_id, const char *hostname, gboolean use_fqdn)
|
||||
add_ip4_config (GString *str,
|
||||
GBytes *client_id,
|
||||
const char *hostname,
|
||||
gboolean use_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags)
|
||||
{
|
||||
if (client_id) {
|
||||
const char *p;
|
||||
|
|
@ -143,7 +133,27 @@ add_ip4_config (GString *str, GBytes *client_id, const char *hostname, gboolean
|
|||
g_string_append (str, "; # added by NetworkManager\n");
|
||||
}
|
||||
|
||||
add_hostname4 (str, hostname, use_fqdn);
|
||||
if (hostname) {
|
||||
if (use_fqdn) {
|
||||
g_string_append_printf (str, FQDN_FORMAT "\n", hostname);
|
||||
|
||||
g_string_append_printf (str, FQDN_TAG_PREFIX "encoded %s;\n",
|
||||
(hostname_flags & NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED)
|
||||
? "on"
|
||||
: "off");
|
||||
|
||||
g_string_append_printf (str, FQDN_TAG_PREFIX "server-update %s;\n",
|
||||
(hostname_flags & NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE)
|
||||
? "on"
|
||||
: "off");
|
||||
|
||||
g_string_append_printf (str, FQDN_TAG_PREFIX "no-client-update %s;\n",
|
||||
(hostname_flags & NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE)
|
||||
? "on"
|
||||
: "off");
|
||||
} else
|
||||
g_string_append_printf (str, HOSTNAME4_FORMAT "\n", hostname);
|
||||
}
|
||||
|
||||
g_string_append_c (str, '\n');
|
||||
|
||||
|
|
@ -159,12 +169,16 @@ add_ip4_config (GString *str, GBytes *client_id, const char *hostname, gboolean
|
|||
}
|
||||
|
||||
static void
|
||||
add_hostname6 (GString *str, const char *hostname)
|
||||
add_hostname6 (GString *str,
|
||||
const char *hostname,
|
||||
NMDhcpHostnameFlags hostname_flags)
|
||||
{
|
||||
if (hostname) {
|
||||
g_string_append_printf (str, FQDN_FORMAT "\n", hostname);
|
||||
g_string_append (str,
|
||||
"send fqdn.server-update on;\n");
|
||||
if (hostname_flags & NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE)
|
||||
g_string_append (str, FQDN_TAG_PREFIX "server-update on;\n");
|
||||
if (hostname_flags & NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE)
|
||||
g_string_append (str, FQDN_TAG_PREFIX "no-client-update on;\n");
|
||||
g_string_append_c (str, '\n');
|
||||
}
|
||||
}
|
||||
|
|
@ -271,6 +285,7 @@ nm_dhcp_dhclient_create_config (const char *interface,
|
|||
const char *hostname,
|
||||
guint32 timeout,
|
||||
gboolean use_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
const char *orig_path,
|
||||
const char *orig_contents,
|
||||
GBytes **out_new_client_id)
|
||||
|
|
@ -437,7 +452,7 @@ nm_dhcp_dhclient_create_config (const char *interface,
|
|||
}
|
||||
|
||||
if (addr_family == AF_INET) {
|
||||
add_ip4_config (new_contents, client_id, hostname, use_fqdn);
|
||||
add_ip4_config (new_contents, client_id, hostname, use_fqdn, hostname_flags);
|
||||
add_request (reqs, "rfc3442-classless-static-routes");
|
||||
add_request (reqs, "ms-classless-static-routes");
|
||||
add_request (reqs, "static-routes");
|
||||
|
|
@ -445,7 +460,7 @@ nm_dhcp_dhclient_create_config (const char *interface,
|
|||
add_request (reqs, "ntp-servers");
|
||||
add_request (reqs, "root-path");
|
||||
} else {
|
||||
add_hostname6 (new_contents, hostname);
|
||||
add_hostname6 (new_contents, hostname, hostname_flags);
|
||||
add_request (reqs, "dhcp6.name-servers");
|
||||
add_request (reqs, "dhcp6.domain-search");
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ char *nm_dhcp_dhclient_create_config (const char *interface,
|
|||
const char *hostname,
|
||||
guint32 timeout,
|
||||
gboolean use_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
const char *orig_path,
|
||||
const char *orig_contents,
|
||||
GBytes **out_new_client_id);
|
||||
|
|
|
|||
|
|
@ -146,6 +146,7 @@ merge_dhclient_config (NMDhcpDhclient *self,
|
|||
const char *hostname,
|
||||
guint32 timeout,
|
||||
gboolean use_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
const char *orig_path,
|
||||
GBytes **out_new_client_id,
|
||||
GError **error)
|
||||
|
|
@ -174,6 +175,7 @@ merge_dhclient_config (NMDhcpDhclient *self,
|
|||
hostname,
|
||||
timeout,
|
||||
use_fqdn,
|
||||
hostname_flags,
|
||||
orig_path,
|
||||
orig,
|
||||
out_new_client_id);
|
||||
|
|
@ -265,6 +267,7 @@ create_dhclient_config (NMDhcpDhclient *self,
|
|||
const char *hostname,
|
||||
guint32 timeout,
|
||||
gboolean use_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
GBytes **out_new_client_id)
|
||||
{
|
||||
gs_free char *orig = NULL;
|
||||
|
|
@ -292,6 +295,7 @@ create_dhclient_config (NMDhcpDhclient *self,
|
|||
hostname,
|
||||
timeout,
|
||||
use_fqdn,
|
||||
hostname_flags,
|
||||
orig,
|
||||
out_new_client_id,
|
||||
&error)) {
|
||||
|
|
@ -491,6 +495,7 @@ ip4_start (NMDhcpClient *client,
|
|||
nm_dhcp_client_get_hostname (client),
|
||||
nm_dhcp_client_get_timeout (client),
|
||||
nm_dhcp_client_get_use_fqdn (client),
|
||||
nm_dhcp_client_get_hostname_flags (client),
|
||||
&new_client_id);
|
||||
if (!priv->conf_file) {
|
||||
nm_utils_error_set_literal (error,
|
||||
|
|
@ -534,6 +539,7 @@ ip6_start (NMDhcpClient *client,
|
|||
nm_dhcp_client_get_hostname (client),
|
||||
nm_dhcp_client_get_timeout (client),
|
||||
TRUE,
|
||||
nm_dhcp_client_get_hostname_flags (client),
|
||||
NULL);
|
||||
if (!priv->conf_file) {
|
||||
nm_utils_error_set_literal (error,
|
||||
|
|
|
|||
|
|
@ -219,6 +219,7 @@ client_start (NMDhcpManager *self,
|
|||
const char *dhcp_anycast_addr,
|
||||
const char *hostname,
|
||||
gboolean hostname_use_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
gboolean info_only,
|
||||
NMSettingIP6ConfigPrivacy privacy,
|
||||
const char *last_ip4_address,
|
||||
|
|
@ -305,6 +306,7 @@ client_start (NMDhcpManager *self,
|
|||
NM_DHCP_CLIENT_ROUTE_TABLE, (guint) route_table,
|
||||
NM_DHCP_CLIENT_ROUTE_METRIC, (guint) route_metric,
|
||||
NM_DHCP_CLIENT_TIMEOUT, (guint) timeout,
|
||||
NM_DHCP_CLIENT_HOSTNAME_FLAGS, (guint) hostname_flags,
|
||||
NM_DHCP_CLIENT_FLAGS, (guint) (0
|
||||
| (hostname_use_fqdn ? NM_DHCP_CLIENT_FLAGS_USE_FQDN : 0)
|
||||
| (info_only ? NM_DHCP_CLIENT_FLAGS_INFO_ONLY : 0)
|
||||
|
|
@ -379,6 +381,7 @@ nm_dhcp_manager_start_ip4 (NMDhcpManager *self,
|
|||
gboolean send_hostname,
|
||||
const char *dhcp_hostname,
|
||||
const char *dhcp_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
GBytes *dhcp_client_id,
|
||||
guint32 timeout,
|
||||
const char *dhcp_anycast_addr,
|
||||
|
|
@ -436,6 +439,7 @@ nm_dhcp_manager_start_ip4 (NMDhcpManager *self,
|
|||
dhcp_anycast_addr,
|
||||
hostname,
|
||||
use_fqdn,
|
||||
hostname_flags,
|
||||
FALSE,
|
||||
0,
|
||||
last_ip_address,
|
||||
|
|
@ -457,6 +461,7 @@ nm_dhcp_manager_start_ip6 (NMDhcpManager *self,
|
|||
guint32 route_metric,
|
||||
gboolean send_hostname,
|
||||
const char *dhcp_hostname,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
GBytes *duid,
|
||||
gboolean enforce_duid,
|
||||
guint32 iaid,
|
||||
|
|
@ -497,6 +502,7 @@ nm_dhcp_manager_start_ip6 (NMDhcpManager *self,
|
|||
dhcp_anycast_addr,
|
||||
hostname,
|
||||
TRUE,
|
||||
hostname_flags,
|
||||
info_only,
|
||||
privacy,
|
||||
NULL,
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ NMDhcpClient * nm_dhcp_manager_start_ip4 (NMDhcpManager *manager,
|
|||
gboolean send_hostname,
|
||||
const char *dhcp_hostname,
|
||||
const char *dhcp_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
GBytes *dhcp_client_id,
|
||||
guint32 timeout,
|
||||
const char *dhcp_anycast_addr,
|
||||
|
|
@ -60,6 +61,7 @@ NMDhcpClient * nm_dhcp_manager_start_ip6 (NMDhcpManager *manager,
|
|||
guint32 route_metric,
|
||||
gboolean send_hostname,
|
||||
const char *dhcp_hostname,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
GBytes *duid,
|
||||
gboolean enforce_duid,
|
||||
guint32 iaid,
|
||||
|
|
|
|||
|
|
@ -71,13 +71,6 @@ G_DEFINE_TYPE (NMDhcpNettools, nm_dhcp_nettools, NM_TYPE_DHCP_CLIENT)
|
|||
|
||||
#define DHCP_MAX_FQDN_LENGTH 255
|
||||
|
||||
enum {
|
||||
DHCP_FQDN_FLAG_S = (1 << 0),
|
||||
DHCP_FQDN_FLAG_O = (1 << 1),
|
||||
DHCP_FQDN_FLAG_E = (1 << 2),
|
||||
DHCP_FQDN_FLAG_N = (1 << 3),
|
||||
};
|
||||
|
||||
enum {
|
||||
NM_IN_ADDR_CLASS_A,
|
||||
NM_IN_ADDR_CLASS_B,
|
||||
|
|
@ -1220,6 +1213,22 @@ decline (NMDhcpClient *client,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static guint8
|
||||
fqdn_flags_to_wire (NMDhcpHostnameFlags flags)
|
||||
{
|
||||
guint r = 0;
|
||||
|
||||
/* RFC 4702 section 2.1 */
|
||||
if (flags & NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE)
|
||||
r |= (1 << 0);
|
||||
if (flags & NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED)
|
||||
r |= (1 << 2);
|
||||
if (flags & NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE)
|
||||
r |= (1 << 3);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
ip4_start (NMDhcpClient *client,
|
||||
const char *dhcp_anycast_addr,
|
||||
|
|
@ -1289,26 +1298,38 @@ ip4_start (NMDhcpClient *client,
|
|||
hostname = nm_dhcp_client_get_hostname (client);
|
||||
if (hostname) {
|
||||
if (nm_dhcp_client_get_use_fqdn (client)) {
|
||||
uint8_t buffer[3 + DHCP_MAX_FQDN_LENGTH];
|
||||
uint8_t buffer[255];
|
||||
NMDhcpHostnameFlags flags;
|
||||
size_t fqdn_len;
|
||||
|
||||
buffer[0] = DHCP_FQDN_FLAG_S | /* Request server to perform A RR DNS updates */
|
||||
DHCP_FQDN_FLAG_E; /* Canonical wire format */
|
||||
buffer[1] = 0; /* RCODE1 (deprecated) */
|
||||
buffer[2] = 0; /* RCODE2 (deprecated) */
|
||||
flags = nm_dhcp_client_get_hostname_flags (client);
|
||||
buffer[0] = fqdn_flags_to_wire (flags);
|
||||
buffer[1] = 0; /* RCODE1 (deprecated) */
|
||||
buffer[2] = 0; /* RCODE2 (deprecated) */
|
||||
|
||||
r = nm_sd_dns_name_to_wire_format (hostname,
|
||||
buffer + 3,
|
||||
sizeof (buffer) - 3,
|
||||
FALSE);
|
||||
if (r < 0) {
|
||||
nm_utils_error_set_errno (error, r, "failed to convert DHCP FQDN: %s");
|
||||
return FALSE;
|
||||
if (flags & NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED) {
|
||||
r = nm_sd_dns_name_to_wire_format (hostname,
|
||||
buffer + 3,
|
||||
sizeof (buffer) - 3,
|
||||
FALSE);
|
||||
if (r <= 0) {
|
||||
nm_utils_error_set_errno (error, r, "failed to convert DHCP FQDN: %s");
|
||||
return FALSE;
|
||||
}
|
||||
fqdn_len = r;
|
||||
} else {
|
||||
fqdn_len = strlen (hostname);
|
||||
if (fqdn_len > sizeof (buffer) - 3) {
|
||||
nm_utils_error_set (error, r, "failed to set DHCP FQDN: name too long");
|
||||
return FALSE;
|
||||
}
|
||||
memcpy (buffer + 3, hostname, fqdn_len);
|
||||
}
|
||||
|
||||
r = n_dhcp4_client_probe_config_append_option (config,
|
||||
NM_DHCP_OPTION_DHCP4_CLIENT_FQDN,
|
||||
buffer,
|
||||
3 + r);
|
||||
3 + fqdn_len);
|
||||
if (r) {
|
||||
nm_utils_error_set_errno (error, r, "failed to set DHCP FQDN: %s");
|
||||
return FALSE;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ test_config (const char *orig,
|
|||
const char *hostname,
|
||||
guint32 timeout,
|
||||
gboolean use_fqdn,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
const char *dhcp_client_id,
|
||||
GBytes *expected_new_client_id,
|
||||
const char *iface,
|
||||
|
|
@ -50,6 +51,7 @@ test_config (const char *orig,
|
|||
hostname,
|
||||
timeout,
|
||||
use_fqdn,
|
||||
hostname_flags,
|
||||
"/path/to/dhclient.conf",
|
||||
orig,
|
||||
&new_client_id);
|
||||
|
|
@ -94,7 +96,11 @@ static const char *orig_missing_expected = \
|
|||
static void
|
||||
test_orig_missing (void)
|
||||
{
|
||||
test_config (NULL, orig_missing_expected, AF_INET, NULL, 0, FALSE, NULL, NULL, "eth0", NULL);
|
||||
test_config (NULL,
|
||||
orig_missing_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL, NULL, "eth0", NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -125,6 +131,7 @@ test_override_client_id (void)
|
|||
{
|
||||
test_config (override_client_id_orig, override_client_id_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
"11:22:33:44:55:66",
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -155,6 +162,7 @@ test_quote_client_id (void)
|
|||
{
|
||||
test_config (NULL, quote_client_id_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
"abcd",
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -185,6 +193,7 @@ test_quote_client_id_2 (void)
|
|||
{
|
||||
test_config (NULL, quote_client_id_expected_2,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
"a\\bc",
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -215,6 +224,7 @@ test_hex_zero_client_id (void)
|
|||
{
|
||||
test_config (NULL, hex_zero_client_id_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
"00:11:22:33",
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -245,6 +255,7 @@ test_ascii_client_id (void)
|
|||
{
|
||||
test_config (NULL, ascii_client_id_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
"qb:cd:ef:12:34:56",
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -275,6 +286,7 @@ test_hex_single_client_id (void)
|
|||
{
|
||||
test_config (NULL, hex_single_client_id_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
"ab:cd:e:12:34:56",
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -313,6 +325,7 @@ test_existing_hex_client_id (void)
|
|||
new_client_id = g_bytes_new (bytes, sizeof (bytes));
|
||||
test_config (existing_hex_client_id_orig, existing_hex_client_id_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL,
|
||||
new_client_id,
|
||||
"eth0",
|
||||
|
|
@ -350,6 +363,7 @@ test_existing_escaped_client_id (void)
|
|||
new_client_id = g_bytes_new ("$test\xfe", 6);
|
||||
test_config (existing_escaped_client_id_orig, existing_escaped_client_id_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL,
|
||||
new_client_id,
|
||||
"eth0",
|
||||
|
|
@ -391,6 +405,7 @@ test_existing_ascii_client_id (void)
|
|||
new_client_id = g_bytes_new (buf, sizeof (buf));
|
||||
test_config (existing_ascii_client_id_orig, existing_ascii_client_id_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL,
|
||||
new_client_id,
|
||||
"eth0",
|
||||
|
|
@ -403,7 +418,8 @@ static const char *fqdn_expected = \
|
|||
"\n"
|
||||
"send fqdn.fqdn \"foo.bar.com\"; # added by NetworkManager\n"
|
||||
"send fqdn.encoded on;\n"
|
||||
"send fqdn.server-update on;\n"
|
||||
"send fqdn.server-update off;\n"
|
||||
"send fqdn.no-client-update on;\n"
|
||||
"\n"
|
||||
"option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n"
|
||||
"option ms-classless-static-routes code 249 = array of unsigned integer 8;\n"
|
||||
|
|
@ -421,7 +437,10 @@ test_fqdn (void)
|
|||
{
|
||||
test_config (NULL, fqdn_expected,
|
||||
AF_INET, "foo.bar.com", 0,
|
||||
TRUE, NULL,
|
||||
TRUE,
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED
|
||||
| NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE,
|
||||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
NULL);
|
||||
|
|
@ -438,8 +457,9 @@ static const char *fqdn_options_override_expected = \
|
|||
"# Merged from /path/to/dhclient.conf\n"
|
||||
"\n"
|
||||
"send fqdn.fqdn \"example2.com\"; # added by NetworkManager\n"
|
||||
"send fqdn.encoded on;\n"
|
||||
"send fqdn.encoded off;\n"
|
||||
"send fqdn.server-update on;\n"
|
||||
"send fqdn.no-client-update off;\n"
|
||||
"\n"
|
||||
"option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n"
|
||||
"option ms-classless-static-routes code 249 = array of unsigned integer 8;\n"
|
||||
|
|
@ -462,6 +482,7 @@ test_fqdn_options_override (void)
|
|||
test_config (fqdn_options_override_orig,
|
||||
fqdn_options_override_expected,
|
||||
AF_INET, "example2.com", 0,
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE,
|
||||
TRUE, NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -496,6 +517,7 @@ test_override_hostname (void)
|
|||
{
|
||||
test_config (override_hostname_orig, override_hostname_expected,
|
||||
AF_INET, "blahblah", 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -524,6 +546,7 @@ test_override_hostname6 (void)
|
|||
{
|
||||
test_config (override_hostname6_orig, override_hostname6_expected,
|
||||
AF_INET6, "blahblah.local", 0, TRUE,
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_SERV_UPDATE,
|
||||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -536,7 +559,7 @@ static const char *nonfqdn_hostname6_expected = \
|
|||
"# Created by NetworkManager\n"
|
||||
"\n"
|
||||
"send fqdn.fqdn \"blahblah\"; # added by NetworkManager\n"
|
||||
"send fqdn.server-update on;\n"
|
||||
"send fqdn.no-client-update on;\n"
|
||||
"\n"
|
||||
"also request dhcp6.name-servers;\n"
|
||||
"also request dhcp6.domain-search;\n"
|
||||
|
|
@ -549,6 +572,7 @@ test_nonfqdn_hostname6 (void)
|
|||
/* Non-FQDN hostname can now be used with dhclient */
|
||||
test_config (NULL, nonfqdn_hostname6_expected,
|
||||
AF_INET6, "blahblah", 0, TRUE,
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE,
|
||||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -585,6 +609,7 @@ test_existing_alsoreq (void)
|
|||
{
|
||||
test_config (existing_alsoreq_orig, existing_alsoreq_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -624,6 +649,7 @@ test_existing_req (void)
|
|||
{
|
||||
test_config (existing_req_orig, existing_req_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -664,6 +690,7 @@ test_existing_multiline_alsoreq (void)
|
|||
{
|
||||
test_config (existing_multiline_alsoreq_orig, existing_multiline_alsoreq_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -903,6 +930,7 @@ test_interface1 (void)
|
|||
{
|
||||
test_config (interface1_orig, interface1_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
@ -949,6 +977,7 @@ test_interface2 (void)
|
|||
{
|
||||
test_config (interface2_orig, interface2_expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL,
|
||||
NULL,
|
||||
"eth1",
|
||||
|
|
@ -1060,6 +1089,7 @@ test_structured (void)
|
|||
new_client_id = g_bytes_new (bytes, sizeof (bytes) - 1);
|
||||
test_config (orig, expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL,
|
||||
new_client_id,
|
||||
"eth0",
|
||||
|
|
@ -1115,6 +1145,7 @@ test_config_req_intf (void)
|
|||
|
||||
test_config (orig, expected,
|
||||
AF_INET, NULL, 0, FALSE,
|
||||
NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
NULL,
|
||||
NULL,
|
||||
"eth0",
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "ndisc/nm-ndisc.h"
|
||||
#include "ndisc/nm-lndp-ndisc.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-setting-ip6-config.h"
|
||||
#include "systemd/nm-sd.h"
|
||||
|
||||
|
|
@ -520,6 +521,7 @@ main (int argc, char *argv[])
|
|||
!!global_opt.dhcp4_hostname,
|
||||
global_opt.dhcp4_hostname,
|
||||
global_opt.dhcp4_fqdn,
|
||||
NM_DHCP_HOSTNAME_FLAGS_FQDN_DEFAULT_IP4,
|
||||
client_id,
|
||||
NM_DHCP_TIMEOUT_DEFAULT,
|
||||
NULL,
|
||||
|
|
|
|||
|
|
@ -1579,7 +1579,7 @@ make_ip4_setting (shvarFile *ifcfg,
|
|||
gboolean has_key;
|
||||
shvarFile *route_ifcfg;
|
||||
gboolean never_default;
|
||||
gint64 timeout;
|
||||
gint64 i64;
|
||||
int priority;
|
||||
const char *const *item;
|
||||
guint32 route_table;
|
||||
|
|
@ -1682,6 +1682,14 @@ make_ip4_setting (shvarFile *ifcfg,
|
|||
NULL);
|
||||
}
|
||||
|
||||
i64 = svGetValueInt64 (ifcfg, "DHCP_HOSTNAME_FLAGS", 10, 0, G_MAXUINT32, -1);
|
||||
if (i64 > -1) {
|
||||
g_object_set (s_ip4,
|
||||
NM_SETTING_IP_CONFIG_DHCP_HOSTNAME_FLAGS,
|
||||
(guint) i64,
|
||||
NULL);
|
||||
}
|
||||
|
||||
g_object_set (s_ip4,
|
||||
NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, svGetValueBoolean (ifcfg, "DHCP_SEND_HOSTNAME", TRUE),
|
||||
NM_SETTING_IP_CONFIG_DHCP_TIMEOUT, svGetValueInt64 (ifcfg, "IPV4_DHCP_TIMEOUT", 10, 0, G_MAXINT32, 0),
|
||||
|
|
@ -1852,14 +1860,14 @@ make_ip4_setting (shvarFile *ifcfg,
|
|||
}
|
||||
}
|
||||
|
||||
timeout = svGetValueInt64 (ifcfg, "ACD_TIMEOUT", 10, -1, NM_SETTING_IP_CONFIG_DAD_TIMEOUT_MAX, -2);
|
||||
if (timeout == -2) {
|
||||
timeout = svGetValueInt64 (ifcfg, "ARPING_WAIT", 10, -1,
|
||||
NM_SETTING_IP_CONFIG_DAD_TIMEOUT_MAX / 1000, -1);
|
||||
if (timeout > 0)
|
||||
timeout *= 1000;
|
||||
i64 = svGetValueInt64 (ifcfg, "ACD_TIMEOUT", 10, -1, NM_SETTING_IP_CONFIG_DAD_TIMEOUT_MAX, -2);
|
||||
if (i64 == -2) {
|
||||
i64 = svGetValueInt64 (ifcfg, "ARPING_WAIT", 10, -1,
|
||||
NM_SETTING_IP_CONFIG_DAD_TIMEOUT_MAX / 1000, -1);
|
||||
if (i64 > 0)
|
||||
i64 *= 1000;
|
||||
}
|
||||
g_object_set (s_ip4, NM_SETTING_IP_CONFIG_DAD_TIMEOUT, (int) timeout, NULL);
|
||||
g_object_set (s_ip4, NM_SETTING_IP_CONFIG_DAD_TIMEOUT, (int) i64, NULL);
|
||||
|
||||
return NM_SETTING (g_steal_pointer (&s_ip4));
|
||||
}
|
||||
|
|
@ -1993,6 +2001,7 @@ make_ip6_setting (shvarFile *ifcfg,
|
|||
gs_free const char **list = NULL;
|
||||
const char *const *iter;
|
||||
guint32 i;
|
||||
gint64 i64;
|
||||
int i_val;
|
||||
GError *local = NULL;
|
||||
int priority;
|
||||
|
|
@ -2153,6 +2162,15 @@ make_ip6_setting (shvarFile *ifcfg,
|
|||
g_object_set (s_ip6, NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME,
|
||||
svGetValueBoolean (ifcfg, "DHCPV6_SEND_HOSTNAME", TRUE), NULL);
|
||||
|
||||
|
||||
i64 = svGetValueInt64 (ifcfg, "DHCPV6_HOSTNAME_FLAGS", 10, 0, G_MAXUINT32, -1);
|
||||
if (i64 > -1) {
|
||||
g_object_set (s_ip6,
|
||||
NM_SETTING_IP_CONFIG_DHCP_HOSTNAME_FLAGS,
|
||||
(guint) i64,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/* Read static IP addresses.
|
||||
* Read them even for AUTO and DHCP methods - in this case the addresses are
|
||||
* added to the automatic ones. Note that this is not currently supported by
|
||||
|
|
|
|||
|
|
@ -2438,6 +2438,7 @@ write_ip4_setting (NMConnection *connection,
|
|||
GString *searches;
|
||||
const char *method = NULL;
|
||||
gboolean has_netmask;
|
||||
NMDhcpHostnameFlags flags;
|
||||
|
||||
NM_SET_OUT (out_route_content_svformat, NULL);
|
||||
NM_SET_OUT (out_route_content, NULL);
|
||||
|
|
@ -2598,6 +2599,12 @@ write_ip4_setting (NMConnection *connection,
|
|||
value = nm_setting_ip4_config_get_dhcp_fqdn (NM_SETTING_IP4_CONFIG (s_ip4));
|
||||
svSetValueStr (ifcfg, "DHCP_FQDN", value);
|
||||
|
||||
flags = nm_setting_ip_config_get_dhcp_hostname_flags (s_ip4);
|
||||
svSetValueInt64_cond (ifcfg,
|
||||
"DHCP_HOSTNAME_FLAGS",
|
||||
flags != NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
flags);
|
||||
|
||||
/* Missing DHCP_SEND_HOSTNAME means TRUE, and we prefer not write it explicitly
|
||||
* in that case, because it is NM-specific variable
|
||||
*/
|
||||
|
|
@ -2744,6 +2751,7 @@ write_ip4_aliases (NMConnection *connection, const char *base_ifcfg_path)
|
|||
static void
|
||||
write_ip6_setting_dhcp_hostname (NMSettingIPConfig *s_ip6, shvarFile *ifcfg)
|
||||
{
|
||||
NMDhcpHostnameFlags flags;
|
||||
const char *hostname;
|
||||
|
||||
hostname = nm_setting_ip_config_get_dhcp_hostname (s_ip6);
|
||||
|
|
@ -2756,6 +2764,12 @@ write_ip6_setting_dhcp_hostname (NMSettingIPConfig *s_ip6, shvarFile *ifcfg)
|
|||
svUnsetValue (ifcfg, "DHCPV6_SEND_HOSTNAME");
|
||||
else
|
||||
svSetValueStr (ifcfg, "DHCPV6_SEND_HOSTNAME", "no");
|
||||
|
||||
flags = nm_setting_ip_config_get_dhcp_hostname_flags (s_ip6);
|
||||
svSetValueInt64_cond (ifcfg,
|
||||
"DHCPV6_HOSTNAME_FLAGS",
|
||||
flags != NM_DHCP_HOSTNAME_FLAG_NONE,
|
||||
flags);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -8,7 +8,12 @@ USERCTL=yes
|
|||
IPV6INIT=no
|
||||
NM_CONTROLLED=yes
|
||||
PEERDNS=no
|
||||
DHCP_HOSTNAME=foobar
|
||||
DHCP_FQDN=foo.bar
|
||||
DHCP_HOSTNAME_FLAGS=6
|
||||
DNS1=4.2.2.1
|
||||
DNS2=4.2.2.2
|
||||
|
||||
IPV6_AUTOCONF=no
|
||||
IPV6INIT=yes
|
||||
DHCPV6C=yes
|
||||
DHCPV6_HOSTNAME_FLAGS=8
|
||||
DHCPV6_HOSTNAME=foo.bar
|
||||
|
|
|
|||
|
|
@ -887,6 +887,7 @@ test_read_wired_dhcp (void)
|
|||
NMSettingConnection *s_con;
|
||||
NMSettingWired *s_wired;
|
||||
NMSettingIPConfig *s_ip4;
|
||||
NMSettingIPConfig *s_ip6;
|
||||
char *unmanaged = NULL;
|
||||
char expected_mac_address[ETH_ALEN] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0xee };
|
||||
const char *mac;
|
||||
|
|
@ -916,11 +917,23 @@ test_read_wired_dhcp (void)
|
|||
s_ip4 = nm_connection_get_setting_ip4_config (connection);
|
||||
g_assert (s_ip4);
|
||||
g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO);
|
||||
g_assert_cmpstr (nm_setting_ip_config_get_dhcp_hostname (s_ip4), ==, "foobar");
|
||||
g_assert_cmpstr (nm_setting_ip4_config_get_dhcp_fqdn (NM_SETTING_IP4_CONFIG (s_ip4)), ==, "foo.bar");
|
||||
g_assert (nm_setting_ip_config_get_ignore_auto_dns (s_ip4));
|
||||
g_assert_cmpuint (nm_setting_ip_config_get_num_dns (s_ip4), ==, 2);
|
||||
g_assert_cmpstr (nm_setting_ip_config_get_dns (s_ip4, 0), ==, "4.2.2.1");
|
||||
g_assert_cmpstr (nm_setting_ip_config_get_dns (s_ip4, 1), ==, "4.2.2.2");
|
||||
g_assert_cmpuint (nm_setting_ip_config_get_dhcp_hostname_flags (s_ip4),
|
||||
==,
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED | NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE);
|
||||
|
||||
/* ===== IPv6 SETTING ===== */
|
||||
s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
||||
g_assert (s_ip6);
|
||||
g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_DHCP);
|
||||
g_assert_cmpstr (nm_setting_ip_config_get_dhcp_hostname (s_ip6), ==, "foo.bar");
|
||||
g_assert_cmpuint (nm_setting_ip_config_get_dhcp_hostname_flags (s_ip6),
|
||||
==,
|
||||
NM_DHCP_HOSTNAME_FLAG_FQDN_CLEAR_FLAGS);
|
||||
|
||||
g_object_unref (connection);
|
||||
}
|
||||
|
|
@ -4457,7 +4470,8 @@ test_write_wired_dhcp (void)
|
|||
g_object_set (s_ip4,
|
||||
NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO,
|
||||
NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, "random-client-id-00:22:33",
|
||||
NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, "awesome-hostname",
|
||||
NM_SETTING_IP4_CONFIG_DHCP_FQDN, "awesome.hostname",
|
||||
NM_SETTING_IP_CONFIG_DHCP_HOSTNAME_FLAGS, (guint) NM_DHCP_HOSTNAME_FLAG_FQDN_ENCODED,
|
||||
NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, TRUE,
|
||||
NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, TRUE,
|
||||
NM_SETTING_IP_CONFIG_DHCP_IAID, "2864434397",
|
||||
|
|
@ -4470,8 +4484,10 @@ test_write_wired_dhcp (void)
|
|||
nm_connection_add_setting (connection, NM_SETTING (s_ip6));
|
||||
|
||||
g_object_set (s_ip6,
|
||||
NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
|
||||
NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_DHCP,
|
||||
NM_SETTING_IP_CONFIG_MAY_FAIL, TRUE,
|
||||
NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, "awesome.hostname",
|
||||
NM_SETTING_IP_CONFIG_DHCP_HOSTNAME_FLAGS, (guint) NM_DHCP_HOSTNAME_FLAG_FQDN_NO_UPDATE,
|
||||
NULL);
|
||||
|
||||
_writer_new_connection (connection,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue