Thomas Haller 2020-02-17 14:44:17 +01:00
commit 4c993f6bbb
25 changed files with 1090 additions and 626 deletions

View file

@ -4487,6 +4487,22 @@ static const NMMetaPropertyType _pt_objlist = {
), \
),
static const NMMetaPropertyTypData _ptd_gobject_int_timeout = {
PROPERTY_TYP_DATA_SUBTYPE (
gobject_int,
.value_infos = INT_VALUE_INFOS (
{
.value.i64 = 0,
.nick = "default",
},
{
.value.i64 = G_MAXINT32,
.nick = "infinity",
},
),
),
};
#define _CURRENT_NM_META_SETTING_TYPE NM_META_SETTING_TYPE_6LOWPAN
static const NMMetaPropertyInfo *const property_infos_6LOWPAN[] = {
PROPERTY_INFO_WITH_DESC (NM_SETTING_6LOWPAN_PARENT,
@ -5645,18 +5661,7 @@ static const NMMetaPropertyInfo *const property_infos_IP4_CONFIG[] = {
),
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DHCP_TIMEOUT, DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT,
.property_type = &_pt_gobject_int,
.property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (gobject_int,
.value_infos = INT_VALUE_INFOS (
{
.value.i64 = 0,
.nick = "default",
},
{
.value.i64 = G_MAXINT32,
.nick = "infinity",
},
),
),
.property_typ_data = &_ptd_gobject_int_timeout,
),
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME,
.property_type = &_pt_gobject_bool,
@ -5893,12 +5898,20 @@ static const NMMetaPropertyInfo *const property_infos_IP6_CONFIG[] = {
| NM_META_PROPERTY_TYP_FLAG_ENUM_GET_PRETTY_TEXT,
),
),
PROPERTY_INFO (NM_SETTING_IP6_CONFIG_RA_TIMEOUT, DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_RA_TIMEOUT,
.property_type = &_pt_gobject_int,
.property_typ_data = &_ptd_gobject_int_timeout,
),
PROPERTY_INFO (NM_SETTING_IP6_CONFIG_DHCP_DUID, DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DHCP_DUID,
.property_type = &_pt_gobject_string,
),
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DHCP_IAID, DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DHCP_IAID,
.property_type = &_pt_gobject_string,
),
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DHCP_TIMEOUT, DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DHCP_TIMEOUT,
.property_type = &_pt_gobject_int,
.property_typ_data = &_ptd_gobject_int_timeout,
),
PROPERTY_INFO (NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DHCP_SEND_HOSTNAME,
.property_type = &_pt_gobject_bool,
),

View file

@ -210,7 +210,7 @@
#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.")
#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_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.")
#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.")
@ -232,7 +232,7 @@
#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.")
#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.")
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DNS N_("Array of IP addresses of DNS servers.")
#define DESCRIBE_DOC_NM_SETTING_IP6_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.")
#define DESCRIBE_DOC_NM_SETTING_IP6_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.")
@ -244,6 +244,7 @@
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_MAY_FAIL N_("If TRUE, allow overall network configuration to proceed even if the configuration specified by this property times out. Note that at least one IP configuration must succeed or overall network configuration will still fail. For example, in IPv6-only networks, setting this property to TRUE on the NMSettingIP4Config allows the overall network configuration to succeed if IPv4 configuration fails but IPv6 configuration completes successfully.")
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_METHOD N_("IP configuration method. NMSettingIP4Config and NMSettingIP6Config both support \"disabled\", \"auto\", \"manual\", and \"link-local\". See the subclass-specific documentation for other values. In general, for the \"auto\" method, properties such as \"dns\" and \"routes\" specify information that is added on to the information returned from automatic configuration. The \"ignore-auto-routes\" and \"ignore-auto-dns\" properties modify this behavior. For methods that imply no upstream network, such as \"shared\" or \"link-local\", these properties must be empty. For IPv4 method \"shared\", the IP subnet can be configured by adding one manual IPv4 address or otherwise 10.42.x.0/24 is chosen. Note that the shared method must be configured on the interface which shares the internet to a subnet, not on the uplink which is shared.")
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_NEVER_DEFAULT N_("If TRUE, this connection will never be the default connection for this IP type, meaning it will never be assigned the default route by NetworkManager.")
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_RA_TIMEOUT N_("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.")
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_ROUTE_METRIC N_("The default metric for routes that don't explicitly specify a metric. The default value -1 means that the metric is chosen automatically based on the device type. The metric applies to dynamic routes, manual (static) routes that don't have an explicit metric setting, address prefix routes, and the default route. Note that for IPv6, the kernel accepts zero (0) but coerces it to 1024 (user default). Hence, setting this property to zero effectively mean setting it to 1024. For IPv4, zero is a regular value for the metric.")
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_ROUTE_TABLE N_("Enable policy routing (source routing) and set the routing table used when adding routes. This affects all routes, including device-routes, IPv4LL, DHCP, SLAAC, default-routes and static routes. But note that static routes can individually overwrite the setting by explicitly specifying a non-zero routing table. If the table setting is left at zero, it is eligible to be overwritten via global configuration. If the property is zero even after applying the global configuration value, policy routing is disabled for the address family of this connection. Policy routing disabled means that NetworkManager will add all routes to the main table (except static routes that explicitly configure a different table). Additionally, NetworkManager will not delete any extraneous routes from tables except the main table. This is to preserve backward compatibility for users who manage routing tables outside of NetworkManager.")
#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_ROUTES N_("Array of IP routes.")

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -5854,7 +5854,11 @@ nm_setting_ip_config_class_init (NMSettingIPConfigClass *klass)
/**
* NMSettingIPConfig:dhcp-timeout:
*
* A timeout for a DHCP transaction in seconds.
* 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.
**/
obj_properties[PROP_DHCP_TIMEOUT] =
g_param_spec_int (NM_SETTING_IP_CONFIG_DHCP_TIMEOUT, "", "",

View file

@ -43,6 +43,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE (
PROP_ADDR_GEN_MODE,
PROP_TOKEN,
PROP_DHCP_DUID,
PROP_RA_TIMEOUT,
);
typedef struct {
@ -50,6 +51,7 @@ typedef struct {
char *dhcp_duid;
NMSettingIP6ConfigPrivacy ip6_privacy;
NMSettingIP6ConfigAddrGenMode addr_gen_mode;
gint32 ra_timeout;
} NMSettingIP6ConfigPrivate;
G_DEFINE_TYPE (NMSettingIP6Config, nm_setting_ip6_config, NM_TYPE_SETTING_IP_CONFIG)
@ -134,6 +136,23 @@ nm_setting_ip6_config_get_dhcp_duid (NMSettingIP6Config *setting)
return NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->dhcp_duid;
}
/**
* nm_setting_ip6_config_get_ra_timeout:
* @setting: the #NMSettingIP6Config
*
* Returns: The configured %NM_SETTING_IP6_CONFIG_RA_TIMEOUT value with the
* timeout for router advertisements in seconds.
*
* Since: 1.24
**/
gint32
nm_setting_ip6_config_get_ra_timeout (NMSettingIP6Config *setting)
{
g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), 0);
return NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting)->ra_timeout;
}
static gboolean
verify (NMSetting *setting, NMConnection *connection, GError **error)
{
@ -475,6 +494,9 @@ get_property (GObject *object, guint prop_id,
case PROP_DHCP_DUID:
g_value_set_string (value, priv->dhcp_duid);
break;
case PROP_RA_TIMEOUT:
g_value_set_int (value, priv->ra_timeout);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -502,6 +524,9 @@ set_property (GObject *object, guint prop_id,
g_free (priv->dhcp_duid);
priv->dhcp_duid = g_value_dup_string (value);
break;
case PROP_RA_TIMEOUT:
priv->ra_timeout = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@ -661,6 +686,14 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *klass)
* ---end---
*/
/* ---ifcfg-rh---
* property: dhcp-timeout
* variable: IPV6_DHCP_TIMEOUT(+)
* description: A timeout after which the DHCP transaction fails in case of no response.
* example: IPV6_DHCP_TIMEOUT=10
* ---end---
*/
/* ---ifcfg-rh---
* property: dhcp-hostname-flags
* variable: DHCPV6_HOSTNAME_FLAGS
@ -830,6 +863,32 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *klass)
NM_SETTING_PARAM_INFERRABLE |
G_PARAM_STATIC_STRINGS);
/**
* NMSettingIP6Config:ra-timeout:
*
* 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.
*
* Since: 1.24
**/
/* ---ifcfg-rh---
* property: dhcp-timeout
* variable: IPV6_RA_TIMEOUT(+)
* description: A timeout for waiting Router Advertisements in seconds.
* example: IPV6_RA_TIMEOUT=10
* ---end---
*/
obj_properties[PROP_RA_TIMEOUT] =
g_param_spec_int (NM_SETTING_IP6_CONFIG_RA_TIMEOUT, "", "",
0, G_MAXINT32, 0,
G_PARAM_READWRITE |
NM_SETTING_PARAM_FUZZY_IGNORE |
G_PARAM_STATIC_STRINGS);
/**
* NMSettingIP6Config:dhcp-duid:
*

View file

@ -31,6 +31,8 @@ G_BEGIN_DECLS
#define NM_SETTING_IP6_CONFIG_DHCP_DUID "dhcp-duid"
#define NM_SETTING_IP6_CONFIG_RA_TIMEOUT "ra-timeout"
/**
* NM_SETTING_IP6_CONFIG_METHOD_IGNORE:
*
@ -159,6 +161,8 @@ NM_AVAILABLE_IN_1_4
const char *nm_setting_ip6_config_get_token (NMSettingIP6Config *setting);
NM_AVAILABLE_IN_1_12
const char *nm_setting_ip6_config_get_dhcp_duid (NMSettingIP6Config *setting);
NM_AVAILABLE_IN_1_24
gint32 nm_setting_ip6_config_get_ra_timeout (NMSettingIP6Config *setting);
G_END_DECLS

View file

@ -1673,6 +1673,7 @@ global:
nm_secret_agent_old_get_dbus_connection;
nm_secret_agent_old_get_dbus_name_owner;
nm_secret_agent_old_get_main_context;
nm_setting_ip6_config_get_ra_timeout;
nm_setting_vrf_get_table;
nm_setting_vrf_get_type;
nm_setting_vrf_new;

View file

@ -749,6 +749,10 @@ ipv6.ip6-privacy=0
removes extraneous routes from the tables.
</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>ipv6.ra-timeout</varname></term>
<listitem><para>If left unspecified, the default value depends on the sysctl solicitation settings.</para></listitem>
</varlistentry>
<varlistentry>
<term><varname>ipv6.dhcp-duid</varname></term>
<listitem><para>If left unspecified, it defaults to "lease".</para></listitem>

View file

@ -76,8 +76,21 @@ _LOG_DECLARE_SELF (NMDevice);
/*****************************************************************************/
#define DEFAULT_AUTOCONNECT TRUE
static guint32
dhcp_grace_period_from_timeout (guint32 timeout)
{
#define DHCP_GRACE_PERIOD_MULTIPLIER 2U
nm_assert (timeout > 0);
nm_assert (timeout < G_MAXINT32);
if (timeout < G_MAXUINT32 / DHCP_GRACE_PERIOD_MULTIPLIER)
return timeout * DHCP_GRACE_PERIOD_MULTIPLIER;
return G_MAXUINT32;
}
#define CARRIER_WAIT_TIME_MS 6000
#define CARRIER_WAIT_TIME_AFTER_MTU_MS 10000
@ -463,12 +476,13 @@ typedef struct _NMDevicePrivate {
/* DHCPv4 tracking */
struct {
NMDhcpClient * client;
gulong state_sigid;
NMDhcp4Config * config;
char * pac_url;
char * root_path;
bool was_active;
gulong state_sigid;
guint grace_id;
bool was_active:1;
bool grace_pending:1;
} dhcp4;
struct {
@ -533,17 +547,18 @@ typedef struct _NMDevicePrivate {
struct {
NMDhcpClient * client;
NMNDiscDHCPLevel mode;
gulong state_sigid;
gulong prefix_sigid;
NMDhcp6Config * config;
/* IP6 config from DHCP */
AppliedConfig ip6_config;
/* Event ID of the current IP6 config from DHCP */
char * event_id;
gulong state_sigid;
gulong prefix_sigid;
NMNDiscDHCPLevel mode;
guint needed_prefixes;
bool was_active;
guint grace_id;
bool was_active:1;
bool grace_pending:1;
} dhcp6;
gboolean needs_ip6_subnet;
@ -7533,7 +7548,7 @@ get_dhcp_timeout (NMDevice *self, int addr_family)
{
NMDeviceClass *klass;
NMConnection *connection;
NMSettingIPConfig *s_ip;
int timeout_i;
guint32 timeout;
nm_assert (NM_IS_DEVICE (self));
@ -7541,11 +7556,12 @@ get_dhcp_timeout (NMDevice *self, int addr_family)
connection = nm_device_get_applied_connection (self);
s_ip = nm_connection_get_setting_ip_config (connection, addr_family);
timeout_i = nm_setting_ip_config_get_dhcp_timeout (nm_connection_get_setting_ip_config (connection, addr_family));
nm_assert (timeout_i >= 0 && timeout_i <= G_MAXINT32);
timeout = nm_setting_ip_config_get_dhcp_timeout (s_ip);
timeout = (guint32) timeout_i;
if (timeout)
return timeout;
goto out;
timeout = nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
addr_family == AF_INET
@ -7554,13 +7570,22 @@ get_dhcp_timeout (NMDevice *self, int addr_family)
self,
0, G_MAXINT32, 0);
if (timeout)
return timeout;
goto out;
klass = NM_DEVICE_GET_CLASS (self);
if (klass->get_dhcp_timeout)
timeout = klass->get_dhcp_timeout (self, addr_family);
if (klass->get_dhcp_timeout_for_device) {
timeout = klass->get_dhcp_timeout_for_device (self, addr_family);
if (timeout)
goto out;
}
return timeout ?: NM_DHCP_TIMEOUT_DEFAULT;
timeout = NM_DHCP_TIMEOUT_DEFAULT;
out:
G_STATIC_ASSERT_EXPR (G_MAXINT32 == NM_DHCP_TIMEOUT_INFINITY);
nm_assert (timeout > 0);
nm_assert (timeout <= G_MAXINT32);
return timeout;
}
static void
@ -7570,6 +7595,7 @@ dhcp4_cleanup (NMDevice *self, CleanupType cleanup_type, gboolean release)
priv->dhcp4.was_active = FALSE;
nm_clear_g_source (&priv->dhcp4.grace_id);
priv->dhcp4.grace_pending = FALSE;
g_clear_pointer (&priv->dhcp4.pac_url, g_free);
g_clear_pointer (&priv->dhcp4.root_path, g_free);
@ -7850,6 +7876,7 @@ dhcp4_grace_period_expired (gpointer user_data)
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
priv->dhcp4.grace_id = 0;
priv->dhcp4.grace_pending = FALSE;
_LOGI (LOGD_DHCP4, "DHCPv4: grace period expired");
nm_device_ip_method_failed (self, AF_INET,
@ -7897,25 +7924,26 @@ dhcp4_fail (NMDevice *self, NMDhcpState dhcp_state)
/* In any other case (expired lease, assumed connection, etc.),
* wait for some time before failing the IP method.
*/
if (!priv->dhcp4.grace_id) {
if (!priv->dhcp4.grace_pending) {
guint32 timeout;
/* Start a grace period equal to the DHCP timeout multiplied
* by a constant factor. */
timeout = get_dhcp_timeout (self, AF_INET);
if (timeout < G_MAXUINT32 / DHCP_GRACE_PERIOD_MULTIPLIER) {
timeout *= DHCP_GRACE_PERIOD_MULTIPLIER;
if (timeout == NM_DHCP_TIMEOUT_INFINITY) {
_LOGI (LOGD_DHCP4, "DHCPv4: trying to acquire a new lease");
} else {
timeout = dhcp_grace_period_from_timeout (timeout);
_LOGI (LOGD_DHCP4,
"DHCPv4: trying to acquire a new lease within %u seconds",
timeout);
} else {
timeout = G_MAXUINT32;
_LOGI (LOGD_DHCP4, "DHCPv4: trying to acquire a new lease");
nm_assert (!priv->dhcp4.grace_id);
priv->dhcp4.grace_id = g_timeout_add_seconds (timeout,
dhcp4_grace_period_expired,
self);
}
priv->dhcp4.grace_id = g_timeout_add_seconds (timeout,
dhcp4_grace_period_expired,
self);
priv->dhcp4.grace_pending = TRUE;
goto clear_config;
}
return;
@ -7972,6 +8000,7 @@ dhcp4_state_changed (NMDhcpClient *client,
}
nm_clear_g_source (&priv->dhcp4.grace_id);
priv->dhcp4.grace_pending = FALSE;
/* After some failures, we have been able to renew the lease:
* update the ip state
@ -8598,6 +8627,7 @@ dhcp6_cleanup (NMDevice *self, CleanupType cleanup_type, gboolean release)
applied_config_clear (&priv->dhcp6.ip6_config);
g_clear_pointer (&priv->dhcp6.event_id, g_free);
nm_clear_g_source (&priv->dhcp6.grace_id);
priv->dhcp6.grace_pending = FALSE;
if (priv->dhcp6.client) {
nm_clear_g_signal_handler (priv->dhcp6.client, &priv->dhcp6.state_sigid);
@ -8653,6 +8683,7 @@ dhcp6_grace_period_expired (gpointer user_data)
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
priv->dhcp6.grace_id = 0;
priv->dhcp6.grace_pending = FALSE;
_LOGI (LOGD_DHCP6, "DHCPv6: grace period expired");
nm_device_ip_method_failed (self, AF_INET6,
@ -8704,25 +8735,26 @@ dhcp6_fail (NMDevice *self, NMDhcpState dhcp_state)
/* In any other case (expired lease, assumed connection, etc.),
* wait for some time before failing the IP method.
*/
if (!priv->dhcp6.grace_id) {
if (!priv->dhcp6.grace_pending) {
guint32 timeout;
/* Start a grace period equal to the DHCP timeout multiplied
* by a constant factor. */
timeout = get_dhcp_timeout (self, AF_INET6);
if (timeout < G_MAXUINT32 / DHCP_GRACE_PERIOD_MULTIPLIER) {
timeout *= DHCP_GRACE_PERIOD_MULTIPLIER;
if (timeout == NM_DHCP_TIMEOUT_INFINITY)
_LOGI (LOGD_DHCP6, "DHCPv6: trying to acquire a new lease");
else {
timeout = dhcp_grace_period_from_timeout (timeout);
_LOGI (LOGD_DHCP6,
"DHCPv6: trying to acquire a new lease within %u seconds",
timeout);
} else {
timeout = G_MAXUINT32;
_LOGI (LOGD_DHCP6, "DHCPv6: trying to acquire a new lease");
nm_assert (!priv->dhcp6.grace_id);
priv->dhcp6.grace_id = g_timeout_add_seconds (timeout,
dhcp6_grace_period_expired,
self);
}
priv->dhcp6.grace_id = g_timeout_add_seconds (timeout,
dhcp6_grace_period_expired,
self);
priv->dhcp6.grace_pending = TRUE;
goto clear_config;
}
} else {
@ -8762,6 +8794,7 @@ dhcp6_state_changed (NMDhcpClient *client,
case NM_DHCP_STATE_BOUND:
case NM_DHCP_STATE_EXTENDED:
nm_clear_g_source (&priv->dhcp6.grace_id);
priv->dhcp6.grace_pending = FALSE;
/* If the server sends multiple IPv6 addresses, we receive a state
* changed event for each of them. Use the event ID to merge IPv6
* addresses from the same transaction into a single configuration.
@ -10107,7 +10140,7 @@ addrconf6_start_with_link_ready (NMDevice *self)
G_CALLBACK (ndisc_config_changed),
self);
priv->ndisc_timeout_id = g_signal_connect (priv->ndisc,
NM_NDISC_RA_TIMEOUT,
NM_NDISC_RA_TIMEOUT_SIGNAL,
G_CALLBACK (ndisc_ra_timeout),
self);
@ -10126,6 +10159,28 @@ ndisc_node_type (NMDevice *self)
return NM_NDISC_NODE_TYPE_HOST;
}
static gint32
get_ra_timeout (NMDevice *self)
{
NMConnection *connection;
gint32 timeout;
G_STATIC_ASSERT_EXPR (NM_RA_TIMEOUT_DEFAULT == 0);
G_STATIC_ASSERT_EXPR (NM_RA_TIMEOUT_INFINITY == G_MAXINT32);
connection = nm_device_get_applied_connection (self);
timeout = nm_setting_ip6_config_get_ra_timeout (NM_SETTING_IP6_CONFIG (nm_connection_get_setting_ip6_config (connection)));
nm_assert (timeout >= 0);
if (timeout)
return timeout;
return nm_config_data_get_connection_default_int64 (NM_CONFIG_GET_DATA,
NM_CON_DEFAULT ("ipv6.ra-timeout"),
self,
0, G_MAXINT32, 0);
}
static gboolean
addrconf6_start (NMDevice *self, NMSettingIP6ConfigPrivacy use_tempaddr)
{
@ -10156,6 +10211,7 @@ addrconf6_start (NMDevice *self, NMSettingIP6ConfigPrivacy use_tempaddr)
stable_id,
nm_setting_ip6_config_get_addr_gen_mode (s_ip6),
ndisc_node_type (self),
get_ra_timeout (self),
&error);
if (!priv->ndisc) {
_LOGE (LOGD_IP6, "addrconf6: failed to start neighbor discovery: %s", error->message);

View file

@ -437,8 +437,8 @@ typedef struct _NMDeviceClass {
NMConnection *con_old,
NMConnection *con_new);
guint32 (* get_dhcp_timeout) (NMDevice *self,
int addr_family);
guint32 (* get_dhcp_timeout_for_device) (NMDevice *self,
int addr_family);
gboolean (* get_guessed_metered) (NMDevice *self);

View file

@ -405,7 +405,7 @@ state_changed (NMDevice *device,
}
static guint32
get_dhcp_timeout (NMDevice *device, int addr_family)
get_dhcp_timeout_for_device (NMDevice *device, int addr_family)
{
/* shorter timeout for mesh connectivity */
return 20;
@ -521,7 +521,7 @@ nm_device_olpc_mesh_class_init (NMDeviceOlpcMeshClass *klass)
device_class->act_stage1_prepare = act_stage1_prepare;
device_class->act_stage2_config = act_stage2_config;
device_class->state_changed = state_changed;
device_class->get_dhcp_timeout = get_dhcp_timeout;
device_class->get_dhcp_timeout_for_device = get_dhcp_timeout_for_device;
obj_properties[PROP_COMPANION] =
g_param_spec_string (NM_DEVICE_OLPC_MESH_COMPANION, "", "",

View file

@ -732,7 +732,7 @@ set_modem (NMDeviceModem *self, NMModem *modem)
}
static guint32
get_dhcp_timeout (NMDevice *device, int addr_family)
get_dhcp_timeout_for_device (NMDevice *device, int addr_family)
{
/* DHCP is always done by the modem firmware, not by the network, and
* by the time we get around to DHCP the firmware should already know
@ -897,7 +897,7 @@ nm_device_modem_class_init (NMDeviceModemClass *klass)
device_class->is_available = is_available;
device_class->get_ip_iface_identifier = get_ip_iface_identifier;
device_class->get_configured_mtu = nm_modem_get_configured_mtu;
device_class->get_dhcp_timeout = get_dhcp_timeout;
device_class->get_dhcp_timeout_for_device = get_dhcp_timeout_for_device;
device_class->state_changed = device_state_changed;

View file

@ -1203,6 +1203,7 @@ nm_dhcp_client_class_init (NMDhcpClientClass *client_class)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS);
G_STATIC_ASSERT_EXPR (G_MAXINT32 == NM_DHCP_TIMEOUT_INFINITY);
obj_properties[PROP_TIMEOUT] =
g_param_spec_uint (NM_DHCP_CLIENT_TIMEOUT, "", "",
1, G_MAXINT32, NM_DHCP_TIMEOUT_DEFAULT,

View file

@ -12,8 +12,8 @@
#include "nm-ip6-config.h"
#include "nm-dhcp-utils.h"
#define NM_DHCP_TIMEOUT_DEFAULT ((guint32) 45) /* default DHCP timeout, in seconds */
#define NM_DHCP_TIMEOUT_INFINITY G_MAXINT32
#define NM_DHCP_TIMEOUT_DEFAULT ((guint32) 45) /* default DHCP timeout, in seconds */
#define NM_DHCP_TIMEOUT_INFINITY ((guint32) G_MAXINT32)
#define NM_TYPE_DHCP_CLIENT (nm_dhcp_client_get_type ())
#define NM_DHCP_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DHCP_CLIENT, NMDhcpClient))

View file

@ -563,6 +563,7 @@ nm_lndp_ndisc_new (NMPlatform *platform,
const char *network_id,
NMSettingIP6ConfigAddrGenMode addr_gen_mode,
NMNDiscNodeType node_type,
gint32 ra_timeout,
GError **error)
{
nm_auto_pop_netns NMPNetns *netns = NULL;
@ -588,6 +589,7 @@ nm_lndp_ndisc_new (NMPlatform *platform,
NM_NDISC_MAX_ADDRESSES, ipv6_sysctl_get (platform, ifname,
"max_addresses",
0, G_MAXINT32, NM_NDISC_MAX_ADDRESSES_DEFAULT),
NM_NDISC_RA_TIMEOUT, (int) ra_timeout,
NM_NDISC_ROUTER_SOLICITATIONS, ipv6_sysctl_get (platform, ifname,
"router_solicitations",
1, G_MAXINT32, NM_NDISC_ROUTER_SOLICITATIONS_DEFAULT),

View file

@ -28,6 +28,7 @@ NMNDisc *nm_lndp_ndisc_new (NMPlatform *platform,
const char *network_id,
NMSettingIP6ConfigAddrGenMode addr_gen_mode,
NMNDiscNodeType node_type,
gint32 ra_timeout,
GError **error);
#endif /* __NETWORKMANAGER_LNDP_NDISC_H__ */

View file

@ -48,6 +48,7 @@ struct _NMNDiscPrivate {
char *network_id;
NMSettingIP6ConfigAddrGenMode addr_gen_mode;
NMUtilsStableType stable_type;
gint32 ra_timeout;
gint32 max_addresses;
gint32 router_solicitations;
gint32 router_solicitation_interval;
@ -67,6 +68,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE (
PROP_NETWORK_ID,
PROP_ADDR_GEN_MODE,
PROP_MAX_ADDRESSES,
PROP_RA_TIMEOUT,
PROP_ROUTER_SOLICITATIONS,
PROP_ROUTER_SOLICITATION_INTERVAL,
PROP_NODE_TYPE,
@ -74,7 +76,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE (
enum {
CONFIG_RECEIVED,
RA_TIMEOUT,
RA_TIMEOUT_SIGNAL,
LAST_SIGNAL
};
@ -898,7 +900,7 @@ ndisc_ra_timeout_cb (gpointer user_data)
NMNDisc *ndisc = NM_NDISC (user_data);
NM_NDISC_GET_PRIVATE (ndisc)->ra_timeout_id = 0;
g_signal_emit (ndisc, signals[RA_TIMEOUT], 0);
g_signal_emit (ndisc, signals[RA_TIMEOUT_SIGNAL], 0);
return G_SOURCE_REMOVE;
}
@ -906,34 +908,46 @@ void
nm_ndisc_start (NMNDisc *ndisc)
{
nm_auto_pop_netns NMPNetns *netns = NULL;
NMNDiscPrivate *priv = NM_NDISC_GET_PRIVATE (ndisc);
NMNDiscClass *klass = NM_NDISC_GET_CLASS (ndisc);
gint64 ra_wait_secs;
NMNDiscPrivate *priv;
g_return_if_fail (klass->start);
g_return_if_fail (!priv->ra_timeout_id);
g_return_if_fail (NM_IS_NDISC (ndisc));
_LOGD ("starting neighbor discovery: %d", priv->ifindex);
priv = NM_NDISC_GET_PRIVATE (ndisc);
nm_assert (NM_NDISC_GET_CLASS (ndisc)->start);
nm_assert (!priv->ra_timeout_id);
_LOGD ("starting neighbor discovery for ifindex %d%s",
priv->ifindex,
priv->node_type == NM_NDISC_NODE_TYPE_HOST
? " (solicit)"
: " (announce)");
if (!nm_ndisc_netns_push (ndisc, &netns))
return;
klass->start (ndisc);
NM_NDISC_GET_CLASS (ndisc)->start (ndisc);
switch (priv->node_type) {
case NM_NDISC_NODE_TYPE_HOST:
ra_wait_secs = (((gint64) priv->router_solicitations) * priv->router_solicitation_interval) + 1;
ra_wait_secs = MAX (ra_wait_secs, 30);
priv->ra_timeout_id = g_timeout_add_seconds (ra_wait_secs, ndisc_ra_timeout_cb, ndisc);
_LOGD ("scheduling RA timeout in %d seconds", (int) ra_wait_secs);
if (priv->node_type == NM_NDISC_NODE_TYPE_HOST) {
gint32 ra_timeout = priv->ra_timeout;
G_STATIC_ASSERT_EXPR (NM_RA_TIMEOUT_DEFAULT == 0);
G_STATIC_ASSERT_EXPR (NM_RA_TIMEOUT_INFINITY == G_MAXINT32);
if (ra_timeout != NM_RA_TIMEOUT_INFINITY) {
if (ra_timeout == NM_RA_TIMEOUT_DEFAULT) {
ra_timeout = NM_MAX ((((gint64) priv->router_solicitations) * priv->router_solicitation_interval) + 1,
30);
}
nm_assert (ra_timeout > 0 && ra_timeout < NM_RA_TIMEOUT_INFINITY);
_LOGD ("scheduling RA timeout in %d seconds", ra_timeout);
priv->ra_timeout_id = g_timeout_add_seconds (ra_timeout, ndisc_ra_timeout_cb, ndisc);
}
solicit_routers (ndisc);
break;
case NM_NDISC_NODE_TYPE_ROUTER:
announce_router_initial (ndisc);
break;
default:
g_assert_not_reached ();
return;
}
nm_assert (priv->node_type == NM_NDISC_NODE_TYPE_ROUTER);
announce_router_initial (ndisc);
}
NMNDiscConfigMap
@ -1312,6 +1326,10 @@ set_property (GObject *object, guint prop_id,
/* construct-only */
priv->max_addresses = g_value_get_int (value);
break;
case PROP_RA_TIMEOUT:
/* construct-only */
priv->ra_timeout = g_value_get_int (value);
break;
case PROP_ROUTER_SOLICITATIONS:
/* construct-only */
priv->router_solicitations = g_value_get_int (value);
@ -1323,6 +1341,8 @@ set_property (GObject *object, guint prop_id,
case PROP_NODE_TYPE:
/* construct-only */
priv->node_type = g_value_get_int (value);
nm_assert (NM_IN_SET (priv->node_type, NM_NDISC_NODE_TYPE_HOST,
NM_NDISC_NODE_TYPE_ROUTER));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -1401,8 +1421,8 @@ nm_ndisc_class_init (NMNDiscClass *klass)
g_type_class_add_private (klass, sizeof (NMNDiscPrivate));
object_class->set_property = set_property;
object_class->dispose = dispose;
object_class->finalize = finalize;
object_class->dispose = dispose;
object_class->finalize = finalize;
obj_properties[PROP_PLATFORM] =
g_param_spec_object (NM_NDISC_PLATFORM, "", "",
@ -1446,6 +1466,13 @@ nm_ndisc_class_init (NMNDiscClass *klass)
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
G_STATIC_ASSERT_EXPR (G_MAXINT32 == NM_RA_TIMEOUT_INFINITY);
obj_properties[PROP_RA_TIMEOUT] =
g_param_spec_int (NM_NDISC_RA_TIMEOUT, "", "",
0, G_MAXINT32, 0,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
obj_properties[PROP_ROUTER_SOLICITATIONS] =
g_param_spec_int (NM_NDISC_ROUTER_SOLICITATIONS, "", "",
1, G_MAXINT32, NM_NDISC_ROUTER_SOLICITATIONS_DEFAULT,
@ -1473,8 +1500,8 @@ nm_ndisc_class_init (NMNDiscClass *klass)
0,
NULL, NULL, NULL,
G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_UINT);
signals[RA_TIMEOUT] =
g_signal_new (NM_NDISC_RA_TIMEOUT,
signals[RA_TIMEOUT_SIGNAL] =
g_signal_new (NM_NDISC_RA_TIMEOUT_SIGNAL,
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_FIRST,
0,

View file

@ -16,6 +16,9 @@
#include "platform/nm-platform.h"
#include "platform/nmp-object.h"
#define NM_RA_TIMEOUT_DEFAULT ((gint32) 0)
#define NM_RA_TIMEOUT_INFINITY G_MAXINT32
#define NM_TYPE_NDISC (nm_ndisc_get_type ())
#define NM_NDISC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_NDISC, NMNDisc))
#define NM_NDISC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_NDISC, NMNDiscClass))
@ -31,11 +34,12 @@
#define NM_NDISC_STABLE_TYPE "stable-type"
#define NM_NDISC_NODE_TYPE "node-type"
#define NM_NDISC_MAX_ADDRESSES "max-addresses"
#define NM_NDISC_RA_TIMEOUT "ra-timeout"
#define NM_NDISC_ROUTER_SOLICITATIONS "router-solicitations"
#define NM_NDISC_ROUTER_SOLICITATION_INTERVAL "router-solicitation-interval"
#define NM_NDISC_CONFIG_RECEIVED "config-received"
#define NM_NDISC_RA_TIMEOUT "ra-timeout"
#define NM_NDISC_CONFIG_RECEIVED "config-received"
#define NM_NDISC_RA_TIMEOUT_SIGNAL "ra-timeout-signal"
typedef enum {
NM_NDISC_DHCP_LEVEL_UNKNOWN,

View file

@ -52,6 +52,7 @@ main (int argc, char **argv)
"8ce666e8-d34d-4fb1-b858-f15a7al28086",
NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_EUI64,
NM_NDISC_NODE_TYPE_HOST,
0,
&error);
if (!ndisc) {
g_print ("Failed to create NMNDisc instance: %s\n", error->message);

View file

@ -552,10 +552,14 @@ main (int argc, char *argv[])
stable_type = (global_opt.stable_id[0] - '0');
stable_id = &global_opt.stable_id[2];
}
ndisc = nm_lndp_ndisc_new (NM_PLATFORM_GET, gl.ifindex, global_opt.ifname,
stable_type, stable_id,
ndisc = nm_lndp_ndisc_new (NM_PLATFORM_GET,
gl.ifindex,
global_opt.ifname,
stable_type,
stable_id,
global_opt.addr_gen_mode,
NM_NDISC_NODE_TYPE_HOST,
NM_RA_TIMEOUT_DEFAULT,
NULL);
g_assert (ndisc);
@ -573,7 +577,7 @@ main (int argc, char *argv[])
G_CALLBACK (ndisc_config_changed),
NULL);
g_signal_connect (ndisc,
NM_NDISC_RA_TIMEOUT,
NM_NDISC_RA_TIMEOUT_SIGNAL,
G_CALLBACK (ndisc_ra_timeout),
NULL);
nm_ndisc_start (ndisc);

View file

@ -1734,7 +1734,7 @@ make_ip4_setting (shvarFile *ifcfg,
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),
NM_SETTING_IP_CONFIG_DHCP_TIMEOUT, (int) svGetValueInt64 (ifcfg, "IPV4_DHCP_TIMEOUT", 10, 0, G_MAXINT32, 0),
NULL);
nm_clear_g_free (&value);
@ -2203,9 +2203,11 @@ make_ip6_setting (shvarFile *ifcfg,
if (v)
g_object_set (s_ip6, NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, v, NULL);
g_object_set (s_ip6, NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME,
svGetValueBoolean (ifcfg, "DHCPV6_SEND_HOSTNAME", TRUE), NULL);
g_object_set (s_ip6,
NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, svGetValueBoolean (ifcfg, "DHCPV6_SEND_HOSTNAME", TRUE),
NM_SETTING_IP_CONFIG_DHCP_TIMEOUT, (int) svGetValueInt64 (ifcfg, "IPV6_DHCP_TIMEOUT", 10, 0, G_MAXINT32, 0),
NM_SETTING_IP6_CONFIG_RA_TIMEOUT, (int) svGetValueInt64 (ifcfg, "IPV6_RA_TIMEOUT", 10, 0, G_MAXINT32, 0),
NULL);
i64 = svGetValueInt64 (ifcfg, "DHCPV6_HOSTNAME_FLAGS", 10, 0, G_MAXUINT32, -1);
if (i64 > -1) {

View file

@ -806,6 +806,7 @@ const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[] = {
_KEY_TYPE ("IPV6_DEFAULTDEV", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
_KEY_TYPE ("IPV6_DEFAULTGW", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
_KEY_TYPE ("IPV6_DEFROUTE", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
_KEY_TYPE ("IPV6_DHCP_TIMEOUT", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
_KEY_TYPE ("IPV6_DISABLED", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
_KEY_TYPE ("IPV6_DNS_PRIORITY", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
_KEY_TYPE ("IPV6_DOMAIN", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
@ -814,6 +815,7 @@ const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[] = {
_KEY_TYPE ("IPV6_PEERROUTES", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
_KEY_TYPE ("IPV6_PRIVACY", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
_KEY_TYPE ("IPV6_PRIVACY_PREFER_PUBLIC_IP", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
_KEY_TYPE ("IPV6_RA_TIMEOUT", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
_KEY_TYPE ("IPV6_RES_OPTIONS", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
_KEY_TYPE ("IPV6_ROUTE_METRIC", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),
_KEY_TYPE ("IPV6_ROUTE_TABLE", NMS_IFCFG_KEY_TYPE_IS_PLAIN ),

View file

@ -33,7 +33,7 @@ typedef struct {
NMSIfcfgKeyTypeFlags key_flags;
} NMSIfcfgKeyTypeInfo;
extern const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[227];
extern const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[229];
const NMSIfcfgKeyTypeInfo *nms_ifcfg_well_known_key_find_info (const char *key, gssize *out_idx);

View file

@ -2614,28 +2614,6 @@ 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);
svSetValueStr (ifcfg, "DHCPV6_HOSTNAME", hostname);
/* Missing DHCPV6_SEND_HOSTNAME means TRUE, and we prefer not write it
* explicitly in that case, because it is NM-specific variable
*/
if (!nm_setting_ip_config_get_dhcp_send_hostname (s_ip6))
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
write_ip6_setting (NMConnection *connection,
shvarFile *ifcfg,
@ -2651,6 +2629,9 @@ write_ip6_setting (NMConnection *connection,
NMIPRouteTableSyncMode route_table;
GString *ip_str1, *ip_str2, *ip_ptr;
NMSettingIP6ConfigAddrGenMode addr_gen_mode;
NMDhcpHostnameFlags flags;
const char *hostname;
int timeout;
NM_SET_OUT (out_route6_content, NULL);
@ -2690,7 +2671,32 @@ write_ip6_setting (NMConnection *connection,
svSetValueStr (ifcfg, "DHCPV6_IAID",
nm_setting_ip_config_get_dhcp_iaid (s_ip6));
write_ip6_setting_dhcp_hostname (s_ip6, ifcfg);
hostname = nm_setting_ip_config_get_dhcp_hostname (s_ip6);
svSetValueStr (ifcfg, "DHCPV6_HOSTNAME", hostname);
/* Missing DHCPV6_SEND_HOSTNAME means TRUE, and we prefer not write it
* explicitly in that case, because it is NM-specific variable
*/
if (!nm_setting_ip_config_get_dhcp_send_hostname (s_ip6))
svSetValueStr (ifcfg, "DHCPV6_SEND_HOSTNAME", "no");
timeout = nm_setting_ip6_config_get_ra_timeout (NM_SETTING_IP6_CONFIG (s_ip6));
svSetValueInt64_cond (ifcfg,
"IPV6_RA_TIMEOUT",
timeout != 0,
timeout);
timeout = nm_setting_ip_config_get_dhcp_timeout (s_ip6);
svSetValueInt64_cond (ifcfg,
"IPV6_DHCP_TIMEOUT",
timeout != 0,
timeout);
flags = nm_setting_ip_config_get_dhcp_hostname_flags (s_ip6);
svSetValueInt64_cond (ifcfg,
"DHCPV6_HOSTNAME_FLAGS",
flags != NM_DHCP_HOSTNAME_FLAG_NONE,
flags);
/* Write out IP addresses */
num = nm_setting_ip_config_get_num_addresses (s_ip6);