libnm,cli,ifcfg-rh: add ipv6.ra-timeout configuration option

This commit is contained in:
Thomas Haller 2020-02-13 15:41:35 +01:00
parent 0d8f55a1cb
commit de4aeb34e3
11 changed files with 718 additions and 513 deletions

View file

@ -5898,6 +5898,10 @@ 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,
),

View file

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

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

@ -2206,6 +2206,7 @@ make_ip6_setting (shvarFile *ifcfg,
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);

View file

@ -815,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[228];
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

@ -2680,6 +2680,12 @@ write_ip6_setting (NMConnection *connection,
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",