From 2366b6c3462f2bc690edc8aead057849eeac7791 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 25 Sep 2007 06:34:05 +0000 Subject: [PATCH] 2007-09-25 Dan Williams * src/NetworkManagerPolicy.c - (nm_policy_device_change_check): handle devices that have a deferred activation. These devices are not really active _yet_, but need to be treated as such here. Don't interrupt them automatically. * src/nm-device-interface.c - (impl_device_activate): handle devices that have a deferred activation like activating or active devices. When multiple active devices get committed, the device shouldn't be deactivated until the connection details are available to avoid DoS and such. Currently, any active, activating, or deferred activation device is deactivated here before starting the new activation request. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2873 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 16 +++++++++++++++ src/NetworkManagerPolicy.c | 42 +++++++++++++++++++++++++++----------- src/nm-device-interface.c | 11 ++++++++++ 3 files changed, 57 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 905054ee45..e9316e5b57 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2007-09-25 Dan Williams + + * src/NetworkManagerPolicy.c + - (nm_policy_device_change_check): handle devices that have a + deferred activation. These devices are not really active _yet_, + but need to be treated as such here. Don't interrupt them + automatically. + + * src/nm-device-interface.c + - (impl_device_activate): handle devices that have a deferred activation + like activating or active devices. When multiple active devices + get committed, the device shouldn't be deactivated until the + connection details are available to avoid DoS and such. Currently, + any active, activating, or deferred activation device is deactivated + here before starting the new activation request. + 2007-09-25 Dan Williams Properly re-query secrets from the settings daemon when stuff fails. diff --git a/src/NetworkManagerPolicy.c b/src/NetworkManagerPolicy.c index 36bfa16c51..7017ede232 100644 --- a/src/NetworkManagerPolicy.c +++ b/src/NetworkManagerPolicy.c @@ -214,17 +214,31 @@ nm_policy_device_change_check (gpointer user_data) } } break; + case NM_STATE_DISCONNECTED: + /* Check for devices that have deferred activation requests */ + for (iter = nm_manager_get_devices (policy->manager); iter; iter = iter->next) { + NMActRequest *req = nm_device_get_act_request (NM_DEVICE (iter->data)); + + if (req && nm_act_request_is_deferred (req)) { + old_dev = NM_DEVICE (iter->data); + break; + } + } + break; default: break; } if (old_dev) { guint32 caps = nm_device_get_capabilities (old_dev); + NMActRequest *req = nm_device_get_act_request (old_dev); - /* Don't interrupt a currently activating device. */ - if ( nm_device_is_activating (old_dev) - && !nm_device_can_interrupt_activation (old_dev)) { - nm_info ("Old device '%s' activating, won't change.", nm_device_get_iface (old_dev)); + /* Don't interrupt a currently activating device automatically. */ + if ( (nm_device_is_activating (old_dev) + && !nm_device_can_interrupt_activation (old_dev)) + || nm_act_request_is_deferred (req)) { + nm_info ("Old device '%s' activating, won't change.", + nm_device_get_iface (old_dev)); goto out; } @@ -294,17 +308,21 @@ nm_policy_device_change_check (gpointer user_data) NMConnection *old_connection = nm_act_request_get_connection (old_act_req); NMAccessPoint *old_ap = nm_device_802_11_wireless_get_activation_ap (NM_DEVICE_802_11_WIRELESS (old_dev)); int old_mode = nm_ap_get_mode (old_ap); - gboolean same_request = FALSE; + gboolean same_activating = FALSE; - /* Don't try to re-activate the same connection if it's not - * failed yet. + /* Don't interrupt activation of a wireless device by + * trying to auto-activate any connection on that device. */ - if ( (old_dev == new_dev) - && nm_device_is_activating (new_dev) - && (old_connection == connection)) - same_request = TRUE; + if (old_dev == new_dev) { + NMActRequest *req = nm_device_get_act_request (new_dev); - if (!same_request && !old_has_link && (old_mode != IW_MODE_ADHOC)) { + if (nm_device_is_activating (new_dev)) + same_activating = TRUE; + else if (req && nm_act_request_is_deferred (req)) + same_activating = TRUE; + } + + if (!same_activating && !old_has_link && (old_mode != IW_MODE_ADHOC)) { NMSettingConnection * new_sc = (NMSettingConnection *) nm_connection_get_setting (connection, NM_SETTING_CONNECTION); NMSettingConnection * old_sc = (NMSettingConnection *) nm_connection_get_setting (old_connection, NM_SETTING_CONNECTION); diff --git a/src/nm-device-interface.c b/src/nm-device-interface.c index cd2006e4a0..1d64247673 100644 --- a/src/nm-device-interface.c +++ b/src/nm-device-interface.c @@ -223,6 +223,17 @@ impl_device_activate (NMDeviceInterface *device, } } break; + case NM_STATE_DISCONNECTED: + /* Check for devices that have deferred activation requests */ + for (iter = nm_manager_get_devices (manager); iter; iter = iter->next) { + NMActRequest *req = nm_device_get_act_request (NM_DEVICE (iter->data)); + + if (req && nm_act_request_is_deferred (req)) { + old_dev = NM_DEVICE (iter->data); + break; + } + } + break; default: break; }