diff options
author | Thomas Haller <thaller@redhat.com> | 2017-11-28 10:32:56 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-11-28 10:33:28 +0100 |
commit | 245590bacd30314039913d437c2dee9c9f23a366 (patch) | |
tree | 9edf99828c73c1f148eaae3d18515249537c920c | |
parent | e4099f67640176bce91c2fcb89f1145c4bd264af (diff) | |
download | NetworkManager-245590bacd30314039913d437c2dee9c9f23a366.tar.gz |
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.
-rw-r--r-- | src/devices/nm-device.c | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 95237205bd..83480096b2 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -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); @@ -2528,7 +2525,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); @@ -7415,7 +7412,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 @@ -7434,9 +7430,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 ()) { @@ -7451,9 +7445,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 @@ -12581,12 +12573,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]; |