Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 620662 | Differences between
and this patch

Collapse All | Expand All

(-)a/man/NetworkManager.conf.xml (+18 lines)
Lines 856-861 managed=1 Link Here
856
            </para>
856
            </para>
857
          </listitem>
857
          </listitem>
858
        </varlistentry>
858
        </varlistentry>
859
        <varlistentry id="carrier-wait-timeout">
860
          <term><varname>carrier-wait-timeout</varname></term>
861
          <listitem>
862
            <para>
863
              Specify the timeout for waiting for carrier in milliseconds.
864
              When the device loses carrier, NetworkManager does not react
865
              immediately. Instead, it waits for this timeout before considering
866
              the link lost. Also, on startup, NetworkManager considers the
867
              device as busy for this time, as long as the device has no carrier.
868
              This delays startup-complete signal and NetworkManager-wait-online.
869
              Configuring this too high means to block NetworkManager-wait-online
870
              longer then necessary. Configuring it too low, means that NetworkManager
871
              will declare startup-complete, although carrier is about to come
872
              and auto-activation to kick in.
873
              The default is 5000 milliseconds.
874
            </para>
875
          </listitem>
876
        </varlistentry>
859
        <varlistentry id="ignore-carrier">
877
        <varlistentry id="ignore-carrier">
860
          <term><varname>ignore-carrier</varname></term>
878
          <term><varname>ignore-carrier</varname></term>
861
          <listitem>
879
          <listitem>
(-)a/src/devices/nm-device.c (-2 / +14 lines)
Lines 328-334 typedef struct _NMDevicePrivate { Link Here
328
	guint32         v4_route_table;
328
	guint32         v4_route_table;
329
	guint32         v6_route_table;
329
	guint32         v6_route_table;
330
330
331
	/* when carrier goes away, we give a grace period of CARRIER_WAIT_TIME_MS
331
	/* when carrier goes away, we give a grace period of _get_carrier_wait_ms()
332
	 * until taking action.
332
	 * until taking action.
333
	 *
333
	 *
334
	 * When changing MTU, the device might take longer then that. So, whenever
334
	 * When changing MTU, the device might take longer then that. So, whenever
Lines 10698-10703 nm_device_is_up (NMDevice *self) Link Here
10698
	return ifindex > 0 ? nm_platform_link_is_up (nm_device_get_platform (self), ifindex) : TRUE;
10698
	return ifindex > 0 ? nm_platform_link_is_up (nm_device_get_platform (self), ifindex) : TRUE;
10699
}
10699
}
10700
10700
10701
static gint64
10702
_get_carrier_wait_ms (NMDevice *self)
10703
{
10704
	gs_free char *value = NULL;
10705
10706
	value = nm_config_data_get_device_config (NM_CONFIG_GET_DATA,
10707
	                                          NM_CONFIG_KEYFILE_KEY_DEVICE_CARRIER_WAIT_TIMEOUT,
10708
	                                          self,
10709
	                                          NULL);
10710
	return _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXINT32, CARRIER_WAIT_TIME_MS);
10711
}
10712
10701
gboolean
10713
gboolean
10702
nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
10714
nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
10703
{
10715
{
Lines 10772-10778 nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware) Link Here
10772
			nm_device_add_pending_action (self, NM_PENDING_ACTION_CARRIER_WAIT, FALSE);
10784
			nm_device_add_pending_action (self, NM_PENDING_ACTION_CARRIER_WAIT, FALSE);
10773
10785
10774
		now_ms = nm_utils_get_monotonic_timestamp_ms ();
10786
		now_ms = nm_utils_get_monotonic_timestamp_ms ();
10775
		until_ms = NM_MAX (now_ms + CARRIER_WAIT_TIME_MS, priv->carrier_wait_until_ms);
10787
		until_ms = NM_MAX (now_ms + _get_carrier_wait_ms (self), priv->carrier_wait_until_ms);
10776
		priv->carrier_wait_id = g_timeout_add (until_ms - now_ms, carrier_wait_timeout, self);
10788
		priv->carrier_wait_id = g_timeout_add (until_ms - now_ms, carrier_wait_timeout, self);
10777
	}
10789
	}
10778
10790
(-)a/src/nm-config.h (-1 / +1 lines)
Lines 79-84 Link Here
79
#define NM_CONFIG_KEYFILE_KEY_DEVICE_MANAGED                "managed"
79
#define NM_CONFIG_KEYFILE_KEY_DEVICE_MANAGED                "managed"
80
#define NM_CONFIG_KEYFILE_KEY_DEVICE_IGNORE_CARRIER         "ignore-carrier"
80
#define NM_CONFIG_KEYFILE_KEY_DEVICE_IGNORE_CARRIER         "ignore-carrier"
81
#define NM_CONFIG_KEYFILE_KEY_DEVICE_SRIOV_NUM_VFS          "sriov-num-vfs"
81
#define NM_CONFIG_KEYFILE_KEY_DEVICE_SRIOV_NUM_VFS          "sriov-num-vfs"
82
#define NM_CONFIG_KEYFILE_KEY_DEVICE_CARRIER_WAIT_TIMEOUT   "carrier-wait-timeout"
82
83
83
#define NM_CONFIG_KEYFILE_KEYPREFIX_WAS                     ".was."
84
#define NM_CONFIG_KEYFILE_KEYPREFIX_WAS                     ".was."
84
#define NM_CONFIG_KEYFILE_KEYPREFIX_SET                     ".set."
85
#define NM_CONFIG_KEYFILE_KEYPREFIX_SET                     ".set."
85
- 
(-)a/src/devices/nm-device.c (-10 / +23 lines)
Lines 89-94 _LOG_DECLARE_SELF (NMDevice); Link Here
89
#define CARRIER_WAIT_TIME_MS 5000
89
#define CARRIER_WAIT_TIME_MS 5000
90
#define CARRIER_WAIT_TIME_AFTER_MTU_MS 10000
90
#define CARRIER_WAIT_TIME_AFTER_MTU_MS 10000
91
91
92
#define CARRIER_DEFER_TIME_MS 4000
93
#define CARRIER_DEFER_TIME_AFTER_MTU_MS 10000
94
92
#define NM_DEVICE_AUTH_RETRIES_UNSET    -1
95
#define NM_DEVICE_AUTH_RETRIES_UNSET    -1
93
#define NM_DEVICE_AUTH_RETRIES_INFINITY -2
96
#define NM_DEVICE_AUTH_RETRIES_INFINITY -2
94
#define NM_DEVICE_AUTH_RETRIES_DEFAULT  3
97
#define NM_DEVICE_AUTH_RETRIES_DEFAULT  3
Lines 335-340 typedef struct _NMDevicePrivate { Link Here
335
	 * NM changes the MTU it sets @carrier_wait_until_ms to CARRIER_WAIT_TIME_AFTER_MTU_MS
338
	 * NM changes the MTU it sets @carrier_wait_until_ms to CARRIER_WAIT_TIME_AFTER_MTU_MS
336
	 * in the future. This is used to extend the grace period in this particular case. */
339
	 * in the future. This is used to extend the grace period in this particular case. */
337
	gint64          carrier_wait_until_ms;
340
	gint64          carrier_wait_until_ms;
341
	gint64          carrier_defer_until_ms;
338
342
339
	bool            carrier:1;
343
	bool            carrier:1;
340
	bool            ignore_carrier:1;
344
	bool            ignore_carrier:1;
Lines 2465-2472 carrier_changed (NMDevice *self, gboolean carrier) Link Here
2465
	}
2469
	}
2466
}
2470
}
2467
2471
2468
#define LINK_DISCONNECT_DELAY 4
2469
2470
static gboolean
2472
static gboolean
2471
carrier_disconnected_action_cb (gpointer user_data)
2473
carrier_disconnected_action_cb (gpointer user_data)
2472
{
2474
{
Lines 2523-2532 nm_device_set_carrier (NMDevice *self, gboolean carrier) Link Here
2523
			_LOGD (LOGD_DEVICE, "carrier: link disconnected");
2525
			_LOGD (LOGD_DEVICE, "carrier: link disconnected");
2524
			carrier_changed (self, FALSE);
2526
			carrier_changed (self, FALSE);
2525
		} else {
2527
		} else {
2526
			priv->carrier_defer_id = g_timeout_add_seconds (LINK_DISCONNECT_DELAY,
2528
			gint64 now_ms, until_ms;
2527
			                                                carrier_disconnected_action_cb, self);
2529
2528
			_LOGD (LOGD_DEVICE, "carrier: link disconnected (deferring action for %d seconds) (id=%u)",
2530
			now_ms = nm_utils_get_monotonic_timestamp_ms ();
2529
			       LINK_DISCONNECT_DELAY, priv->carrier_defer_id);
2531
			until_ms = NM_MAX (now_ms + CARRIER_DEFER_TIME_MS, priv->carrier_defer_until_ms);
2532
			priv->carrier_defer_id = g_timeout_add (until_ms - now_ms, carrier_disconnected_action_cb, self);
2533
			_LOGD (LOGD_DEVICE, "carrier: link disconnected (deferring action for %ld milli seconds) (id=%u)",
2534
			       (long) (until_ms - now_ms), priv->carrier_defer_id);
2530
		}
2535
		}
2531
	}
2536
	}
2532
}
2537
}
Lines 7410-7415 _commit_mtu (NMDevice *self, const NMIP4Config *config) Link Here
7410
	if (   (mtu_desired && mtu_desired != mtu_plat)
7415
	if (   (mtu_desired && mtu_desired != mtu_plat)
7411
	    || (ip6_mtu && ip6_mtu != _IP6_MTU_SYS ())) {
7416
	    || (ip6_mtu && ip6_mtu != _IP6_MTU_SYS ())) {
7412
		gboolean anticipated_failure = FALSE;
7417
		gboolean anticipated_failure = FALSE;
7418
		gint64 now_ms;
7413
7419
7414
		if (!priv->mtu_initial && !priv->ip6_mtu_initial) {
7420
		if (!priv->mtu_initial && !priv->ip6_mtu_initial) {
7415
			/* before touching any of the MTU paramters, record the
7421
			/* before touching any of the MTU paramters, record the
Lines 7428-7434 _commit_mtu (NMDevice *self, const NMIP4Config *config) Link Here
7428
				              ? "Are the MTU sizes of the slaves large enough?"
7434
				              ? "Are the MTU sizes of the slaves large enough?"
7429
				              : "Did you configure the MTU correctly?"));
7435
				              : "Did you configure the MTU correctly?"));
7430
			}
7436
			}
7431
			priv->carrier_wait_until_ms = nm_utils_get_monotonic_timestamp_ms () + CARRIER_WAIT_TIME_AFTER_MTU_MS;
7437
			now_ms = nm_utils_get_monotonic_timestamp_ms ();
7438
			priv->carrier_wait_until_ms = now_ms + CARRIER_WAIT_TIME_AFTER_MTU_MS;
7439
			priv->carrier_defer_until_ms = now_ms + CARRIER_DEFER_TIME_AFTER_MTU_MS;
7432
		}
7440
		}
7433
7441
7434
		if (ip6_mtu && ip6_mtu != _IP6_MTU_SYS ()) {
7442
		if (ip6_mtu && ip6_mtu != _IP6_MTU_SYS ()) {
Lines 7443-7449 _commit_mtu (NMDevice *self, const NMIP4Config *config) Link Here
7443
				           ? ": Is the underlying MTU value successfully set?"
7451
				           ? ": Is the underlying MTU value successfully set?"
7444
				           : "");
7452
				           : "");
7445
			}
7453
			}
7446
			priv->carrier_wait_until_ms = nm_utils_get_monotonic_timestamp_ms () + CARRIER_WAIT_TIME_AFTER_MTU_MS;
7454
			now_ms = nm_utils_get_monotonic_timestamp_ms ();
7455
			priv->carrier_wait_until_ms = now_ms + CARRIER_WAIT_TIME_AFTER_MTU_MS;
7456
			priv->carrier_defer_until_ms = now_ms + CARRIER_DEFER_TIME_AFTER_MTU_MS;
7447
		}
7457
		}
7448
	}
7458
	}
7449
#undef _IP6_MTU_SYS
7459
#undef _IP6_MTU_SYS
Lines 12571-12578 nm_device_cleanup (NMDevice *self, NMDeviceStateReason reason, CleanupType clean Link Here
12571
			_LOGT (LOGD_DEVICE, "mtu: reset device-mtu: %u, ipv6-mtu: %u, ifindex: %d",
12581
			_LOGT (LOGD_DEVICE, "mtu: reset device-mtu: %u, ipv6-mtu: %u, ifindex: %d",
12572
			       (guint) priv->mtu_initial, (guint) priv->ip6_mtu_initial, ifindex);
12582
			       (guint) priv->mtu_initial, (guint) priv->ip6_mtu_initial, ifindex);
12573
			if (priv->mtu_initial) {
12583
			if (priv->mtu_initial) {
12584
				gint64 now;
12585
12574
				nm_platform_link_set_mtu (nm_device_get_platform (self), ifindex, priv->mtu_initial);
12586
				nm_platform_link_set_mtu (nm_device_get_platform (self), ifindex, priv->mtu_initial);
12575
				priv->carrier_wait_until_ms = nm_utils_get_monotonic_timestamp_ms () + CARRIER_WAIT_TIME_AFTER_MTU_MS;
12587
				now = nm_utils_get_monotonic_timestamp_ms ();
12588
				priv->carrier_wait_until_ms = now + CARRIER_WAIT_TIME_AFTER_MTU_MS;
12589
				priv->carrier_defer_until_ms = now + CARRIER_DEFER_TIME_AFTER_MTU_MS;
12576
			}
12590
			}
12577
			if (priv->ip6_mtu_initial) {
12591
			if (priv->ip6_mtu_initial) {
12578
				char sbuf[64];
12592
				char sbuf[64];
12579
- 
(-)a/src/devices/nm-device.c (-18 / +5 lines)
Lines 89-97 _LOG_DECLARE_SELF (NMDevice); Link Here
89
#define CARRIER_WAIT_TIME_MS 5000
89
#define CARRIER_WAIT_TIME_MS 5000
90
#define CARRIER_WAIT_TIME_AFTER_MTU_MS 10000
90
#define CARRIER_WAIT_TIME_AFTER_MTU_MS 10000
91
91
92
#define CARRIER_DEFER_TIME_MS 4000
93
#define CARRIER_DEFER_TIME_AFTER_MTU_MS 10000
94
95
#define NM_DEVICE_AUTH_RETRIES_UNSET    -1
92
#define NM_DEVICE_AUTH_RETRIES_UNSET    -1
96
#define NM_DEVICE_AUTH_RETRIES_INFINITY -2
93
#define NM_DEVICE_AUTH_RETRIES_INFINITY -2
97
#define NM_DEVICE_AUTH_RETRIES_DEFAULT  3
94
#define NM_DEVICE_AUTH_RETRIES_DEFAULT  3
Lines 338-344 typedef struct _NMDevicePrivate { Link Here
338
	 * NM changes the MTU it sets @carrier_wait_until_ms to CARRIER_WAIT_TIME_AFTER_MTU_MS
335
	 * NM changes the MTU it sets @carrier_wait_until_ms to CARRIER_WAIT_TIME_AFTER_MTU_MS
339
	 * in the future. This is used to extend the grace period in this particular case. */
336
	 * in the future. This is used to extend the grace period in this particular case. */
340
	gint64          carrier_wait_until_ms;
337
	gint64          carrier_wait_until_ms;
341
	gint64          carrier_defer_until_ms;
342
338
343
	bool            carrier:1;
339
	bool            carrier:1;
344
	bool            ignore_carrier:1;
340
	bool            ignore_carrier:1;
Lines 534-539 static gboolean addrconf6_start_with_link_ready (NMDevice *self); Link Here
534
static NMActStageReturn linklocal6_start (NMDevice *self);
530
static NMActStageReturn linklocal6_start (NMDevice *self);
535
531
536
static void _carrier_wait_check_queued_act_request (NMDevice *self);
532
static void _carrier_wait_check_queued_act_request (NMDevice *self);
533
static gint64 _get_carrier_wait_ms (NMDevice *self);
537
534
538
static const char *_activation_func_to_string (ActivationHandleFunc func);
535
static const char *_activation_func_to_string (ActivationHandleFunc func);
539
static void activation_source_handle_cb (NMDevice *self, int addr_family);
536
static void activation_source_handle_cb (NMDevice *self, int addr_family);
Lines 2528-2534 nm_device_set_carrier (NMDevice *self, gboolean carrier) Link Here
2528
			gint64 now_ms, until_ms;
2525
			gint64 now_ms, until_ms;
2529
2526
2530
			now_ms = nm_utils_get_monotonic_timestamp_ms ();
2527
			now_ms = nm_utils_get_monotonic_timestamp_ms ();
2531
			until_ms = NM_MAX (now_ms + CARRIER_DEFER_TIME_MS, priv->carrier_defer_until_ms);
2528
			until_ms = NM_MAX (now_ms + _get_carrier_wait_ms (self), priv->carrier_wait_until_ms);
2532
			priv->carrier_defer_id = g_timeout_add (until_ms - now_ms, carrier_disconnected_action_cb, self);
2529
			priv->carrier_defer_id = g_timeout_add (until_ms - now_ms, carrier_disconnected_action_cb, self);
2533
			_LOGD (LOGD_DEVICE, "carrier: link disconnected (deferring action for %ld milli seconds) (id=%u)",
2530
			_LOGD (LOGD_DEVICE, "carrier: link disconnected (deferring action for %ld milli seconds) (id=%u)",
2534
			       (long) (until_ms - now_ms), priv->carrier_defer_id);
2531
			       (long) (until_ms - now_ms), priv->carrier_defer_id);
Lines 7415-7421 _commit_mtu (NMDevice *self, const NMIP4Config *config) Link Here
7415
	if (   (mtu_desired && mtu_desired != mtu_plat)
7412
	if (   (mtu_desired && mtu_desired != mtu_plat)
7416
	    || (ip6_mtu && ip6_mtu != _IP6_MTU_SYS ())) {
7413
	    || (ip6_mtu && ip6_mtu != _IP6_MTU_SYS ())) {
7417
		gboolean anticipated_failure = FALSE;
7414
		gboolean anticipated_failure = FALSE;
7418
		gint64 now_ms;
7419
7415
7420
		if (!priv->mtu_initial && !priv->ip6_mtu_initial) {
7416
		if (!priv->mtu_initial && !priv->ip6_mtu_initial) {
7421
			/* before touching any of the MTU paramters, record the
7417
			/* before touching any of the MTU paramters, record the
Lines 7434-7442 _commit_mtu (NMDevice *self, const NMIP4Config *config) Link Here
7434
				              ? "Are the MTU sizes of the slaves large enough?"
7430
				              ? "Are the MTU sizes of the slaves large enough?"
7435
				              : "Did you configure the MTU correctly?"));
7431
				              : "Did you configure the MTU correctly?"));
7436
			}
7432
			}
7437
			now_ms = nm_utils_get_monotonic_timestamp_ms ();
7433
			priv->carrier_wait_until_ms = nm_utils_get_monotonic_timestamp_ms () + CARRIER_WAIT_TIME_AFTER_MTU_MS;
7438
			priv->carrier_wait_until_ms = now_ms + CARRIER_WAIT_TIME_AFTER_MTU_MS;
7439
			priv->carrier_defer_until_ms = now_ms + CARRIER_DEFER_TIME_AFTER_MTU_MS;
7440
		}
7434
		}
7441
7435
7442
		if (ip6_mtu && ip6_mtu != _IP6_MTU_SYS ()) {
7436
		if (ip6_mtu && ip6_mtu != _IP6_MTU_SYS ()) {
Lines 7451-7459 _commit_mtu (NMDevice *self, const NMIP4Config *config) Link Here
7451
				           ? ": Is the underlying MTU value successfully set?"
7445
				           ? ": Is the underlying MTU value successfully set?"
7452
				           : "");
7446
				           : "");
7453
			}
7447
			}
7454
			now_ms = nm_utils_get_monotonic_timestamp_ms ();
7448
			priv->carrier_wait_until_ms = nm_utils_get_monotonic_timestamp_ms () + CARRIER_WAIT_TIME_AFTER_MTU_MS;
7455
			priv->carrier_wait_until_ms = now_ms + CARRIER_WAIT_TIME_AFTER_MTU_MS;
7456
			priv->carrier_defer_until_ms = now_ms + CARRIER_DEFER_TIME_AFTER_MTU_MS;
7457
		}
7449
		}
7458
	}
7450
	}
7459
#undef _IP6_MTU_SYS
7451
#undef _IP6_MTU_SYS
Lines 12581-12592 nm_device_cleanup (NMDevice *self, NMDeviceStateReason reason, CleanupType clean Link Here
12581
			_LOGT (LOGD_DEVICE, "mtu: reset device-mtu: %u, ipv6-mtu: %u, ifindex: %d",
12573
			_LOGT (LOGD_DEVICE, "mtu: reset device-mtu: %u, ipv6-mtu: %u, ifindex: %d",
12582
			       (guint) priv->mtu_initial, (guint) priv->ip6_mtu_initial, ifindex);
12574
			       (guint) priv->mtu_initial, (guint) priv->ip6_mtu_initial, ifindex);
12583
			if (priv->mtu_initial) {
12575
			if (priv->mtu_initial) {
12584
				gint64 now;
12585
12586
				nm_platform_link_set_mtu (nm_device_get_platform (self), ifindex, priv->mtu_initial);
12576
				nm_platform_link_set_mtu (nm_device_get_platform (self), ifindex, priv->mtu_initial);
12587
				now = nm_utils_get_monotonic_timestamp_ms ();
12577
				priv->carrier_wait_until_ms = nm_utils_get_monotonic_timestamp_ms () + CARRIER_WAIT_TIME_AFTER_MTU_MS;
12588
				priv->carrier_wait_until_ms = now + CARRIER_WAIT_TIME_AFTER_MTU_MS;
12589
				priv->carrier_defer_until_ms = now + CARRIER_DEFER_TIME_AFTER_MTU_MS;
12590
			}
12578
			}
12591
			if (priv->ip6_mtu_initial) {
12579
			if (priv->ip6_mtu_initial) {
12592
				char sbuf[64];
12580
				char sbuf[64];
12593
- 

Return to bug 620662