device: make carrier-wait-timeout configurable per device
As this depends on the particular host configuration, it's hard to find a default that suits everybody. At least make it configurable per-device. https://bugzilla.redhat.com/show_bug.cgi?id=1483343 https://bugzilla.redhat.com/show_bug.cgi?id=1515027
This commit is contained in:
@@ -856,6 +856,24 @@ managed=1
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry id="carrier-wait-timeout">
|
||||
<term><varname>carrier-wait-timeout</varname></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specify the timeout for waiting for carrier in milliseconds.
|
||||
When the device loses carrier, NetworkManager does not react
|
||||
immediately. Instead, it waits for this timeout before considering
|
||||
the link lost. Also, on startup, NetworkManager considers the
|
||||
device as busy for this time, as long as the device has no carrier.
|
||||
This delays startup-complete signal and NetworkManager-wait-online.
|
||||
Configuring this too high means to block NetworkManager-wait-online
|
||||
longer then necessary. Configuring it too low, means that NetworkManager
|
||||
will declare startup-complete, although carrier is about to come
|
||||
and auto-activation to kick in.
|
||||
The default is 5000 milliseconds.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry id="ignore-carrier">
|
||||
<term><varname>ignore-carrier</varname></term>
|
||||
<listitem>
|
||||
|
@@ -328,7 +328,7 @@ typedef struct _NMDevicePrivate {
|
||||
guint32 v4_route_table;
|
||||
guint32 v6_route_table;
|
||||
|
||||
/* when carrier goes away, we give a grace period of CARRIER_WAIT_TIME_MS
|
||||
/* when carrier goes away, we give a grace period of _get_carrier_wait_ms()
|
||||
* until taking action.
|
||||
*
|
||||
* When changing MTU, the device might take longer then that. So, whenever
|
||||
@@ -10698,6 +10698,18 @@ nm_device_is_up (NMDevice *self)
|
||||
return ifindex > 0 ? nm_platform_link_is_up (nm_device_get_platform (self), ifindex) : TRUE;
|
||||
}
|
||||
|
||||
static gint64
|
||||
_get_carrier_wait_ms (NMDevice *self)
|
||||
{
|
||||
gs_free char *value = NULL;
|
||||
|
||||
value = nm_config_data_get_device_config (NM_CONFIG_GET_DATA,
|
||||
NM_CONFIG_KEYFILE_KEY_DEVICE_CARRIER_WAIT_TIMEOUT,
|
||||
self,
|
||||
NULL);
|
||||
return _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXINT32, CARRIER_WAIT_TIME_MS);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
|
||||
{
|
||||
@@ -10772,7 +10784,7 @@ nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
|
||||
nm_device_add_pending_action (self, NM_PENDING_ACTION_CARRIER_WAIT, FALSE);
|
||||
|
||||
now_ms = nm_utils_get_monotonic_timestamp_ms ();
|
||||
until_ms = NM_MAX (now_ms + CARRIER_WAIT_TIME_MS, priv->carrier_wait_until_ms);
|
||||
until_ms = NM_MAX (now_ms + _get_carrier_wait_ms (self), priv->carrier_wait_until_ms);
|
||||
priv->carrier_wait_id = g_timeout_add (until_ms - now_ms, carrier_wait_timeout, self);
|
||||
}
|
||||
|
||||
|
@@ -79,6 +79,7 @@
|
||||
#define NM_CONFIG_KEYFILE_KEY_DEVICE_MANAGED "managed"
|
||||
#define NM_CONFIG_KEYFILE_KEY_DEVICE_IGNORE_CARRIER "ignore-carrier"
|
||||
#define NM_CONFIG_KEYFILE_KEY_DEVICE_SRIOV_NUM_VFS "sriov-num-vfs"
|
||||
#define NM_CONFIG_KEYFILE_KEY_DEVICE_CARRIER_WAIT_TIMEOUT "carrier-wait-timeout"
|
||||
|
||||
#define NM_CONFIG_KEYFILE_KEYPREFIX_WAS ".was."
|
||||
#define NM_CONFIG_KEYFILE_KEYPREFIX_SET ".set."
|
||||
|
Reference in New Issue
Block a user