On Saturday 09 of April 2011 02:01:09 Mikhail Efremov wrote: > On Wed, 06 Apr 2011 17:24:44 -0500 Dan Williams wrote: > > On Tue, 2011-04-05 at 11:37 -0400, Derek Atkins wrote: > > > Hey all, > > > > > > I have a strange issue. I lost power last night and one of my > > > systems came up before my DHCP server did (which is surprising, > > > because my DHCP server usually comes up pretty quick!) This > > > "client" system was supposed to get itself on the network (it has > > > an auto-logon system). However, NM didn't succeed because my DHCP > > > server wasn't responding, yet. > > > > > > This is a hard-wired system (not wireless). Is there any way to > > > get NM to periodically retry DHCP if at first it does not succeed? > > > > > > I realize that DHCP has its own retry mechanism, but if the whole > > > process times out, can I set NM to retry every, say, 5 minutes? > > > > We'd need some code changes in NM; basically for wired connections if > > the activation attempt fails a certain number of times (currently 3) > > then the connection is marked "invalid". What probably should happen > > is that internally, in nm-policy.c, a timeout handler should be > > scheduled for the connection (using g_timeout_add_seconds()) that > > triggers after 5 minutes or so and if the connection isn't currently > > active (ie check the NMManager's active connection list) then the > > invalid flag is cleared from the connection, which will let it be > > automatically retried. > > Not on this issue exactly, but this is reminded me about my old patch > which was written long time ago (it was just forgotten to submit, sorry). > If cable was unplugged, then when it is replugged this may be another > network, so NM should try to reconnect even if the connection was > early marked as "invalid". > This patch for the NM_0_8 branch, for master it should be remaked, but > I have no time to do this right now, sorry. And there may be no > necessary for a separate function to clear the tag.
Looks good. However, we may want to remove the 'invalid' flag for all connections compatible with the device. Patches both for NM_0_8 and master attached. Jirka
From fd1fcb95bcd2edc565ff75d21ca7f36f6139018b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= <jkli...@redhat.com> Date: Mon, 23 May 2011 12:23:28 +0200 Subject: [PATCH] core: clear 'invalid' tag when cable is replugged MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When re-plugging we may be in a different network. So remove invalid tag from compatible connection so that they can be tried again. Based on a patch from Mikhail Efremov. Signed-off-by: Jiří Klimeš <jkli...@redhat.com> --- src/nm-policy.c | 33 ++++++++++++++++++++++++++++++++- 1 files changed, 32 insertions(+), 1 deletions(-) diff --git a/src/nm-policy.c b/src/nm-policy.c index da6ce94..78efef0 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -848,6 +848,32 @@ get_device_connection (NMDevice *device) } static void +clear_invalid_tag (NMManager *manager, NMDevice *device) +{ + GSList *connections, *iter; + NMDeviceInterface *dev_iface; + GError *error = NULL; + + g_return_if_fail (NM_IS_MANAGER (manager)); + g_return_if_fail (NM_IS_DEVICE (device)); + + dev_iface = NM_DEVICE_INTERFACE (device); + + /* System connections first, then user connections */ + connections = nm_manager_get_connections (manager, NM_CONNECTION_SCOPE_SYSTEM); + connections = g_slist_concat (connections, nm_manager_get_connections (manager, NM_CONNECTION_SCOPE_USER)); + + /* Clear INVALID_TAG for all connections compatible with the device */ + for (iter = connections; iter; iter = g_slist_next (iter)) { + if (nm_device_interface_check_connection_compatible (dev_iface, iter->data, &error)) + g_object_set_data (G_OBJECT (iter->data), INVALID_TAG, NULL); + g_object_unref (G_OBJECT (iter->data)); + g_clear_error (&error); + } + g_slist_free (connections); +} + +static void device_state_changed (NMDevice *device, NMDeviceState new_state, NMDeviceState old_state, @@ -882,9 +908,14 @@ device_state_changed (NMDevice *device, update_routing_and_dns (policy, FALSE); break; + case NM_DEVICE_STATE_DISCONNECTED: + /* Clear INVALID_TAG when carrier on. If cable was unplugged + * and plugged again, we should try to reconnect */ + if (reason == NM_DEVICE_STATE_REASON_CARRIER && old_state == NM_DEVICE_STATE_UNAVAILABLE) + clear_invalid_tag (policy->manager, device); + /* fall through */ case NM_DEVICE_STATE_UNMANAGED: case NM_DEVICE_STATE_UNAVAILABLE: - case NM_DEVICE_STATE_DISCONNECTED: update_routing_and_dns (policy, FALSE); schedule_activate_check (policy, device, 0); break; -- 1.7.4.4
From 15825c119e33b15f5782b6c47c6fff452db9d5a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= <jkli...@redhat.com> Date: Mon, 23 May 2011 12:50:25 +0200 Subject: [PATCH] core: reset auto retries counter when cable is replugged MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When re-plugging we may be in a different network. So we should try the compatible connections again. Based on a patch from Mikhail Efremov. Signed-off-by: Jiří Klimeš <jkli...@redhat.com> --- src/nm-policy.c | 21 +++++++++++++++------ 1 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/nm-policy.c b/src/nm-policy.c index 194d111..b98fe32 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -817,13 +817,17 @@ hostname_changed (NMManager *manager, GParamSpec *pspec, gpointer user_data) } static void -reset_retries_all (NMSettings *settings) +reset_retries_all (NMSettings *settings, NMDevice *device) { GSList *connections, *iter; + GError *error = NULL; connections = nm_settings_get_connections (settings); - for (iter = connections; iter; iter = g_slist_next (iter)) - set_connection_auto_retries (NM_CONNECTION (iter->data), RETRIES_DEFAULT); + for (iter = connections; iter; iter = g_slist_next (iter)) { + if (!device || nm_device_interface_check_connection_compatible (NM_DEVICE_INTERFACE (device), iter->data, &error)) + set_connection_auto_retries (NM_CONNECTION (iter->data), RETRIES_DEFAULT); + g_clear_error (&error); + } g_slist_free (connections); } @@ -838,7 +842,7 @@ sleeping_changed (NMManager *manager, GParamSpec *pspec, gpointer user_data) /* Reset retries on all connections so they'll checked on wakeup */ if (sleeping || !enabled) - reset_retries_all (policy->settings); + reset_retries_all (policy->settings, NULL); } static void @@ -932,6 +936,11 @@ device_state_changed (NMDevice *device, update_routing_and_dns (policy, FALSE); break; case NM_DEVICE_STATE_DISCONNECTED: + /* Clear INVALID_TAG when carrier on. If cable was unplugged + * and plugged again, we should try to reconnect */ + if (reason == NM_DEVICE_STATE_REASON_CARRIER && old_state == NM_DEVICE_STATE_UNAVAILABLE) + reset_retries_all (policy->settings, device); + /* Device is now available for auto-activation */ update_routing_and_dns (policy, FALSE); schedule_activate_check (policy, device, 0); @@ -1058,7 +1067,7 @@ connections_loaded (NMSettings *settings, gpointer user_data) // that by calling reset_retries_all() in nm_policy_new() /* Initialize connections' auto-retries */ - reset_retries_all (settings); + reset_retries_all (settings, NULL); schedule_activate_all ((NMPolicy *) user_data); } @@ -1188,7 +1197,7 @@ nm_policy_new (NMManager *manager, connection_visibility_changed); /* Initialize connections' auto-retries */ - reset_retries_all (policy->settings); + reset_retries_all (policy->settings, NULL); initialized = TRUE; return policy; -- 1.7.4.4
_______________________________________________ networkmanager-list mailing list networkmanager-list@gnome.org http://mail.gnome.org/mailman/listinfo/networkmanager-list