mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-10 05:50:21 +01:00
libnm-core,clients: add support for ipv4.dhcp-vendor-class-identifier option
https://bugzilla.redhat.com/show_bug.cgi?id=1871042
Signed-off-by: Antonio Cardace <acardace@redhat.com>
(cherry picked from commit d7235394b2)
This commit is contained in:
parent
00132cecb5
commit
555f2bfc61
9 changed files with 792 additions and 537 deletions
|
|
@ -5834,6 +5834,9 @@ static const NMMetaPropertyInfo *const property_infos_IP4_CONFIG[] = {
|
|||
),
|
||||
),
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_IP4_CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER,
|
||||
.property_type = &_pt_gobject_string,
|
||||
),
|
||||
NULL
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -229,6 +229,7 @@
|
|||
#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. If zero (the default), a globally configured default is used. If still unspecified, a device specific timeout is used (usually 45 seconds). Set to 2147483647 (MAXINT32) for infinity.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER N_("The Vendor Class Identifier DHCP option (60). Special characters in the data string may be escaped using C-style escapes, nevertheless this property cannot contain nul bytes. If the per-profile value is unspecified (the default), a global connection default gets consulted. If still unspecified, the DHCP option is not sent to the server. Since 1.28, 1.26.4")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DNS N_("Array of IP addresses of DNS servers.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DNS_OPTIONS N_("Array of DNS options as described in man 5 resolv.conf. NULL means that the options are unset and left at the default. In this case NetworkManager will use default options. This is distinct from an empty list of properties. The currently supported options are \"attempts\", \"debug\", \"edns0\", \"inet6\", \"ip6-bytestring\", \"ip6-dotint\", \"ndots\", \"no-check-names\", \"no-ip6-dotint\", \"no-reload\", \"no-tld-query\", \"rotate\", \"single-request\", \"single-request-reopen\", \"timeout\", \"trust-ad\", \"use-vc\". The \"trust-ad\" setting is only honored if the profile contributes name servers to resolv.conf, and if all contributing profiles have \"trust-ad\" enabled.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DNS_PRIORITY N_("DNS servers priority. The relative priority for DNS servers specified by this setting. A lower value is better (higher priority). Zero selects a globally configured default value. If the latter is missing or zero too, it defaults to 50 for VPNs (including WireGuard) and 100 for other connections. Note that the priority is to order DNS settings for multiple active connections. It does not disambiguate multiple DNS servers within the same connection profile. When using dns=default, servers with higher priority will be on top of resolv.conf. To prioritize a given server over another one within the same connection, just specify them in the desired order. When multiple devices have configurations with the same priority, VPNs will be considered first, then devices with the best (lowest metric) default route and then all other devices. Negative values have the special effect of excluding other configurations with a greater priority value; so in presence of at least one negative priority, only DNS servers from connections with the lowest priority value will be used. When using a DNS resolver that supports Conditional Forwarding as dns=dnsmasq or dns=systemd-resolved, each connection is used to query domains in its search list. Queries for domains not present in any search list are routed through connections having the '~.' special wildcard domain, which is added automatically to connections with the default route (or can be added manually). When multiple connections specify the same domain, the one with the highest priority (lowest numerical value) wins. If a connection specifies a domain which is subdomain of another domain with a negative DNS priority value, the subdomain is ignored.")
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -38,11 +38,13 @@
|
|||
NM_GOBJECT_PROPERTIES_DEFINE_BASE (
|
||||
PROP_DHCP_CLIENT_ID,
|
||||
PROP_DHCP_FQDN,
|
||||
PROP_DHCP_VENDOR_CLASS_IDENTIFIER,
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
char *dhcp_client_id;
|
||||
char *dhcp_fqdn;
|
||||
char *dhcp_vendor_class_identifier;
|
||||
} NMSettingIP4ConfigPrivate;
|
||||
|
||||
G_DEFINE_TYPE (NMSettingIP4Config, nm_setting_ip4_config, NM_TYPE_SETTING_IP_CONFIG)
|
||||
|
|
@ -88,6 +90,25 @@ nm_setting_ip4_config_get_dhcp_fqdn (NMSettingIP4Config *setting)
|
|||
return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->dhcp_fqdn;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_ip4_config_get_dhcp_vendor_class_identifier:
|
||||
* @setting: the #NMSettingIP4Config
|
||||
*
|
||||
* Returns the value contained in the #NMSettingIP4Config:dhcp_vendor_class_identifier
|
||||
* property.
|
||||
*
|
||||
* Returns: the vendor class identifier option to send to the DHCP server
|
||||
*
|
||||
* Since: 1.28, 1.26.4
|
||||
**/
|
||||
const char *
|
||||
nm_setting_ip4_config_get_dhcp_vendor_class_identifier (NMSettingIP4Config *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), NULL);
|
||||
|
||||
return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->dhcp_vendor_class_identifier;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
verify (NMSetting *setting, NMConnection *connection, GError **error)
|
||||
{
|
||||
|
|
@ -206,6 +227,52 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->dhcp_vendor_class_identifier) {
|
||||
const char * bin;
|
||||
gsize unescaped_len;
|
||||
gs_free char *to_free = NULL;
|
||||
|
||||
if (priv->dhcp_vendor_class_identifier[0] == '\0') {
|
||||
g_set_error_literal (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_ ("property cannot be an empty string"));
|
||||
g_prefix_error (error,
|
||||
"%s.%s: ",
|
||||
NM_SETTING_IP4_CONFIG_SETTING_NAME,
|
||||
NM_SETTING_IP4_CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bin = nm_utils_buf_utf8safe_unescape (priv->dhcp_vendor_class_identifier,
|
||||
NM_UTILS_STR_UTF8_SAFE_FLAG_NONE,
|
||||
&unescaped_len,
|
||||
(gpointer *) &to_free);
|
||||
/* a DHCP option cannot be longer than 255 bytes */
|
||||
if (unescaped_len > 255) {
|
||||
g_set_error_literal (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_ ("property cannot be longer than 255 bytes"));
|
||||
g_prefix_error (error,
|
||||
"%s.%s: ",
|
||||
NM_SETTING_IP4_CONFIG_SETTING_NAME,
|
||||
NM_SETTING_IP4_CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER);
|
||||
return FALSE;
|
||||
}
|
||||
if (strlen (bin) != unescaped_len) {
|
||||
g_set_error_literal (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_ ("property cannot contain any nul bytes"));
|
||||
g_prefix_error (error,
|
||||
"%s.%s: ",
|
||||
NM_SETTING_IP4_CONFIG_SETTING_NAME,
|
||||
NM_SETTING_IP4_CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Failures from here on are NORMALIZABLE_ERROR... */
|
||||
|
||||
if ( nm_streq (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED)
|
||||
|
|
@ -474,6 +541,9 @@ get_property (GObject *object, guint prop_id,
|
|||
case PROP_DHCP_FQDN:
|
||||
g_value_set_string (value, nm_setting_ip4_config_get_dhcp_fqdn (s_ip4));
|
||||
break;
|
||||
case PROP_DHCP_VENDOR_CLASS_IDENTIFIER:
|
||||
g_value_set_string (value, nm_setting_ip4_config_get_dhcp_vendor_class_identifier (s_ip4));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -495,6 +565,10 @@ set_property (GObject *object, guint prop_id,
|
|||
g_free (priv->dhcp_fqdn);
|
||||
priv->dhcp_fqdn = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_DHCP_VENDOR_CLASS_IDENTIFIER:
|
||||
g_free (priv->dhcp_vendor_class_identifier);
|
||||
priv->dhcp_vendor_class_identifier = g_value_dup_string (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -528,6 +602,7 @@ finalize (GObject *object)
|
|||
|
||||
g_free (priv->dhcp_client_id);
|
||||
g_free (priv->dhcp_fqdn);
|
||||
g_free (priv->dhcp_vendor_class_identifier);
|
||||
|
||||
G_OBJECT_CLASS (nm_setting_ip4_config_parent_class)->finalize (object);
|
||||
}
|
||||
|
|
@ -806,6 +881,32 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *klass)
|
|||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMSettingIP4Config:dhcp-vendor-class-identifier:
|
||||
*
|
||||
* The Vendor Class Identifier DHCP option (60).
|
||||
* Special characters in the data string may be escaped using C-style escapes,
|
||||
* nevertheless this property cannot contain nul bytes.
|
||||
* If the per-profile value is unspecified (the default),
|
||||
* a global connection default gets consulted.
|
||||
* If still unspecified, the DHCP option is not sent to the server.
|
||||
*
|
||||
* Since 1.28, 1.26.4
|
||||
*/
|
||||
/* ---ifcfg-rh---
|
||||
* property: dhcp-vendor-class-identifier
|
||||
* variable: DHCP_VENDOR_CLASS_IDENTIFIER(+)
|
||||
* description: The Vendor Class Identifier DHCP option (60).
|
||||
* example: DHCP_VENDOR_CLASS_IDENTIFIER=foo
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_DHCP_VENDOR_CLASS_IDENTIFIER]
|
||||
= g_param_spec_string (NM_SETTING_IP4_CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/* IP4-specific property overrides */
|
||||
|
||||
/* ---dbus---
|
||||
|
|
|
|||
|
|
@ -24,8 +24,9 @@ G_BEGIN_DECLS
|
|||
|
||||
#define NM_SETTING_IP4_CONFIG_SETTING_NAME "ipv4"
|
||||
|
||||
#define NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID "dhcp-client-id"
|
||||
#define NM_SETTING_IP4_CONFIG_DHCP_FQDN "dhcp-fqdn"
|
||||
#define NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID "dhcp-client-id"
|
||||
#define NM_SETTING_IP4_CONFIG_DHCP_FQDN "dhcp-fqdn"
|
||||
#define NM_SETTING_IP4_CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER "dhcp-vendor-class-identifier"
|
||||
|
||||
/**
|
||||
* NM_SETTING_IP4_CONFIG_METHOD_AUTO:
|
||||
|
|
@ -95,6 +96,9 @@ const char *nm_setting_ip4_config_get_dhcp_client_id (NMSettingIP4Config *se
|
|||
NM_AVAILABLE_IN_1_2
|
||||
const char *nm_setting_ip4_config_get_dhcp_fqdn (NMSettingIP4Config *setting);
|
||||
|
||||
NM_AVAILABLE_IN_1_26_4
|
||||
const char *nm_setting_ip4_config_get_dhcp_vendor_class_identifier (NMSettingIP4Config *setting);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NM_SETTING_IP4_CONFIG_H__ */
|
||||
|
|
|
|||
|
|
@ -3363,29 +3363,30 @@ test_connection_diff_a_only (void)
|
|||
{ NULL, NM_SETTING_DIFF_RESULT_UNKNOWN },
|
||||
} },
|
||||
{ NM_SETTING_IP4_CONFIG_SETTING_NAME, {
|
||||
{ NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_DNS, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_DNS_SEARCH, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_DNS_OPTIONS, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_ADDRESSES, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_GATEWAY, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_ROUTES, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_ROUTE_METRIC, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_ROUTE_TABLE, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_ROUTING_RULES, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ 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 },
|
||||
{ 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 },
|
||||
{ NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_DNS, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_DNS_SEARCH, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_DNS_OPTIONS, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_ADDRESSES, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_GATEWAY, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_ROUTES, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_ROUTE_METRIC, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_ROUTE_TABLE, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_ROUTING_RULES, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ 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 },
|
||||
{ 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 },
|
||||
{ NM_SETTING_IP4_CONFIG_DHCP_VENDOR_CLASS_IDENTIFIER, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NULL, NM_SETTING_DIFF_RESULT_UNKNOWN },
|
||||
} },
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1741,3 +1741,8 @@ global:
|
|||
nm_setting_option_set_boolean;
|
||||
nm_setting_option_set_uint32;
|
||||
} libnm_1_24_0;
|
||||
|
||||
libnm_1_26_4 {
|
||||
global:
|
||||
nm_setting_ip4_config_get_dhcp_vendor_class_identifier;
|
||||
} libnm_1_26_0;
|
||||
|
|
|
|||
|
|
@ -740,6 +740,10 @@ ipv6.ip6-privacy=0
|
|||
<listitem><para>If left unspecified, the default value for
|
||||
the interface type is used.</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ipv4.dhcp-vendor-class-identifier</varname></term>
|
||||
<listitem><para>If left unspecified, the default is to not send the DHCP option to the server.</para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>ipv4.dns-priority</varname></term>
|
||||
<listitem><para>If unspecified or zero, use 50 for VPN profiles
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue