device: use same values for carrier-wait and carrier-defer time

Waiting for carrier on startup is probably the same times that carrier
needs, e.g. on an MTU change. Use the same timing.

Note, that as carrier-wait-timeout is no configurable, this
configuration applies to both -- as the manual page already
claims to do.

(cherry picked from commit 245590bacd)
This commit is contained in:
Thomas Haller 2017-11-28 10:32:56 +01:00
parent d8b786570c
commit 27e38c77dd

View file

@ -89,9 +89,6 @@ _LOG_DECLARE_SELF (NMDevice);
#define CARRIER_WAIT_TIME_MS 5000
#define CARRIER_WAIT_TIME_AFTER_MTU_MS 10000
#define CARRIER_DEFER_TIME_MS 4000
#define CARRIER_DEFER_TIME_AFTER_MTU_MS 10000
#define NM_DEVICE_AUTH_RETRIES_UNSET -1
#define NM_DEVICE_AUTH_RETRIES_INFINITY -2
#define NM_DEVICE_AUTH_RETRIES_DEFAULT 3
@ -338,7 +335,6 @@ typedef struct _NMDevicePrivate {
* NM changes the MTU it sets @carrier_wait_until_ms to CARRIER_WAIT_TIME_AFTER_MTU_MS
* in the future. This is used to extend the grace period in this particular case. */
gint64 carrier_wait_until_ms;
gint64 carrier_defer_until_ms;
bool carrier:1;
bool ignore_carrier:1;
@ -534,6 +530,7 @@ static gboolean addrconf6_start_with_link_ready (NMDevice *self);
static NMActStageReturn linklocal6_start (NMDevice *self);
static void _carrier_wait_check_queued_act_request (NMDevice *self);
static gint64 _get_carrier_wait_ms (NMDevice *self);
static const char *_activation_func_to_string (ActivationHandleFunc func);
static void activation_source_handle_cb (NMDevice *self, int addr_family);
@ -2527,7 +2524,7 @@ nm_device_set_carrier (NMDevice *self, gboolean carrier)
gint64 now_ms, until_ms;
now_ms = nm_utils_get_monotonic_timestamp_ms ();
until_ms = NM_MAX (now_ms + CARRIER_DEFER_TIME_MS, priv->carrier_defer_until_ms);
until_ms = NM_MAX (now_ms + _get_carrier_wait_ms (self), priv->carrier_wait_until_ms);
priv->carrier_defer_id = g_timeout_add (until_ms - now_ms, carrier_disconnected_action_cb, self);
_LOGD (LOGD_DEVICE, "carrier: link disconnected (deferring action for %ld milli seconds) (id=%u)",
(long) (until_ms - now_ms), priv->carrier_defer_id);
@ -7414,7 +7411,6 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config)
if ( (mtu_desired && mtu_desired != mtu_plat)
|| (ip6_mtu && ip6_mtu != _IP6_MTU_SYS ())) {
gboolean anticipated_failure = FALSE;
gint64 now_ms;
if (!priv->mtu_initial && !priv->ip6_mtu_initial) {
/* before touching any of the MTU paramters, record the
@ -7433,9 +7429,7 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config)
? "Are the MTU sizes of the slaves large enough?"
: "Did you configure the MTU correctly?"));
}
now_ms = nm_utils_get_monotonic_timestamp_ms ();
priv->carrier_wait_until_ms = now_ms + CARRIER_WAIT_TIME_AFTER_MTU_MS;
priv->carrier_defer_until_ms = now_ms + CARRIER_DEFER_TIME_AFTER_MTU_MS;
priv->carrier_wait_until_ms = nm_utils_get_monotonic_timestamp_ms () + CARRIER_WAIT_TIME_AFTER_MTU_MS;
}
if (ip6_mtu && ip6_mtu != _IP6_MTU_SYS ()) {
@ -7450,9 +7444,7 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config)
? ": Is the underlying MTU value successfully set?"
: "");
}
now_ms = nm_utils_get_monotonic_timestamp_ms ();
priv->carrier_wait_until_ms = now_ms + CARRIER_WAIT_TIME_AFTER_MTU_MS;
priv->carrier_defer_until_ms = now_ms + CARRIER_DEFER_TIME_AFTER_MTU_MS;
priv->carrier_wait_until_ms = nm_utils_get_monotonic_timestamp_ms () + CARRIER_WAIT_TIME_AFTER_MTU_MS;
}
}
#undef _IP6_MTU_SYS
@ -12580,12 +12572,8 @@ nm_device_cleanup (NMDevice *self, NMDeviceStateReason reason, CleanupType clean
_LOGT (LOGD_DEVICE, "mtu: reset device-mtu: %u, ipv6-mtu: %u, ifindex: %d",
(guint) priv->mtu_initial, (guint) priv->ip6_mtu_initial, ifindex);
if (priv->mtu_initial) {
gint64 now;
nm_platform_link_set_mtu (nm_device_get_platform (self), ifindex, priv->mtu_initial);
now = nm_utils_get_monotonic_timestamp_ms ();
priv->carrier_wait_until_ms = now + CARRIER_WAIT_TIME_AFTER_MTU_MS;
priv->carrier_defer_until_ms = now + CARRIER_DEFER_TIME_AFTER_MTU_MS;
priv->carrier_wait_until_ms = nm_utils_get_monotonic_timestamp_ms () + CARRIER_WAIT_TIME_AFTER_MTU_MS;
}
if (priv->ip6_mtu_initial) {
char sbuf[64];