libnm: add ipvx.dhcp-hostname-flags properties

When using the dhclient DHCP backend users can tweak the behavior in
the dhclient configuration file. One of the options that was reported
as useful in the past was the FQDN flags [1] [2].

Add native support for FQDN flags to NM by introducing new
ipv{4,6}.dhcp-hostname-flags properties.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1684595
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1255507
This commit is contained in:
Beniamino Galvani 2019-07-09 11:26:02 +02:00
parent a0632c529b
commit 1bde86396b
11 changed files with 1154 additions and 652 deletions

View file

@ -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,
),

View file

@ -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

View file

@ -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

View file

@ -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);
}

View file

@ -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 */

View file

@ -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)

View file

@ -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;
}

View file

@ -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 },

View file

@ -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;