From c804909f8328591cc5239b81edc97fa18f15252d Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 18 Jan 2011 18:35:35 -0600 Subject: [PATCH] wired: clear wired secrets tries counter when appropriate If NM asks for secrets, and then a client calls ActivateDevice on that same connection, the secrets tries counter doesn't get reset and NM then thinks we need completely new secrets when we really don't since the old secrets request isn't valid anymore. Also ensure the secrets tries gets reset on success and failure to match behavior of wifi. --- src/nm-device-ethernet.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/nm-device-ethernet.c b/src/nm-device-ethernet.c index 00e8a2167..0613c9edf 100644 --- a/src/nm-device-ethernet.c +++ b/src/nm-device-ethernet.c @@ -473,9 +473,43 @@ constructor (GType type, return object; } +static void +clear_secrets_tries (NMDevice *device) +{ + NMActRequest *req; + NMConnection *connection; + + req = nm_device_get_act_request (device); + if (req) { + connection = nm_act_request_get_connection (req); + /* Clear wired secrets tries on success, failure, or when deactivating */ + g_object_set_data (G_OBJECT (connection), WIRED_SECRETS_TRIES, NULL); + } +} + +static void +device_state_changed (NMDevice *device, + NMDeviceState new_state, + NMDeviceState old_state, + NMDeviceStateReason reason, + gpointer user_data) +{ + + switch (new_state) { + case NM_DEVICE_STATE_ACTIVATED: + case NM_DEVICE_STATE_FAILED: + case NM_DEVICE_STATE_DISCONNECTED: + clear_secrets_tries (device); + break; + default: + break; + } +} + static void nm_device_ethernet_init (NMDeviceEthernet * self) { + g_signal_connect (self, "state-changed", G_CALLBACK (device_state_changed), NULL); } static gboolean @@ -1585,6 +1619,9 @@ real_deactivate_quickly (NMDevice *device) NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); + /* Clear wired secrets tries when deactivating */ + clear_secrets_tries (device); + if (priv->pending_ip4_config) { g_object_unref (priv->pending_ip4_config); priv->pending_ip4_config = NULL;