|
|
708502 |
From 116501dbccf7139f942c77e71c4afb5f6d1af6a8 Mon Sep 17 00:00:00 2001
|
|
|
708502 |
From: Thomas Haller <thaller@redhat.com>
|
|
|
708502 |
Date: Mon, 28 Apr 2014 11:18:05 +0200
|
|
|
708502 |
Subject: [PATCH 1/2] core: add parameter to ignore error in add/remove pending
|
|
|
708502 |
action
|
|
|
708502 |
|
|
|
708502 |
Add a parameter to nm_device_add_pending_action() to silently
|
|
|
708502 |
accept adding duplicate actions.
|
|
|
708502 |
|
|
|
708502 |
Same for nm_device_remove_pending_action(), to silently ignore
|
|
|
708502 |
removing non-pending actions.
|
|
|
708502 |
|
|
|
708502 |
Signed-off-by: Thomas Haller <thaller@redhat.com>
|
|
|
708502 |
(cherry picked from commit a16faa3985042dadb34600cb0df2eefc61360340)
|
|
|
708502 |
---
|
|
|
708502 |
src/devices/nm-device-olpc-mesh.c | 4 +-
|
|
|
708502 |
src/devices/nm-device-wifi.c | 8 ++--
|
|
|
708502 |
src/devices/nm-device.c | 89 ++++++++++++++++++++++++++-------------
|
|
|
708502 |
src/devices/nm-device.h | 4 +-
|
|
|
708502 |
src/nm-active-connection.c | 8 ++--
|
|
|
708502 |
src/nm-policy.c | 4 +-
|
|
|
708502 |
6 files changed, 74 insertions(+), 43 deletions(-)
|
|
|
708502 |
|
|
|
708502 |
diff --git a/src/devices/nm-device-olpc-mesh.c b/src/devices/nm-device-olpc-mesh.c
|
|
|
708502 |
index b85956e..52ba79a 100644
|
|
|
708502 |
--- a/src/devices/nm-device-olpc-mesh.c
|
|
|
708502 |
+++ b/src/devices/nm-device-olpc-mesh.c
|
|
|
708502 |
@@ -627,7 +627,7 @@ check_companion_cb (gpointer user_data)
|
|
|
708502 |
}
|
|
|
708502 |
|
|
|
708502 |
done:
|
|
|
708502 |
- nm_device_remove_pending_action (NM_DEVICE (self), "waiting for companion");
|
|
|
708502 |
+ nm_device_remove_pending_action (NM_DEVICE (self), "waiting for companion", TRUE);
|
|
|
708502 |
return FALSE;
|
|
|
708502 |
}
|
|
|
708502 |
|
|
|
708502 |
@@ -645,7 +645,7 @@ state_changed (NMDevice *device, NMDeviceState new_state,
|
|
|
708502 |
* transition to DISCONNECTED otherwise wait for our companion.
|
|
|
708502 |
*/
|
|
|
708502 |
g_idle_add (check_companion_cb, self);
|
|
|
708502 |
- nm_device_add_pending_action (device, "waiting for companion");
|
|
|
708502 |
+ nm_device_add_pending_action (device, "waiting for companion", TRUE);
|
|
|
708502 |
break;
|
|
|
708502 |
case NM_DEVICE_STATE_ACTIVATED:
|
|
|
708502 |
break;
|
|
|
708502 |
diff --git a/src/devices/nm-device-wifi.c b/src/devices/nm-device-wifi.c
|
|
|
708502 |
index d539877..4b231ca 100644
|
|
|
708502 |
--- a/src/devices/nm-device-wifi.c
|
|
|
708502 |
+++ b/src/devices/nm-device-wifi.c
|
|
|
708502 |
@@ -360,7 +360,7 @@ supplicant_interface_acquire (NMDeviceWifi *self)
|
|
|
708502 |
}
|
|
|
708502 |
|
|
|
708502 |
if (nm_supplicant_interface_get_state (priv->supplicant.iface) < NM_SUPPLICANT_INTERFACE_STATE_READY)
|
|
|
708502 |
- nm_device_add_pending_action (NM_DEVICE (self), "waiting for supplicant");
|
|
|
708502 |
+ nm_device_add_pending_action (NM_DEVICE (self), "waiting for supplicant", TRUE);
|
|
|
708502 |
|
|
|
708502 |
g_signal_connect (priv->supplicant.iface,
|
|
|
708502 |
NM_SUPPLICANT_INTERFACE_STATE,
|
|
|
708502 |
@@ -1722,7 +1722,7 @@ request_wireless_scan (gpointer user_data)
|
|
|
708502 |
/* success */
|
|
|
708502 |
backoff = TRUE;
|
|
|
708502 |
priv->requested_scan = TRUE;
|
|
|
708502 |
- nm_device_add_pending_action (NM_DEVICE (self), "scan");
|
|
|
708502 |
+ nm_device_add_pending_action (NM_DEVICE (self), "scan", TRUE);
|
|
|
708502 |
}
|
|
|
708502 |
|
|
|
708502 |
if (ssids) {
|
|
|
708502 |
@@ -1823,7 +1823,7 @@ supplicant_iface_scan_done_cb (NMSupplicantInterface *iface,
|
|
|
708502 |
|
|
|
708502 |
if (priv->requested_scan) {
|
|
|
708502 |
priv->requested_scan = FALSE;
|
|
|
708502 |
- nm_device_remove_pending_action (NM_DEVICE (self), "scan");
|
|
|
708502 |
+ nm_device_remove_pending_action (NM_DEVICE (self), "scan", TRUE);
|
|
|
708502 |
}
|
|
|
708502 |
}
|
|
|
708502 |
|
|
|
708502 |
@@ -2364,7 +2364,7 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface,
|
|
|
708502 |
request_wireless_scan (self);
|
|
|
708502 |
|
|
|
708502 |
if (old_state < NM_SUPPLICANT_INTERFACE_STATE_READY)
|
|
|
708502 |
- nm_device_remove_pending_action (device, "waiting for supplicant");
|
|
|
708502 |
+ nm_device_remove_pending_action (device, "waiting for supplicant", TRUE);
|
|
|
708502 |
break;
|
|
|
708502 |
case NM_SUPPLICANT_INTERFACE_STATE_COMPLETED:
|
|
|
708502 |
remove_supplicant_interface_error_handler (self);
|
|
|
708502 |
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
|
|
|
708502 |
index f16c4d4..b6e7ef2 100644
|
|
|
708502 |
--- a/src/devices/nm-device.c
|
|
|
708502 |
+++ b/src/devices/nm-device.c
|
|
|
708502 |
@@ -1123,7 +1123,7 @@ nm_device_set_carrier (NMDevice *device, gboolean carrier)
|
|
|
708502 |
if (priv->carrier_wait_id) {
|
|
|
708502 |
g_source_remove (priv->carrier_wait_id);
|
|
|
708502 |
priv->carrier_wait_id = 0;
|
|
|
708502 |
- nm_device_remove_pending_action (device, "carrier wait");
|
|
|
708502 |
+ nm_device_remove_pending_action (device, "carrier wait", TRUE);
|
|
|
708502 |
}
|
|
|
708502 |
} else if (state <= NM_DEVICE_STATE_DISCONNECTED) {
|
|
|
708502 |
nm_log_info (LOGD_DEVICE, "(%s): link disconnected", iface);
|
|
|
708502 |
@@ -5539,7 +5539,7 @@ carrier_wait_timeout (gpointer user_data)
|
|
|
708502 |
NMDevice *self = NM_DEVICE (user_data);
|
|
|
708502 |
|
|
|
708502 |
NM_DEVICE_GET_PRIVATE (self)->carrier_wait_id = 0;
|
|
|
708502 |
- nm_device_remove_pending_action (self, "carrier wait");
|
|
|
708502 |
+ nm_device_remove_pending_action (self, "carrier wait", TRUE);
|
|
|
708502 |
return G_SOURCE_REMOVE;
|
|
|
708502 |
}
|
|
|
708502 |
|
|
|
708502 |
@@ -5587,10 +5587,10 @@ nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
|
|
|
708502 |
if (device_has_capability (self, NM_DEVICE_CAP_CARRIER_DETECT)) {
|
|
|
708502 |
if (priv->carrier_wait_id) {
|
|
|
708502 |
g_source_remove (priv->carrier_wait_id);
|
|
|
708502 |
- nm_device_remove_pending_action (self, "carrier wait");
|
|
|
708502 |
+ nm_device_remove_pending_action (self, "carrier wait", TRUE);
|
|
|
708502 |
}
|
|
|
708502 |
priv->carrier_wait_id = g_timeout_add_seconds (5, carrier_wait_timeout, self);
|
|
|
708502 |
- nm_device_add_pending_action (self, "carrier wait");
|
|
|
708502 |
+ nm_device_add_pending_action (self, "carrier wait", TRUE);
|
|
|
708502 |
}
|
|
|
708502 |
|
|
|
708502 |
/* Can only get HW address of some devices when they are up */
|
|
|
708502 |
@@ -6852,7 +6852,7 @@ queued_set_state (gpointer user_data)
|
|
|
708502 |
nm_device_queued_state_clear (self);
|
|
|
708502 |
|
|
|
708502 |
nm_device_state_changed (self, new_state, new_reason);
|
|
|
708502 |
- nm_device_remove_pending_action (self, queued_state_to_string (new_state));
|
|
|
708502 |
+ nm_device_remove_pending_action (self, queued_state_to_string (new_state), TRUE);
|
|
|
708502 |
} else {
|
|
|
708502 |
g_warn_if_fail (priv->queued_state.state == NM_DEVICE_STATE_UNKNOWN);
|
|
|
708502 |
g_warn_if_fail (priv->queued_state.reason == NM_DEVICE_STATE_REASON_NONE);
|
|
|
708502 |
@@ -6876,7 +6876,7 @@ nm_device_queue_state (NMDevice *self,
|
|
|
708502 |
|
|
|
708502 |
/* Add pending action for the new state before clearing the queued states, so
|
|
|
708502 |
* that we don't accidently pop all pending states and reach 'startup complete' */
|
|
|
708502 |
- nm_device_add_pending_action (self, queued_state_to_string (state));
|
|
|
708502 |
+ nm_device_add_pending_action (self, queued_state_to_string (state), TRUE);
|
|
|
708502 |
|
|
|
708502 |
/* We should only ever have one delayed state transition at a time */
|
|
|
708502 |
if (priv->queued_state.id) {
|
|
|
708502 |
@@ -6917,7 +6917,7 @@ nm_device_queued_state_clear (NMDevice *self)
|
|
|
708502 |
nm_log_dbg (LOGD_DEVICE, "(%s): clearing queued state transition (id %d)",
|
|
|
708502 |
nm_device_get_iface (self), priv->queued_state.id);
|
|
|
708502 |
g_source_remove (priv->queued_state.id);
|
|
|
708502 |
- nm_device_remove_pending_action (self, queued_state_to_string (priv->queued_state.state));
|
|
|
708502 |
+ nm_device_remove_pending_action (self, queued_state_to_string (priv->queued_state.state), TRUE);
|
|
|
708502 |
}
|
|
|
708502 |
memset (&priv->queued_state, 0, sizeof (priv->queued_state));
|
|
|
708502 |
}
|
|
|
708502 |
@@ -7651,31 +7651,46 @@ nm_device_set_hw_addr (NMDevice *device, const guint8 *addr,
|
|
|
708502 |
* nm_device_add_pending_action():
|
|
|
708502 |
* @device: the #NMDevice to add the pending action to
|
|
|
708502 |
* @action: a static string that identifies the action
|
|
|
708502 |
+ * @assert_not_yet_pending: if %TRUE, assert that the @action is currently not yet pending.
|
|
|
708502 |
+ * Otherwise, ignore duplicate scheduling of the same action silently.
|
|
|
708502 |
*
|
|
|
708502 |
* Adds a pending action to the device.
|
|
|
708502 |
+ *
|
|
|
708502 |
+ * Returns: %TRUE if the action was added (and not already added before). %FALSE
|
|
|
708502 |
+ * if the same action is already scheduled. In the latter case, the action was not scheduled
|
|
|
708502 |
+ * a second time.
|
|
|
708502 |
*/
|
|
|
708502 |
-void
|
|
|
708502 |
-nm_device_add_pending_action (NMDevice *device, const char *action)
|
|
|
708502 |
+gboolean
|
|
|
708502 |
+nm_device_add_pending_action (NMDevice *device, const char *action, gboolean assert_not_yet_pending)
|
|
|
708502 |
{
|
|
|
708502 |
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
708502 |
GSList *iter;
|
|
|
708502 |
- guint count;
|
|
|
708502 |
+ guint count = 0;
|
|
|
708502 |
|
|
|
708502 |
- g_return_if_fail (action);
|
|
|
708502 |
+ g_return_val_if_fail (action, FALSE);
|
|
|
708502 |
|
|
|
708502 |
- /* Shouldn't ever add the same pending action twice */
|
|
|
708502 |
+ /* Check if the action is already pending. Cannot add duplicate actions */
|
|
|
708502 |
for (iter = priv->pending_actions; iter; iter = iter->next) {
|
|
|
708502 |
if (!strcmp (action, iter->data)) {
|
|
|
708502 |
- nm_log_warn (LOGD_DEVICE, "(%s): add_pending_action (%d): '%s' already added",
|
|
|
708502 |
- nm_device_get_iface (device),
|
|
|
708502 |
- g_slist_length (priv->pending_actions),
|
|
|
708502 |
- action);
|
|
|
708502 |
- g_return_if_reached ();
|
|
|
708502 |
+ if (assert_not_yet_pending) {
|
|
|
708502 |
+ nm_log_warn (LOGD_DEVICE, "(%s): add_pending_action (%d): '%s' already pending",
|
|
|
708502 |
+ nm_device_get_iface (device),
|
|
|
708502 |
+ count + g_slist_length (iter),
|
|
|
708502 |
+ action);
|
|
|
708502 |
+ g_return_val_if_reached (FALSE);
|
|
|
708502 |
+ } else {
|
|
|
708502 |
+ nm_log_dbg (LOGD_DEVICE, "(%s): add_pending_action (%d): '%s' already pending (expected)",
|
|
|
708502 |
+ nm_device_get_iface (device),
|
|
|
708502 |
+ count + g_slist_length (iter),
|
|
|
708502 |
+ action);
|
|
|
708502 |
+ }
|
|
|
708502 |
+ return FALSE;
|
|
|
708502 |
}
|
|
|
708502 |
+ count++;
|
|
|
708502 |
}
|
|
|
708502 |
|
|
|
708502 |
priv->pending_actions = g_slist_append (priv->pending_actions, g_strdup (action));
|
|
|
708502 |
- count = g_slist_length (priv->pending_actions);
|
|
|
708502 |
+ count++;
|
|
|
708502 |
|
|
|
708502 |
nm_log_dbg (LOGD_DEVICE, "(%s): add_pending_action (%d): '%s'",
|
|
|
708502 |
nm_device_get_iface (device),
|
|
|
708502 |
@@ -7684,44 +7699,60 @@ nm_device_add_pending_action (NMDevice *device, const char *action)
|
|
|
708502 |
|
|
|
708502 |
if (count == 1)
|
|
|
708502 |
g_object_notify (G_OBJECT (device), NM_DEVICE_HAS_PENDING_ACTION);
|
|
|
708502 |
+
|
|
|
708502 |
+ return TRUE;
|
|
|
708502 |
}
|
|
|
708502 |
|
|
|
708502 |
/**
|
|
|
708502 |
* nm_device_remove_pending_action():
|
|
|
708502 |
* @device: the #NMDevice to remove the pending action from
|
|
|
708502 |
* @action: a static string that identifies the action
|
|
|
708502 |
+ * @assert_is_pending: if %TRUE, assert that the @action is pending.
|
|
|
708502 |
+ * If %FALSE, don't do anything if the current action is not pending and
|
|
|
708502 |
+ * return %FALSE.
|
|
|
708502 |
*
|
|
|
708502 |
* Removes a pending action previously added by nm_device_add_pending_action().
|
|
|
708502 |
+ *
|
|
|
708502 |
+ * Returns: whether the @action was pending and is now removed.
|
|
|
708502 |
*/
|
|
|
708502 |
-void
|
|
|
708502 |
-nm_device_remove_pending_action (NMDevice *device, const char *action)
|
|
|
708502 |
+gboolean
|
|
|
708502 |
+nm_device_remove_pending_action (NMDevice *device, const char *action, gboolean assert_is_pending)
|
|
|
708502 |
{
|
|
|
708502 |
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
|
|
|
708502 |
GSList *iter;
|
|
|
708502 |
+ guint count = 0;
|
|
|
708502 |
|
|
|
708502 |
- g_return_if_fail (action);
|
|
|
708502 |
+ g_return_val_if_fail (action, FALSE);
|
|
|
708502 |
|
|
|
708502 |
- /* Shouldn't ever add the same pending action twice */
|
|
|
708502 |
for (iter = priv->pending_actions; iter; iter = iter->next) {
|
|
|
708502 |
if (!strcmp (action, iter->data)) {
|
|
|
708502 |
g_free (iter->data);
|
|
|
708502 |
priv->pending_actions = g_slist_delete_link (priv->pending_actions, iter);
|
|
|
708502 |
nm_log_dbg (LOGD_DEVICE, "(%s): remove_pending_action (%d): '%s'",
|
|
|
708502 |
nm_device_get_iface (device),
|
|
|
708502 |
- g_slist_length (priv->pending_actions),
|
|
|
708502 |
+ count + g_slist_length (iter),
|
|
|
708502 |
action);
|
|
|
708502 |
|
|
|
708502 |
if (priv->pending_actions == NULL)
|
|
|
708502 |
g_object_notify (G_OBJECT (device), NM_DEVICE_HAS_PENDING_ACTION);
|
|
|
708502 |
- return;
|
|
|
708502 |
+ return TRUE;
|
|
|
708502 |
}
|
|
|
708502 |
+ count++;
|
|
|
708502 |
}
|
|
|
708502 |
|
|
|
708502 |
- nm_log_warn (LOGD_DEVICE, "(%s): remove_pending_action (%d): '%s' never added",
|
|
|
708502 |
- nm_device_get_iface (device),
|
|
|
708502 |
- g_slist_length (priv->pending_actions),
|
|
|
708502 |
- action);
|
|
|
708502 |
- g_return_if_reached ();
|
|
|
708502 |
+ if (assert_is_pending) {
|
|
|
708502 |
+ nm_log_warn (LOGD_DEVICE, "(%s): remove_pending_action (%d): '%s' not pending",
|
|
|
708502 |
+ nm_device_get_iface (device),
|
|
|
708502 |
+ count,
|
|
|
708502 |
+ action);
|
|
|
708502 |
+ g_return_val_if_reached (FALSE);
|
|
|
708502 |
+ } else {
|
|
|
708502 |
+ nm_log_dbg (LOGD_DEVICE, "(%s): remove_pending_action (%d): '%s' not pending (expected)",
|
|
|
708502 |
+ nm_device_get_iface (device),
|
|
|
708502 |
+ count,
|
|
|
708502 |
+ action);
|
|
|
708502 |
+ }
|
|
|
708502 |
+ return FALSE;
|
|
|
708502 |
}
|
|
|
708502 |
|
|
|
708502 |
gboolean
|
|
|
708502 |
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
|
|
|
708502 |
index 47d7856..935a448 100644
|
|
|
708502 |
--- a/src/devices/nm-device.h
|
|
|
708502 |
+++ b/src/devices/nm-device.h
|
|
|
708502 |
@@ -328,8 +328,8 @@ void nm_device_queue_activation (NMDevice *device, NMActRequest *req);
|
|
|
708502 |
|
|
|
708502 |
gboolean nm_device_supports_vlans (NMDevice *device);
|
|
|
708502 |
|
|
|
708502 |
-void nm_device_add_pending_action (NMDevice *device, const char *action);
|
|
|
708502 |
-void nm_device_remove_pending_action (NMDevice *device, const char *action);
|
|
|
708502 |
+gboolean nm_device_add_pending_action (NMDevice *device, const char *action, gboolean assert_not_yet_pending);
|
|
|
708502 |
+gboolean nm_device_remove_pending_action (NMDevice *device, const char *action, gboolean assert_is_pending);
|
|
|
708502 |
gboolean nm_device_has_pending_action (NMDevice *device);
|
|
|
708502 |
|
|
|
708502 |
GPtrArray *nm_device_get_available_connections (NMDevice *device,
|
|
|
708502 |
diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c
|
|
|
708502 |
index 43f8189..172aa61 100644
|
|
|
708502 |
--- a/src/nm-active-connection.c
|
|
|
708502 |
+++ b/src/nm-active-connection.c
|
|
|
708502 |
@@ -152,7 +152,7 @@ nm_active_connection_set_state (NMActiveConnection *self,
|
|
|
708502 |
&& new_state >= NM_ACTIVE_CONNECTION_STATE_ACTIVATED &&
|
|
|
708502 |
priv->pending_activation_id)
|
|
|
708502 |
{
|
|
|
708502 |
- nm_device_remove_pending_action (priv->device, priv->pending_activation_id);
|
|
|
708502 |
+ nm_device_remove_pending_action (priv->device, priv->pending_activation_id, TRUE);
|
|
|
708502 |
g_clear_pointer (&priv->pending_activation_id, g_free);
|
|
|
708502 |
}
|
|
|
708502 |
}
|
|
|
708502 |
@@ -399,7 +399,7 @@ nm_active_connection_set_device (NMActiveConnection *self, NMDevice *device)
|
|
|
708502 |
|
|
|
708502 |
if (!priv->assumed) {
|
|
|
708502 |
priv->pending_activation_id = g_strdup_printf ("activation::%p", (void *)self);
|
|
|
708502 |
- nm_device_add_pending_action (device, priv->pending_activation_id);
|
|
|
708502 |
+ nm_device_add_pending_action (device, priv->pending_activation_id, TRUE);
|
|
|
708502 |
}
|
|
|
708502 |
}
|
|
|
708502 |
return TRUE;
|
|
|
708502 |
@@ -540,7 +540,7 @@ nm_active_connection_set_assumed (NMActiveConnection *self, gboolean assumed)
|
|
|
708502 |
priv->assumed = assumed;
|
|
|
708502 |
|
|
|
708502 |
if (priv->pending_activation_id) {
|
|
|
708502 |
- nm_device_remove_pending_action (priv->device, priv->pending_activation_id);
|
|
|
708502 |
+ nm_device_remove_pending_action (priv->device, priv->pending_activation_id, TRUE);
|
|
|
708502 |
g_clear_pointer (&priv->pending_activation_id, g_free);
|
|
|
708502 |
}
|
|
|
708502 |
}
|
|
|
708502 |
@@ -795,7 +795,7 @@ _device_cleanup (NMActiveConnection *self)
|
|
|
708502 |
}
|
|
|
708502 |
|
|
|
708502 |
if (priv->pending_activation_id) {
|
|
|
708502 |
- nm_device_remove_pending_action (priv->device, priv->pending_activation_id);
|
|
|
708502 |
+ nm_device_remove_pending_action (priv->device, priv->pending_activation_id, TRUE);
|
|
|
708502 |
g_clear_pointer (&priv->pending_activation_id, g_free);
|
|
|
708502 |
}
|
|
|
708502 |
|
|
|
708502 |
diff --git a/src/nm-policy.c b/src/nm-policy.c
|
|
|
708502 |
index f569b75..b412427 100644
|
|
|
708502 |
--- a/src/nm-policy.c
|
|
|
708502 |
+++ b/src/nm-policy.c
|
|
|
708502 |
@@ -941,7 +941,7 @@ activate_data_free (ActivateData *data)
|
|
|
708502 |
{
|
|
|
708502 |
NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (data->policy);
|
|
|
708502 |
|
|
|
708502 |
- nm_device_remove_pending_action (data->device, "autoactivate");
|
|
|
708502 |
+ nm_device_remove_pending_action (data->device, "autoactivate", TRUE);
|
|
|
708502 |
priv->pending_activation_checks = g_slist_remove (priv->pending_activation_checks, data);
|
|
|
708502 |
|
|
|
708502 |
if (data->autoactivate_id)
|
|
|
708502 |
@@ -1223,7 +1223,7 @@ schedule_activate_check (NMPolicy *policy, NMDevice *device)
|
|
|
708502 |
return;
|
|
|
708502 |
}
|
|
|
708502 |
|
|
|
708502 |
- nm_device_add_pending_action (device, "autoactivate");
|
|
|
708502 |
+ nm_device_add_pending_action (device, "autoactivate", TRUE);
|
|
|
708502 |
|
|
|
708502 |
data = g_malloc0 (sizeof (ActivateData));
|
|
|
708502 |
data->policy = policy;
|
|
|
708502 |
--
|
|
|
708502 |
1.9.0
|
|
|
708502 |
|
|
|
708502 |
|
|
|
708502 |
From e20f6c63b0a5f0dfb2851d6f5a098f8bb1f5a1be Mon Sep 17 00:00:00 2001
|
|
|
708502 |
From: Thomas Haller <thaller@redhat.com>
|
|
|
708502 |
Date: Mon, 14 Apr 2014 17:57:56 +0200
|
|
|
708502 |
Subject: [PATCH 2/2] core: wait with "startup complete" for both IPv4 and IPv6
|
|
|
708502 |
dynamic configuration
|
|
|
708502 |
|
|
|
708502 |
In case of DHCP4, DHCP6 and/or SLAAC, delay "startup complete" until
|
|
|
708502 |
both IPv4 and IPv6 are ready. This especially has an effect on
|
|
|
708502 |
nm-online/NetworkManager-wait-online.service, which blocks until
|
|
|
708502 |
configuration of both IPv4 and IPv6 is ready.
|
|
|
708502 |
|
|
|
708502 |
We queue a pending_action when automatic configuration starts and
|
|
|
708502 |
remove it again, when we receive an address. Before, "startup complete"
|
|
|
708502 |
was reached when either one of the two IP protocols was configured.
|
|
|
708502 |
|
|
|
708502 |
https://bugzilla.redhat.com/show_bug.cgi?id=1086906
|
|
|
708502 |
|
|
|
708502 |
Signed-off-by: Thomas Haller <thaller@redhat.com>
|
|
|
708502 |
(cherry picked from commit 516d66210fbcc9897f60dc9145a477e91ff8bad5)
|
|
|
708502 |
---
|
|
|
708502 |
man/nm-online.1.in | 7 ++++++-
|
|
|
708502 |
src/devices/nm-device.c | 28 ++++++++++++++++++++++++++++
|
|
|
708502 |
2 files changed, 34 insertions(+), 1 deletion(-)
|
|
|
708502 |
|
|
|
708502 |
diff --git a/man/nm-online.1.in b/man/nm-online.1.in
|
|
|
708502 |
index 941f006..86ed974 100644
|
|
|
708502 |
--- a/man/nm-online.1.in
|
|
|
708502 |
+++ b/man/nm-online.1.in
|
|
|
708502 |
@@ -35,7 +35,12 @@ is a utility to find out whether we are online. It is done by asking
|
|
|
708502 |
NetworkManager about its status. When run, \fInm\-online\fP waits until
|
|
|
708502 |
NetworkManager reports an active connection, or specified timeout expires. On
|
|
|
708502 |
exit, the returned status code should be checked (see the return codes bellow).
|
|
|
708502 |
-
|
|
|
708502 |
+.P
|
|
|
708502 |
+By default NetworkManager waits for IPv4 dynamic addressing to complete but does
|
|
|
708502 |
+not wait for the "auto" IPv6 dynamic addressing. To wait for IPv6 addressing to
|
|
|
708502 |
+complete, either (1) change the network connection's IPv6 "may-fail" setting to "no",
|
|
|
708502 |
+and/or (2) change the IPv6 addressing method to "manual" or "dhcp", to indicate that
|
|
|
708502 |
+IPv6 connectivity is expected.
|
|
|
708502 |
.SH OPTIONS
|
|
|
708502 |
.TP
|
|
|
708502 |
.B \-t, \-\-timeout <timeout_value>
|
|
|
708502 |
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
|
|
|
708502 |
index b6e7ef2..8399cf6 100644
|
|
|
708502 |
--- a/src/devices/nm-device.c
|
|
|
708502 |
+++ b/src/devices/nm-device.c
|
|
|
708502 |
@@ -156,6 +156,10 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (NMDevice, nm_device, G_TYPE_OBJECT,
|
|
|
708502 |
|
|
|
708502 |
#define NM_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE, NMDevicePrivate))
|
|
|
708502 |
|
|
|
708502 |
+#define PENDING_ACTION_DHCP4 "dhcp4"
|
|
|
708502 |
+#define PENDING_ACTION_DHCP6 "dhcp6"
|
|
|
708502 |
+#define PENDING_ACTION_AUTOCONF6 "autoconf6"
|
|
|
708502 |
+
|
|
|
708502 |
typedef enum {
|
|
|
708502 |
IP_NONE = 0,
|
|
|
708502 |
IP_WAIT,
|
|
|
708502 |
@@ -2820,6 +2824,8 @@ dhcp4_start (NMDevice *self,
|
|
|
708502 |
G_CALLBACK (dhcp4_timeout),
|
|
|
708502 |
self);
|
|
|
708502 |
|
|
|
708502 |
+ nm_device_add_pending_action (self, PENDING_ACTION_DHCP4, TRUE);
|
|
|
708502 |
+
|
|
|
708502 |
/* DHCP devices will be notified by the DHCP manager when stuff happens */
|
|
|
708502 |
return NM_ACT_STAGE_RETURN_POSTPONE;
|
|
|
708502 |
}
|
|
|
708502 |
@@ -3202,6 +3208,7 @@ dhcp6_start (NMDevice *self,
|
|
|
708502 |
guint32 dhcp_opt,
|
|
|
708502 |
NMDeviceStateReason *reason)
|
|
|
708502 |
{
|
|
|
708502 |
+ NMSettingIP6Config *s_ip6;
|
|
|
708502 |
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
708502 |
NMActStageReturn ret = NM_ACT_STAGE_RETURN_FAILURE;
|
|
|
708502 |
guint8 *anycast = NULL;
|
|
|
708502 |
@@ -3254,6 +3261,11 @@ dhcp6_start (NMDevice *self,
|
|
|
708502 |
G_CALLBACK (dhcp6_timeout),
|
|
|
708502 |
self);
|
|
|
708502 |
|
|
|
708502 |
+ s_ip6 = nm_connection_get_setting_ip6_config (connection);
|
|
|
708502 |
+ if (!nm_setting_ip6_config_get_may_fail (s_ip6) ||
|
|
|
708502 |
+ !strcmp (nm_setting_ip6_config_get_method (s_ip6), NM_SETTING_IP6_CONFIG_METHOD_DHCP))
|
|
|
708502 |
+ nm_device_add_pending_action (self, PENDING_ACTION_DHCP6, TRUE);
|
|
|
708502 |
+
|
|
|
708502 |
/* DHCP devices will be notified by the DHCP manager when stuff happens */
|
|
|
708502 |
ret = NM_ACT_STAGE_RETURN_POSTPONE;
|
|
|
708502 |
} else {
|
|
|
708502 |
@@ -3620,6 +3632,9 @@ addrconf6_start (NMDevice *self, NMSettingIP6ConfigPrivacy use_tempaddr)
|
|
|
708502 |
priv->rdisc_use_tempaddr = use_tempaddr;
|
|
|
708502 |
print_support_extended_ifa_flags (use_tempaddr);
|
|
|
708502 |
|
|
|
708502 |
+ if (!nm_setting_ip6_config_get_may_fail (nm_connection_get_setting_ip6_config (connection)))
|
|
|
708502 |
+ nm_device_add_pending_action (self, PENDING_ACTION_AUTOCONF6, TRUE);
|
|
|
708502 |
+
|
|
|
708502 |
/* ensure link local is ready... */
|
|
|
708502 |
ret = linklocal6_start (self);
|
|
|
708502 |
if (ret == NM_ACT_STAGE_RETURN_SUCCESS)
|
|
|
708502 |
@@ -3663,6 +3678,8 @@ addrconf6_cleanup (NMDevice *self)
|
|
|
708502 |
priv->rdisc_config_changed_sigid = 0;
|
|
|
708502 |
}
|
|
|
708502 |
|
|
|
708502 |
+ nm_device_remove_pending_action (self, PENDING_ACTION_AUTOCONF6, FALSE);
|
|
|
708502 |
+
|
|
|
708502 |
g_clear_object (&priv->ac_ip6_config);
|
|
|
708502 |
g_clear_object (&priv->rdisc);
|
|
|
708502 |
}
|
|
|
708502 |
@@ -4509,6 +4526,9 @@ nm_device_activate_ip4_config_commit (gpointer user_data)
|
|
|
708502 |
|
|
|
708502 |
/* Enter the IP_CHECK state if this is the first method to complete */
|
|
|
708502 |
priv->ip4_state = IP_DONE;
|
|
|
708502 |
+
|
|
|
708502 |
+ nm_device_remove_pending_action (self, PENDING_ACTION_DHCP4, FALSE);
|
|
|
708502 |
+
|
|
|
708502 |
if (nm_device_get_state (self) == NM_DEVICE_STATE_IP_CONFIG)
|
|
|
708502 |
nm_device_state_changed (self, NM_DEVICE_STATE_IP_CHECK, NM_DEVICE_STATE_REASON_NONE);
|
|
|
708502 |
|
|
|
708502 |
@@ -4598,6 +4618,10 @@ nm_device_activate_ip6_config_commit (gpointer user_data)
|
|
|
708502 |
|
|
|
708502 |
/* Enter the IP_CHECK state if this is the first method to complete */
|
|
|
708502 |
priv->ip6_state = IP_DONE;
|
|
|
708502 |
+
|
|
|
708502 |
+ nm_device_remove_pending_action (self, PENDING_ACTION_DHCP6, FALSE);
|
|
|
708502 |
+ nm_device_remove_pending_action (self, PENDING_ACTION_AUTOCONF6, FALSE);
|
|
|
708502 |
+
|
|
|
708502 |
if (nm_device_get_state (self) == NM_DEVICE_STATE_IP_CONFIG)
|
|
|
708502 |
nm_device_state_changed (self, NM_DEVICE_STATE_IP_CHECK, NM_DEVICE_STATE_REASON_NONE);
|
|
|
708502 |
} else {
|
|
|
708502 |
@@ -4683,6 +4707,8 @@ dhcp4_cleanup (NMDevice *self, gboolean stop, gboolean release)
|
|
|
708502 |
priv->dhcp4_timeout_sigid = 0;
|
|
|
708502 |
}
|
|
|
708502 |
|
|
|
708502 |
+ nm_device_remove_pending_action (self, PENDING_ACTION_DHCP4, FALSE);
|
|
|
708502 |
+
|
|
|
708502 |
if (stop)
|
|
|
708502 |
nm_dhcp_client_stop (priv->dhcp4_client, release);
|
|
|
708502 |
|
|
|
708502 |
@@ -4720,6 +4746,8 @@ dhcp6_cleanup (NMDevice *self, gboolean stop, gboolean release)
|
|
|
708502 |
priv->dhcp6_timeout_sigid = 0;
|
|
|
708502 |
}
|
|
|
708502 |
|
|
|
708502 |
+ nm_device_remove_pending_action (self, PENDING_ACTION_DHCP6, FALSE);
|
|
|
708502 |
+
|
|
|
708502 |
if (stop)
|
|
|
708502 |
nm_dhcp_client_stop (priv->dhcp6_client, release);
|
|
|
708502 |
|
|
|
708502 |
--
|
|
|
708502 |
1.9.0
|
|
|
708502 |
|