Merge ~alfonsosanchezbeato/snappy-hwe-snaps/+git/network-manager:tweak-timeouts into ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:network-manager/xenial/1.2.2

Proposed by Alfonso Sanchez-Beato
Status: Merged
Approved by: Tony Espy
Approved revision: 344e3d6e3ae9bd2923821a3a6f736bc0ddf49583
Merged at revision: b56257274aea44e357b2a783960c9c24d240a02e
Proposed branch: ~alfonsosanchezbeato/snappy-hwe-snaps/+git/network-manager:tweak-timeouts
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:network-manager/xenial/1.2.2
Diff against target: 101 lines (+28/-6)
1 file modified
src/nm-policy.c (+28/-6)
Reviewer Review Type Date Requested Status
Tony Espy Approve
System Enablement Bot continuous-integration Approve
Review via email: mp+336819@code.launchpad.net

Description of the change

Delay reconnect retries for modems: for modems it is better to wait a bit before re-trying to connect, to give a chance for network conditions to change.

To post a comment you must log in.
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Tony Espy (awe) wrote :

OK, looks almost identical to our original vivid-touch NM patch:

https://git.launchpad.net/network-manager/tree/debian/patches/Add-modem-reconnect-delay-to-policy.patch?id=665fc317b0c8a06afaeb830215296621a5505845

The only difference being the wait interval was bumped from 5s to 10s.

Did this change ever get up-streamed? If not, we should make sure to submit it this time.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/nm-policy.c b/src/nm-policy.c
index 07bcce8..200c357 100644
--- a/src/nm-policy.c
+++ b/src/nm-policy.c
@@ -56,6 +56,9 @@
56 _NM_UTILS_MACRO_REST (__VA_ARGS__)); \56 _NM_UTILS_MACRO_REST (__VA_ARGS__)); \
57 } G_STMT_END57 } G_STMT_END
5858
59/* Time between retrying to connect, for modems */
60#define MODEM_DELAY_RETRY_S 10
61
59typedef struct _NMPolicyPrivate NMPolicyPrivate;62typedef struct _NMPolicyPrivate NMPolicyPrivate;
6063
61struct _NMPolicyPrivate {64struct _NMPolicyPrivate {
@@ -931,7 +934,7 @@ sleeping_changed (NMManager *manager, GParamSpec *pspec, gpointer user_data)
931}934}
932935
933static void936static void
934schedule_activate_check (NMPolicy *self, NMDevice *device)937schedule_activate_check (NMPolicy *self, NMDevice *device, guint delay)
935{938{
936 NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);939 NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self);
937 ActivateData *data;940 ActivateData *data;
@@ -960,7 +963,10 @@ schedule_activate_check (NMPolicy *self, NMDevice *device)
960 data = g_slice_new0 (ActivateData);963 data = g_slice_new0 (ActivateData);
961 data->policy = self;964 data->policy = self;
962 data->device = g_object_ref (device);965 data->device = g_object_ref (device);
963 data->autoactivate_id = g_idle_add (auto_activate_device, data);966 if (delay)
967 data->autoactivate_id = g_timeout_add_seconds (delay, auto_activate_device, data);
968 else
969 data->autoactivate_id = g_idle_add (auto_activate_device, data);
964 priv->pending_activation_checks = g_slist_append (priv->pending_activation_checks, data);970 priv->pending_activation_checks = g_slist_append (priv->pending_activation_checks, data);
965}971}
966972
@@ -1155,6 +1161,7 @@ device_state_changed (NMDevice *device,
1155 NMIP4Config *ip4_config;1161 NMIP4Config *ip4_config;
1156 NMIP6Config *ip6_config;1162 NMIP6Config *ip6_config;
1157 NMSettingConnection *s_con = NULL;1163 NMSettingConnection *s_con = NULL;
1164 guint delay = 0;
11581165
1159 switch (new_state) {1166 switch (new_state) {
1160 case NM_DEVICE_STATE_FAILED:1167 case NM_DEVICE_STATE_FAILED:
@@ -1184,6 +1191,11 @@ device_state_changed (NMDevice *device,
1184 if (!priv->reset_retries_id) {1191 if (!priv->reset_retries_id) {
1185 gint32 retry_time = nm_settings_connection_get_autoconnect_retry_time (connection);1192 gint32 retry_time = nm_settings_connection_get_autoconnect_retry_time (connection);
11861193
1194 gint32 actual_time = MAX (0, retry_time - nm_utils_get_monotonic_timestamp_s ());
1195 _LOGI (LOGD_DEVICE, "Disabling autoconnect for connection '%s'; "
1196 "setting retry of %d secs.",
1197 nm_connection_get_id (NM_CONNECTION (connection)), actual_time);
1198
1187 g_warn_if_fail (retry_time != 0);1199 g_warn_if_fail (retry_time != 0);
1188 priv->reset_retries_id = g_timeout_add_seconds (MAX (0, retry_time - nm_utils_get_monotonic_timestamp_s ()), reset_connections_retries, self);1200 priv->reset_retries_id = g_timeout_add_seconds (MAX (0, retry_time - nm_utils_get_monotonic_timestamp_s ()), reset_connections_retries, self);
1189 }1201 }
@@ -1250,7 +1262,17 @@ device_state_changed (NMDevice *device,
1250 update_routing_and_dns (self, FALSE);1262 update_routing_and_dns (self, FALSE);
12511263
1252 /* Device is now available for auto-activation */1264 /* Device is now available for auto-activation */
1253 schedule_activate_check (self, device);1265 if (nm_device_get_device_type (device) == NM_DEVICE_TYPE_MODEM)
1266 delay = MODEM_DELAY_RETRY_S;
1267
1268 if (connection)
1269 _LOGI (LOGD_DEVICE, "Connection '%s' disconnected, scheduling activate_check in %u seconds.",
1270 nm_connection_get_id (NM_CONNECTION (connection)), delay);
1271 else
1272 _LOGI (LOGD_DEVICE, "Device '%s' has no connection; scheduling activate_check in %u seconds.",
1273 nm_device_get_iface (device), delay);
1274
1275 schedule_activate_check (self, device, delay);
1254 break;1276 break;
12551277
1256 case NM_DEVICE_STATE_PREPARE:1278 case NM_DEVICE_STATE_PREPARE:
@@ -1363,7 +1385,7 @@ device_autoconnect_changed (NMDevice *device,
1363 NMPolicy *self = priv->self;1385 NMPolicy *self = priv->self;
13641386
1365 if (nm_device_autoconnect_allowed (device))1387 if (nm_device_autoconnect_allowed (device))
1366 schedule_activate_check (self, device);1388 schedule_activate_check (self, device, 0);
1367}1389}
13681390
1369static void1391static void
@@ -1372,7 +1394,7 @@ device_recheck_auto_activate (NMDevice *device, gpointer user_data)
1372 NMPolicyPrivate *priv = user_data;1394 NMPolicyPrivate *priv = user_data;
1373 NMPolicy *self = priv->self;1395 NMPolicy *self = priv->self;
13741396
1375 schedule_activate_check (self, device);1397 schedule_activate_check (self, device, 0);
1376}1398}
13771399
1378static void1400static void
@@ -1586,7 +1608,7 @@ schedule_activate_all (NMPolicy *self)
1586 const GSList *iter;1608 const GSList *iter;
15871609
1588 for (iter = nm_manager_get_devices (priv->manager); iter; iter = g_slist_next (iter))1610 for (iter = nm_manager_get_devices (priv->manager); iter; iter = g_slist_next (iter))
1589 schedule_activate_check (self, NM_DEVICE (iter->data));1611 schedule_activate_check (self, NM_DEVICE (iter->data), 0);
1590}1612}
15911613
1592static void1614static void

Subscribers

People subscribed via source and target branches