On Thursday 07 of April 2011 00:24:44 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. > > It's pretty simple from a code perspective, just hasn't been done yet in > the run-up to 0.9 and 0.8.4. Any takers? > > Dan
A patch doing that is in the attachment. Jirka
From d3e1968ff94e735a0761036cb795cbee4c06937e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= <[email protected]> Date: Fri, 20 May 2011 13:45:12 +0200 Subject: [PATCH] policy: remove connection "invalid mark" after 5 mins to auto-activate again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When there is a temporary connection failure (e.g. due to unavailable DHCP), auto-activated connection is marked as invalid after several retries. Reset the flag after 5 mins to allow next auto-reconnection. Signed-off-by: Jiří Klimeš <[email protected]> --- src/nm-policy.c | 56 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 45 insertions(+), 11 deletions(-) diff --git a/src/nm-policy.c b/src/nm-policy.c index 194d111..5b13fff 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -72,6 +72,7 @@ struct NMPolicy { #define RETRIES_TAG "autoconnect-retries" #define RETRIES_DEFAULT 4 +#define RESET_RETRIES_TIMEOUT 300 static NMDevice * get_best_ip4_device (NMManager *manager, NMActRequest **out_req) @@ -864,6 +865,38 @@ schedule_activate_check (NMPolicy *policy, NMDevice *device, guint delay_seconds } } +static void +schedule_activate_all (NMPolicy *policy) +{ + GSList *iter, *devices; + + devices = nm_manager_get_devices (policy->manager); + for (iter = devices; iter; iter = g_slist_next (iter)) + schedule_activate_check (policy, NM_DEVICE (iter->data), 0); +} + +typedef struct { + NMConnection *connection; + NMPolicy *policy; +} ResetRetriesData; + +static gboolean +reset_connection_retries (gpointer user_data) +{ + ResetRetriesData *data = (ResetRetriesData *) user_data; + NMConnection *connection = NM_CONNECTION (data->connection); + NMPolicy *policy = (NMPolicy *) data->policy; + + /* If the connection is still invalid, reset auto retries back to default */ + if (get_connection_auto_retries (connection) == 0) + set_connection_auto_retries (connection, RETRIES_DEFAULT); + + schedule_activate_all (policy); + + g_free (user_data); + return FALSE; +} + static NMConnection * get_device_connection (NMDevice *device) { @@ -908,8 +941,19 @@ device_state_changed (NMDevice *device, set_connection_auto_retries (connection, tries - 1); } - if (get_connection_auto_retries (connection) == 0) + if (get_connection_auto_retries (connection) == 0) { + ResetRetriesData *reset_data; + nm_log_info (LOGD_DEVICE, "Marking connection '%s' invalid.", nm_connection_get_id (connection)); + + reset_data = g_malloc0 (sizeof (ResetRetriesData)); + reset_data->connection = connection; + reset_data->policy = policy; + + /* Schedule timeout for resetting RETRIES_TAG so that the connection can be auto-activated again. + * That handles e.g. temporary unavailable DHCP server, and such cases. */ + g_timeout_add_seconds (RESET_RETRIES_TIMEOUT, reset_connection_retries, reset_data); + } nm_connection_clear_secrets (connection); } schedule_activate_check (policy, device, 3); @@ -1032,16 +1076,6 @@ device_removed (NMManager *manager, NMDevice *device, gpointer user_data) } static void -schedule_activate_all (NMPolicy *policy) -{ - GSList *iter, *devices; - - devices = nm_manager_get_devices (policy->manager); - for (iter = devices; iter; iter = g_slist_next (iter)) - schedule_activate_check (policy, NM_DEVICE (iter->data), 0); -} - -static void connection_added (NMSettings *settings, NMConnection *connection, gpointer user_data) -- 1.7.5.1
_______________________________________________ networkmanager-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/networkmanager-list
