mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-03 17:30:16 +01:00
libnm,nmcli: add ipv6.dhcp-pd-hint property
Add a new property to specify a hint for DHCPv6 prefix delegation.
This commit is contained in:
parent
af078a7d54
commit
f9c1d06e64
13 changed files with 1063 additions and 796 deletions
|
|
@ -2480,6 +2480,11 @@ make_ip6_setting(shvarFile *ifcfg, shvarFile *network_ifcfg, gboolean routes_rea
|
|||
if (v)
|
||||
g_object_set(s_ip6, NM_SETTING_IP_CONFIG_DHCP_IAID, v, NULL);
|
||||
|
||||
nm_clear_g_free(&value);
|
||||
v = svGetValueStr(ifcfg, "DHCPV6_PD_HINT", &value);
|
||||
if (v)
|
||||
g_object_set(s_ip6, NM_SETTING_IP6_CONFIG_DHCP_PD_HINT, v, NULL);
|
||||
|
||||
nm_clear_g_free(&value);
|
||||
v = svGetValueStr(ifcfg, "DHCPV6_HOSTNAME", &value);
|
||||
/* Use DHCP_HOSTNAME as fallback if it is in FQDN format and ipv6.method is
|
||||
|
|
|
|||
|
|
@ -880,6 +880,7 @@ const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[] = {
|
|||
_KEY_TYPE("DHCPV6_HOSTNAME", NMS_IFCFG_KEY_TYPE_IS_PLAIN),
|
||||
_KEY_TYPE("DHCPV6_HOSTNAME_FLAGS", NMS_IFCFG_KEY_TYPE_IS_PLAIN),
|
||||
_KEY_TYPE("DHCPV6_IAID", NMS_IFCFG_KEY_TYPE_IS_PLAIN),
|
||||
_KEY_TYPE("DHCPV6_PD_HINT", NMS_IFCFG_KEY_TYPE_IS_PLAIN),
|
||||
_KEY_TYPE("DHCPV6_SEND_HOSTNAME", NMS_IFCFG_KEY_TYPE_IS_PLAIN),
|
||||
_KEY_TYPE("DHCP_CLIENT_ID", NMS_IFCFG_KEY_TYPE_IS_PLAIN),
|
||||
_KEY_TYPE("DHCP_FQDN", NMS_IFCFG_KEY_TYPE_IS_PLAIN),
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ typedef struct {
|
|||
NMSIfcfgKeyTypeFlags key_flags;
|
||||
} NMSIfcfgKeyTypeInfo;
|
||||
|
||||
extern const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[261];
|
||||
extern const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[262];
|
||||
|
||||
const NMSIfcfgKeyTypeInfo *nms_ifcfg_well_known_key_find_info(const char *key, gssize *out_idx);
|
||||
|
||||
|
|
|
|||
|
|
@ -3081,6 +3081,9 @@ write_ip6_setting(NMConnection *connection, shvarFile *ifcfg, GString **out_rout
|
|||
"DHCPV6_DUID",
|
||||
nm_setting_ip6_config_get_dhcp_duid(NM_SETTING_IP6_CONFIG(s_ip6)));
|
||||
svSetValueStr(ifcfg, "DHCPV6_IAID", nm_setting_ip_config_get_dhcp_iaid(s_ip6));
|
||||
svSetValueStr(ifcfg,
|
||||
"DHCPV6_PD_HINT",
|
||||
nm_setting_ip6_config_get_dhcp_pd_hint(NM_SETTING_IP6_CONFIG(s_ip6)));
|
||||
|
||||
hostname = nm_setting_ip_config_get_dhcp_hostname(s_ip6);
|
||||
svSetValueStr(ifcfg, "DHCPV6_HOSTNAME", hostname);
|
||||
|
|
|
|||
|
|
@ -1930,6 +1930,7 @@ libnm_1_44_0 {
|
|||
global:
|
||||
nm_setting_gsm_get_initial_eps_apn;
|
||||
nm_setting_gsm_get_initial_eps_config;
|
||||
nm_setting_ip6_config_get_dhcp_pd_hint;
|
||||
nm_setting_link_get_gro_max_size;
|
||||
nm_setting_link_get_gso_max_segments;
|
||||
nm_setting_link_get_gso_max_size;
|
||||
|
|
|
|||
|
|
@ -1652,6 +1652,10 @@
|
|||
dbus-type="s"
|
||||
gprop-type="gchararray"
|
||||
/>
|
||||
<property name="dhcp-pd-hint"
|
||||
dbus-type="s"
|
||||
gprop-type="gchararray"
|
||||
/>
|
||||
<property name="dhcp-reject-servers"
|
||||
dbus-type="as"
|
||||
gprop-type="GStrv"
|
||||
|
|
|
|||
|
|
@ -44,13 +44,15 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_IP6_PRIVACY,
|
|||
PROP_TOKEN,
|
||||
PROP_DHCP_DUID,
|
||||
PROP_RA_TIMEOUT,
|
||||
PROP_MTU, );
|
||||
PROP_MTU,
|
||||
PROP_DHCP_PD_HINT, );
|
||||
|
||||
typedef struct {
|
||||
NMSettingIPConfigPrivate parent;
|
||||
|
||||
char *token;
|
||||
char *dhcp_duid;
|
||||
char *dhcp_pd_hint;
|
||||
int ip6_privacy;
|
||||
gint32 addr_gen_mode;
|
||||
gint32 ra_timeout;
|
||||
|
|
@ -97,6 +99,26 @@ nm_setting_ip6_config_get_ip6_privacy(NMSettingIP6Config *setting)
|
|||
return NM_SETTING_IP6_CONFIG_GET_PRIVATE(setting)->ip6_privacy;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_ip6_config_get_dhcp_pd_hint:
|
||||
* @setting: the #NMSettingIP6Config
|
||||
*
|
||||
* Returns the value contained in the #NMSettingIP6Config:dhcp-pd-hint
|
||||
* property.
|
||||
*
|
||||
* Returns: a string containing an address and prefix length to be used
|
||||
* as hint for DHCPv6 prefix delegation.
|
||||
*
|
||||
* Since: 1.44
|
||||
**/
|
||||
const char *
|
||||
nm_setting_ip6_config_get_dhcp_pd_hint(NMSettingIP6Config *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_IP6_CONFIG(setting), NULL);
|
||||
|
||||
return NM_SETTING_IP6_CONFIG_GET_PRIVATE(setting)->dhcp_pd_hint;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_ip6_config_get_addr_gen_mode:
|
||||
* @setting: the #NMSettingIP6Config
|
||||
|
|
@ -349,6 +371,23 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
}
|
||||
}
|
||||
|
||||
if (priv->dhcp_pd_hint) {
|
||||
int prefix;
|
||||
|
||||
if (!nm_inet_parse_with_prefix_bin(AF_INET6, priv->dhcp_pd_hint, NULL, NULL, &prefix)
|
||||
|| prefix < 1 || prefix > 128) {
|
||||
g_set_error_literal(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("must be a valid IPv6 address with prefix"));
|
||||
g_prefix_error(error,
|
||||
"%s.%s: ",
|
||||
NM_SETTING_IP6_CONFIG_SETTING_NAME,
|
||||
NM_SETTING_IP6_CONFIG_DHCP_PD_HINT);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Failures from here on, are NORMALIZABLE_ERROR... */
|
||||
|
||||
if (token_needs_normalization) {
|
||||
|
|
@ -523,6 +562,41 @@ ip6_route_data_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_set_string_fcn_dhcp_pd_hint(const NMSettInfoSetting *sett_info,
|
||||
const NMSettInfoProperty *property_info,
|
||||
NMSetting *setting,
|
||||
const char *str)
|
||||
{
|
||||
NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE(setting);
|
||||
char buf[NM_INET_ADDRSTRLEN];
|
||||
char bufp[NM_INET_ADDRSTRLEN + 16];
|
||||
gs_free char *old = NULL;
|
||||
NMIPAddr addr;
|
||||
int prefix;
|
||||
|
||||
if (!str)
|
||||
goto do_set;
|
||||
|
||||
if (!nm_inet_parse_with_prefix_bin(AF_INET6, str, NULL, &addr, &prefix)) {
|
||||
/* address not valid, set as is */
|
||||
goto do_set;
|
||||
}
|
||||
|
||||
/* address valid, normalize */
|
||||
nm_inet6_ntop(&addr.addr6, buf);
|
||||
nm_sprintf_buf(bufp, "%s/%d", buf, prefix);
|
||||
str = bufp;
|
||||
|
||||
do_set:
|
||||
if (!nm_streq0(priv->dhcp_pd_hint, str)) {
|
||||
old = priv->dhcp_pd_hint;
|
||||
priv->dhcp_pd_hint = g_strdup(str);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -989,6 +1063,35 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass)
|
|||
NMSettingIP6ConfigPrivate,
|
||||
dhcp_duid);
|
||||
|
||||
/**
|
||||
* NMSettingIP6Config:dhcp-pd-hint:
|
||||
*
|
||||
* A IPv6 address followed by a slash and a prefix length. If set, the value is
|
||||
* sent to the DHCPv6 server as hint indicating the prefix delegation (IA_PD) we
|
||||
* want to receive.
|
||||
* To only hint a prefix length without prefix, set the address part to the
|
||||
* zero address (for example "::/60").
|
||||
*
|
||||
* Since: 1.44
|
||||
**/
|
||||
/* ---ifcfg-rh---
|
||||
* property: dhcp-pd-hint
|
||||
* variable: DHCPV6_PD_HINT(+)
|
||||
* description: Hint for DHCPv6 prefix delegation
|
||||
* example: DHCPV6_PD_HINT=2001:db8:1111:2220::/60
|
||||
* DHCPV6_PD_HINT=::/60
|
||||
* ---end---
|
||||
*/
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_IP6_CONFIG_DHCP_PD_HINT,
|
||||
PROP_DHCP_PD_HINT,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingIP6ConfigPrivate,
|
||||
dhcp_pd_hint,
|
||||
.direct_hook.set_string_fcn =
|
||||
_set_string_fcn_dhcp_pd_hint);
|
||||
|
||||
/* IP6-specific property overrides */
|
||||
|
||||
/* ---dbus---
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ G_BEGIN_DECLS
|
|||
|
||||
#define NM_SETTING_IP6_CONFIG_MTU "mtu"
|
||||
|
||||
#define NM_SETTING_IP6_CONFIG_DHCP_PD_HINT "dhcp-pd-hint"
|
||||
|
||||
/**
|
||||
* NM_SETTING_IP6_CONFIG_METHOD_IGNORE:
|
||||
*
|
||||
|
|
@ -164,6 +166,8 @@ NM_AVAILABLE_IN_1_24
|
|||
gint32 nm_setting_ip6_config_get_ra_timeout(NMSettingIP6Config *setting);
|
||||
NM_AVAILABLE_IN_1_40
|
||||
guint32 nm_setting_ip6_config_get_mtu(NMSettingIP6Config *setting);
|
||||
NM_AVAILABLE_IN_1_44
|
||||
const char *nm_setting_ip6_config_get_dhcp_pd_hint(NMSettingIP6Config *setting);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -6521,6 +6521,9 @@ static const NMMetaPropertyInfo *const property_infos_IP6_CONFIG[] = {
|
|||
.get_fcn = MTU_GET_FCN (NMSettingIP6Config, nm_setting_ip6_config_get_mtu),
|
||||
),
|
||||
),
|
||||
PROPERTY_INFO (NM_SETTING_IP6_CONFIG_DHCP_PD_HINT, DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DHCP_PD_HINT,
|
||||
.property_type = &_pt_gobject_string,
|
||||
),
|
||||
PROPERTY_INFO (NM_SETTING_IP6_CONFIG_DHCP_DUID, DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DHCP_DUID,
|
||||
.property_type = &_pt_gobject_string,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -195,6 +195,7 @@
|
|||
#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 string can be a 32-bit number (either decimal, hexadecimal or as colon separated hexadecimal numbers). Alternatively it can be set to the special values \"mac\", \"perm-mac\", \"ifname\" or \"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\". For DHCPv4, the IAID is only used with \"ipv4.dhcp-client-id\" values \"duid\" and \"ipv6-duid\" to generate the client-id. For DHCPv6, note that at the moment this property is only supported by the \"internal\" DHCPv6 plugin. The \"dhclient\" DHCPv6 plugin always derives the IAID from the MAC address. The actually used DHCPv6 IAID for a currently activated interface is exposed in the lease information of the device.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DHCP_PD_HINT N_("A IPv6 address followed by a slash and a prefix length. If set, the value is sent to the DHCPv6 server as hint indicating the prefix delegation (IA_PD) we want to receive. To only hint a prefix length without prefix, set the address part to the zero address (for example \"::/60\").")
|
||||
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DHCP_REJECT_SERVERS N_("Array of servers from which DHCP offers must be rejected. This property is useful to avoid getting a lease from misconfigured or rogue servers. For DHCPv4, each element must be an IPv4 address, optionally followed by a slash and a prefix length (e.g. \"192.168.122.0/24\"). This property is currently not implemented for DHCPv6.")
|
||||
#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. 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.")
|
||||
|
|
|
|||
|
|
@ -753,6 +753,8 @@
|
|||
description="A timeout for waiting Router Advertisements in seconds. If zero (the default), a globally configured default is used. If still unspecified, the timeout depends on the sysctl settings of the device. Set to 2147483647 (MAXINT32) for infinity." />
|
||||
<property name="mtu"
|
||||
description="Maximum transmission unit size, in bytes. If zero (the default), the MTU is set automatically from router advertisements or is left equal to the link-layer MTU. If greater than the link-layer MTU, or greater than zero but less than the minimum IPv6 MTU of 1280, this value has no effect." />
|
||||
<property name="dhcp-pd-hint"
|
||||
description="A IPv6 address followed by a slash and a prefix length. If set, the value is sent to the DHCPv6 server as hint indicating the prefix delegation (IA_PD) we want to receive. To only hint a prefix length without prefix, set the address part to the zero address (for example "::/60")." />
|
||||
<property name="dhcp-duid"
|
||||
description="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." />
|
||||
<property name="dhcp-iaid"
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue