mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 05:10:09 +01:00
core,libnm: merge branch 'th/various-settings-cleanup-5'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/199
This commit is contained in:
commit
dcbf274e84
15 changed files with 823 additions and 520 deletions
|
|
@ -5186,6 +5186,9 @@ static const NMMetaPropertyInfo *const property_infos_CONNECTION[] = {
|
|||
),
|
||||
),
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_CONNECTION_WAIT_DEVICE_TIMEOUT,
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
NULL
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -152,6 +152,7 @@
|
|||
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_TIMESTAMP N_("The time, in seconds since the Unix Epoch, that the connection was last _successfully_ fully activated. NetworkManager updates the connection timestamp periodically when the connection is active to ensure that an active connection has the latest timestamp. The property is only meant for reading (changes to this property will not be preserved).")
|
||||
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_TYPE N_("Base type of the connection. For hardware-dependent connections, should contain the setting name of the hardware-type specific setting (ie, \"802-3-ethernet\" or \"802-11-wireless\" or \"bluetooth\", etc), and for non-hardware dependent connections like VPN or otherwise, should contain the setting name of that setting type (ie, \"vpn\" or \"bridge\", etc).")
|
||||
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_UUID N_("A universally unique identifier for the connection, for example generated with libuuid. It should be assigned when the connection is created, and never changed as long as the connection still applies to the same network. For example, it should not be changed when the \"id\" property or NMSettingIP4Config changes, but might need to be re-created when the Wi-Fi SSID, mobile broadband network provider, or \"type\" property changes. The UUID must be in the format \"2815492f-7e56-435e-b2e9-246bd7cdc664\" (ie, contains only hexadecimal characters and \"-\").")
|
||||
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_WAIT_DEVICE_TIMEOUT N_("Timeout in milliseconds to wait for device at startup. During boot, devices may take a while to be detected by the driver. This property will cause to delay NetworkManager-wait-online.service and nm-online to give the device a chance to appear. Note that this property only works together with NMSettingConnection:interface-name to identify the device that will be waited for. The value 0 means no wait time. The default value is -1, which currently has the same meaning as no wait time.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_CONNECTION_ZONE N_("The trust level of a the connection. Free form case-insensitive string (for example \"Home\", \"Work\", \"Public\"). NULL or unspecified zone means the connection will be placed in the default zone as defined by the firewall. When updating this property on a currently activated connection, the change takes effect immediately.")
|
||||
#define DESCRIBE_DOC_NM_SETTING_DCB_APP_FCOE_FLAGS N_("Specifies the NMSettingDcbFlags for the DCB FCoE application. Flags may be any combination of NM_SETTING_DCB_FLAG_ENABLE (0x1), NM_SETTING_DCB_FLAG_ADVERTISE (0x2), and NM_SETTING_DCB_FLAG_WILLING (0x4).")
|
||||
#define DESCRIBE_DOC_NM_SETTING_DCB_APP_FCOE_MODE N_("The FCoE controller mode; either \"fabric\" (default) or \"vn2vn\".")
|
||||
|
|
|
|||
|
|
@ -484,12 +484,12 @@ NAME UUID TYPE DEVICE
|
|||
con-1 5fcfd6d7-1e63-3332-8826-a7eda103792d ethernet --
|
||||
|
||||
<<<
|
||||
size: 1224
|
||||
size: 1267
|
||||
location: clients/tests/test-client.py:874:test_002()/23
|
||||
cmd: $NMCLI c s con-1
|
||||
lang: C
|
||||
returncode: 0
|
||||
stdout: 1095 bytes
|
||||
stdout: 1138 bytes
|
||||
>>>
|
||||
connection.id: con-1
|
||||
connection.uuid: 5fcfd6d7-1e63-3332-8826-a7eda103792d
|
||||
|
|
@ -514,14 +514,15 @@ connection.metered: unknown
|
|||
connection.lldp: default
|
||||
connection.mdns: -1 (default)
|
||||
connection.llmnr: -1 (default)
|
||||
connection.wait-device-timeout: -1
|
||||
|
||||
<<<
|
||||
size: 1236
|
||||
size: 1279
|
||||
location: clients/tests/test-client.py:874:test_002()/24
|
||||
cmd: $NMCLI c s con-1
|
||||
lang: pl_PL.UTF-8
|
||||
returncode: 0
|
||||
stdout: 1097 bytes
|
||||
stdout: 1140 bytes
|
||||
>>>
|
||||
connection.id: con-1
|
||||
connection.uuid: 5fcfd6d7-1e63-3332-8826-a7eda103792d
|
||||
|
|
@ -546,5 +547,6 @@ connection.metered: nieznane
|
|||
connection.lldp: default
|
||||
connection.mdns: -1 (default)
|
||||
connection.llmnr: -1 (default)
|
||||
connection.wait-device-timeout: -1
|
||||
|
||||
<<<
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -76,6 +76,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMSettingConnection,
|
|||
PROP_LLMNR,
|
||||
PROP_STABLE_ID,
|
||||
PROP_AUTH_RETRIES,
|
||||
PROP_WAIT_DEVICE_TIMEOUT,
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -102,6 +103,7 @@ typedef struct {
|
|||
int auth_retries;
|
||||
int mdns;
|
||||
int llmnr;
|
||||
int wait_device_timeout;
|
||||
} NMSettingConnectionPrivate;
|
||||
|
||||
G_DEFINE_TYPE (NMSettingConnection, nm_setting_connection, NM_TYPE_SETTING)
|
||||
|
|
@ -692,6 +694,23 @@ nm_setting_connection_is_slave_type (NMSettingConnection *setting,
|
|||
return !g_strcmp0 (NM_SETTING_CONNECTION_GET_PRIVATE (setting)->slave_type, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_connection_get_wait_device_timeout:
|
||||
* @setting: the #NMSettingConnection
|
||||
*
|
||||
* Returns: the %NM_SETTING_CONNECTION_WAIT_DEVICE_TIMEOUT property with
|
||||
* the timeout in milli seconds. -1 is the default.
|
||||
*
|
||||
* Since: 1.20
|
||||
*/
|
||||
gint32
|
||||
nm_setting_connection_get_wait_device_timeout (NMSettingConnection *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), -1);
|
||||
|
||||
return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->wait_device_timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_connection_get_autoconnect_slaves:
|
||||
* @setting: the #NMSettingConnection
|
||||
|
|
@ -1149,6 +1168,20 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if ( priv->wait_device_timeout != -1
|
||||
&& !priv->interface_name) {
|
||||
/* currently, only waiting by interface-name is implemented. Hence reject
|
||||
* configurations that are not implemented (yet). */
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("wait-device-timeout requires %s"),
|
||||
NM_SETTING_CONNECTION_INTERFACE_NAME);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME,
|
||||
NM_SETTING_CONNECTION_WAIT_DEVICE_TIMEOUT);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* *** errors above here should be always fatal, below NORMALIZABLE_ERROR *** */
|
||||
|
||||
if (!priv->uuid) {
|
||||
|
|
@ -1422,6 +1455,9 @@ get_property (GObject *object, guint prop_id,
|
|||
case PROP_LLMNR:
|
||||
g_value_set_int (value, priv->llmnr);
|
||||
break;
|
||||
case PROP_WAIT_DEVICE_TIMEOUT:
|
||||
g_value_set_int (value, priv->wait_device_timeout);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -1514,6 +1550,9 @@ set_property (GObject *object, guint prop_id,
|
|||
case PROP_LLMNR:
|
||||
priv->llmnr = g_value_get_int (value);
|
||||
break;
|
||||
case PROP_WAIT_DEVICE_TIMEOUT:
|
||||
priv->wait_device_timeout = g_value_get_int (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -1529,6 +1568,7 @@ nm_setting_connection_init (NMSettingConnection *setting)
|
|||
|
||||
priv->mdns = NM_SETTING_CONNECTION_MDNS_DEFAULT;
|
||||
priv->llmnr = NM_SETTING_CONNECTION_LLMNR_DEFAULT;
|
||||
priv->wait_device_timeout = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2206,6 +2246,38 @@ nm_setting_connection_class_init (NMSettingConnectionClass *klass)
|
|||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* NMSettingConnection:wait-device-timeout:
|
||||
*
|
||||
* Timeout in milliseconds to wait for device at startup.
|
||||
* During boot, devices may take a while to be detected by the driver.
|
||||
* This property will cause to delay NetworkManager-wait-online.service
|
||||
* and nm-online to give the device a chance to appear.
|
||||
*
|
||||
* Note that this property only works together with NMSettingConnection:interface-name
|
||||
* to identify the device that will be waited for.
|
||||
*
|
||||
* The value 0 means no wait time. The default value is -1, which
|
||||
* currently has the same meaning as no wait time.
|
||||
*
|
||||
* Since: 1.20
|
||||
**/
|
||||
/* ---ifcfg-rh---
|
||||
* property: wait-device-timeout
|
||||
* variable: DEVTIMEOUT(+)
|
||||
* values: timeout in seconds.
|
||||
* description: for initscripts compatibility, this variable must be
|
||||
* a whole integer. If necessary, NetworkManager stores also a fractional
|
||||
* component for the milliseconds.
|
||||
* example: DEVTIMEOUT=5
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_WAIT_DEVICE_TIMEOUT] =
|
||||
g_param_spec_int (NM_SETTING_CONNECTION_WAIT_DEVICE_TIMEOUT, "", "",
|
||||
-1, G_MAXINT32, -1,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
|
||||
_nm_setting_class_commit_full (setting_class, NM_META_SETTING_TYPE_CONNECTION,
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ G_BEGIN_DECLS
|
|||
#define NM_SETTING_CONNECTION_AUTH_RETRIES "auth-retries"
|
||||
#define NM_SETTING_CONNECTION_MDNS "mdns"
|
||||
#define NM_SETTING_CONNECTION_LLMNR "llmnr"
|
||||
#define NM_SETTING_CONNECTION_WAIT_DEVICE_TIMEOUT "wait-device-timeout"
|
||||
|
||||
/* Types for property values */
|
||||
/**
|
||||
|
|
@ -214,6 +215,9 @@ NMSettingConnectionMdns nm_setting_connection_get_mdns (NMSettingConnection *s
|
|||
NM_AVAILABLE_IN_1_14
|
||||
NMSettingConnectionLlmnr nm_setting_connection_get_llmnr (NMSettingConnection *setting);
|
||||
|
||||
NM_AVAILABLE_IN_1_20
|
||||
gint32 nm_setting_connection_get_wait_device_timeout (NMSettingConnection *setting);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NM_SETTING_CONNECTION_H__ */
|
||||
|
|
|
|||
|
|
@ -3024,6 +3024,7 @@ test_connection_diff_a_only (void)
|
|||
{ NM_SETTING_CONNECTION_AUTH_RETRIES, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_CONNECTION_MDNS, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_CONNECTION_LLMNR, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_CONNECTION_WAIT_DEVICE_TIMEOUT, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NULL, NM_SETTING_DIFF_RESULT_UNKNOWN }
|
||||
} },
|
||||
{ NM_SETTING_WIRED_SETTING_NAME, {
|
||||
|
|
|
|||
|
|
@ -1614,6 +1614,7 @@ global:
|
|||
nm_device_modem_get_apn;
|
||||
nm_device_modem_get_device_id;
|
||||
nm_device_modem_get_operator_code;
|
||||
nm_setting_connection_get_wait_device_timeout;
|
||||
nm_setting_ethtool_get_optnames;
|
||||
nm_setting_ovs_dpdk_get_devargs;
|
||||
nm_setting_ovs_dpdk_get_type;
|
||||
|
|
|
|||
|
|
@ -199,3 +199,25 @@ nm_pstr_equal (gconstpointer a, gconstpointer b)
|
|||
&& s2
|
||||
&& nm_streq0 (*s1, *s2));
|
||||
}
|
||||
|
||||
guint
|
||||
nm_pdirect_hash (gconstpointer p)
|
||||
{
|
||||
const void *const*s = p;
|
||||
|
||||
if (!s)
|
||||
return nm_hash_static (1852748873u);
|
||||
return nm_direct_hash (*s);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_pdirect_equal (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
const void *const*s1 = a;
|
||||
const void *const*s2 = b;
|
||||
|
||||
return (s1 == s2)
|
||||
|| ( s1
|
||||
&& s2
|
||||
&& *s1 == *s2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -290,6 +290,15 @@ gboolean nm_pstr_equal (gconstpointer a, gconstpointer b);
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* this hashes/compares the pointer value that we point to. Basically,
|
||||
* (((const void *const*) a) == ((const void *const*) b)). */
|
||||
|
||||
guint nm_pdirect_hash (gconstpointer p);
|
||||
|
||||
gboolean nm_pdirect_equal (gconstpointer a, gconstpointer b);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define NM_HASH_OBFUSCATE_PTR_FMT "%016" G_GINT64_MODIFIER "x"
|
||||
|
||||
/* sometimes we want to log a pointer directly, for providing context/information about
|
||||
|
|
|
|||
|
|
@ -202,6 +202,9 @@ nm_ip4_addr_is_localhost (in_addr_t addr4)
|
|||
#define NM_CMP_DIRECT_MEMCMP(a, b, size) \
|
||||
NM_CMP_RETURN (memcmp ((a), (b), (size)))
|
||||
|
||||
#define NM_CMP_DIRECT_STRCMP(a, b) \
|
||||
NM_CMP_RETURN_DIRECT (strcmp ((a), (b)))
|
||||
|
||||
#define NM_CMP_DIRECT_STRCMP0(a, b) \
|
||||
NM_CMP_RETURN_DIRECT (nm_strcmp0 ((a), (b)))
|
||||
|
||||
|
|
@ -759,7 +762,13 @@ nm_utils_error_set_literal (GError **error, int error_code, const char *literal)
|
|||
}
|
||||
|
||||
#define nm_utils_error_set(error, error_code, ...) \
|
||||
g_set_error ((error), NM_UTILS_ERROR, error_code, __VA_ARGS__)
|
||||
G_STMT_START { \
|
||||
if (NM_NARG (__VA_ARGS__) == 1) { \
|
||||
g_set_error_literal ((error), NM_UTILS_ERROR, (error_code), _NM_UTILS_MACRO_FIRST (__VA_ARGS__)); \
|
||||
} else { \
|
||||
g_set_error ((error), NM_UTILS_ERROR, (error_code), __VA_ARGS__); \
|
||||
} \
|
||||
} G_STMT_END
|
||||
|
||||
#define nm_utils_error_set_errno(error, errsv, fmt, ...) \
|
||||
G_STMT_START { \
|
||||
|
|
|
|||
|
|
@ -2157,9 +2157,7 @@ _delete_volatile_connection_all (NMManager *self, gboolean do_delete)
|
|||
while ((elem = c_list_first_entry (&priv->delete_volatile_connection_lst_head, NMCListElem, lst))) {
|
||||
gs_unref_object NMSettingsConnection *connection = NULL;
|
||||
|
||||
connection = elem->data;
|
||||
nm_c_list_elem_free (elem);
|
||||
|
||||
connection = nm_c_list_elem_free_steal (elem);
|
||||
if (do_delete)
|
||||
_delete_volatile_connection_do (self, connection);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -542,6 +542,37 @@ make_connection_setting (const char *file,
|
|||
vint64 = svGetValueInt64 (ifcfg, "AUTH_RETRIES", 10, -1, G_MAXINT32, -1);
|
||||
g_object_set (s_con, NM_SETTING_CONNECTION_AUTH_RETRIES, (int) vint64, NULL);
|
||||
|
||||
nm_clear_g_free (&value);
|
||||
v = svGetValueStr (ifcfg, "DEVTIMEOUT", &value);
|
||||
if (v) {
|
||||
vint64 = _nm_utils_ascii_str_to_int64 (v, 10, 0, ((gint64) G_MAXINT32) / 1000, -1);
|
||||
if (vint64 != -1)
|
||||
vint64 *= 1000;
|
||||
else {
|
||||
char *endptr;
|
||||
double d;
|
||||
|
||||
d = g_ascii_strtod (v, &endptr);
|
||||
if ( errno == 0
|
||||
&& endptr[0] == '\0'
|
||||
&& d >= 0.0) {
|
||||
d *= 1000.0;
|
||||
|
||||
/* We round. Yes, this is not correct to round IEEE 754 floats in general,
|
||||
* but sufficient for our case where we know that NetworkManager wrote the
|
||||
* setting with up to 3 digits for the milliseconds. */
|
||||
d += 0.5;
|
||||
if ( d >= 0.0
|
||||
&& d <= (double) G_MAXINT32)
|
||||
vint64 = (gint64) d;
|
||||
}
|
||||
}
|
||||
if (vint64 == -1)
|
||||
PARSE_WARNING ("invalid DEVTIMEOUT setting");
|
||||
else
|
||||
g_object_set (s_con, NM_SETTING_CONNECTION_WAIT_DEVICE_TIMEOUT, (int) vint64, NULL);
|
||||
}
|
||||
|
||||
i_val = NM_SETTING_CONNECTION_MDNS_DEFAULT;
|
||||
if (!svGetValueEnum (ifcfg, "MDNS",
|
||||
nm_setting_connection_mdns_get_type (),
|
||||
|
|
|
|||
|
|
@ -1849,6 +1849,7 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg)
|
|||
GString *str;
|
||||
const char *master, *master_iface = NULL, *type;
|
||||
int vint;
|
||||
gint32 vint32;
|
||||
NMSettingConnectionMdns mdns;
|
||||
NMSettingConnectionLlmnr llmnr;
|
||||
guint32 vuint32;
|
||||
|
|
@ -2015,6 +2016,19 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg)
|
|||
vint = nm_setting_connection_get_auth_retries (s_con);
|
||||
svSetValueInt64_cond (ifcfg, "AUTH_RETRIES", vint >= 0, vint);
|
||||
|
||||
vint32 = nm_setting_connection_get_wait_device_timeout (s_con);
|
||||
if (vint32 == -1)
|
||||
svUnsetValue (ifcfg, "DEVTIMEOUT");
|
||||
else if ((vint32 % 1000) == 0)
|
||||
svSetValueInt64 (ifcfg, "DEVTIMEOUT", vint32 / 1000);
|
||||
else {
|
||||
char b[100];
|
||||
|
||||
svSetValueStr (ifcfg,
|
||||
"DEVTIMEOUT",
|
||||
nm_sprintf_buf (b, "%.3f", ((double) vint) / 1000.0));
|
||||
}
|
||||
|
||||
mdns = nm_setting_connection_get_mdns (s_con);
|
||||
if (mdns != NM_SETTING_CONNECTION_MDNS_DEFAULT) {
|
||||
svSetValueEnum (ifcfg, "MDNS", nm_setting_connection_mdns_get_type (),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue