core: preserve reason on device deactivation while pre-down (fix tearing down slave when deactivating master)

When delaying the deactivation of a device during dispatcher-pre-down,
we must preseve the reason to pass it on.

This is especially important, because nm_device_slave_notify_release()
checks for the reason, and does not deactivate the slave if no reason is
given. This error caused slaves the be left up when deactivating the master.

Also update the call to nm_device_slave_notify_release() to ensure we
have a valid state reason when configuring the slave. This would have
pointed out the issue and would even work around it.

Regression introduced by commit d00e2147de.

Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
Thomas Haller 2014-06-12 13:46:25 +02:00
parent 332420ffec
commit 524fc6d454

View file

@ -217,6 +217,7 @@ typedef struct {
gpointer act_source6_func;
guint recheck_assume_id;
guint dispatcher_id;
NMDeviceStateReason dispatcher_pre_down_reason;
/* Link stuff */
guint link_connected_id;
@ -831,8 +832,12 @@ nm_device_release_one_slave (NMDevice *dev, NMDevice *slave, gboolean configure)
reason = NM_DEVICE_STATE_REASON_NONE;
else if (priv->state == NM_DEVICE_STATE_FAILED)
reason = NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED;
else
else if (priv->state_reason != NM_DEVICE_STATE_REASON_NONE)
reason = priv->state_reason;
else {
g_warn_if_reached ();
reason = NM_DEVICE_STATE_REASON_UNKNOWN;
}
nm_device_slave_notify_release (info->slave, reason);
free_slave_info (info);
@ -6530,7 +6535,7 @@ dispatcher_pre_down_done (guint call_id, gpointer user_data)
g_return_if_fail (call_id == priv->dispatcher_id);
priv->dispatcher_id = 0;
nm_device_queue_state (self, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_NONE);
nm_device_queue_state (self, NM_DEVICE_STATE_DISCONNECTED, priv->dispatcher_pre_down_reason);
}
static void
@ -6709,6 +6714,7 @@ _set_state_full (NMDevice *device,
nm_act_request_get_connection (req),
device);
} else {
priv->dispatcher_pre_down_reason = reason;
if (!nm_dispatcher_call (DISPATCHER_ACTION_PRE_DOWN,
nm_act_request_get_connection (req),
device,