Merge lp:~phablet-team/network-manager/lp1461593-wily into lp:~network-manager/network-manager/ubuntu

Proposed by Tony Espy
Status: Merged
Approved by: Mathieu Trudel-Lapierre
Approved revision: 969
Merged at revision: 968
Proposed branch: lp:~phablet-team/network-manager/lp1461593-wily
Merge into: lp:~network-manager/network-manager/ubuntu
Prerequisite: lp:~phablet-team/network-manager/lp1435776-wily
Diff against target: 331 lines (+223/-10)
6 files modified
debian/changelog (+10/-0)
debian/patches/0001-wwan-add-support-for-using-oFono-as-a-modem-manager.patch (+16/-9)
debian/patches/add_ofono_settings_support.patch (+5/-1)
debian/patches/lp1461593-add-modem-reconnect-delay-to-policy.patch (+117/-0)
debian/patches/lp1461593-add-nm-settings-connection-reset-retries-methods.patch (+73/-0)
debian/patches/series (+2/-0)
To merge this branch: bzr merge lp:~phablet-team/network-manager/lp1461593-wily
Reviewer Review Type Date Requested Status
Mathieu Trudel-Lapierre Approve
Review via email: mp+264894@code.launchpad.net

Description of the change

This change adds a 5s delay into NM_POLICY's re-connect logic, specifically so that the retry_limit of the associated connection isn't exhausted immediately whenever the connection drops, which then used to result in a 5m timer being set.

There are two changes...

1. The afore-mentioned 5m timer is now reduced to 30s for modem devices. In theory, connections shouldn't be getting disabled anymore due to the above fix, so this is a just-in-case change.

2. The low-level NM_MODEM_OFONO code wasn't setting the modem state to DISCONNECTING when disconnect() was called. This is now done, and in the associated callback ( disconnect_cb ) the new state is now determined by the ofono cached properties ( online && powered && attached ).

To post a comment you must log in.
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Ofono bits probably should be folded in to the main patch; anything that touches the core NM code should be split out by itself, so that we can upstream just that independently from any ofono support code.

If you want, I could possibly do the patch mangling.

review: Needs Fixing
967. By Tony Espy

debian/patches/add_ofono_settings_support.patch: remove code
that added APN, USERNAME and PASSWORD to NM_SETTING_GSM object.
NM doesn't actually need access to these settings, and USERNAME/
PASSWORD can cause issues with NM's secrets needed logic.

968. By Tony Espy

debian/patches/0001-wwan-add-support-for-using-oFono-as-a-modem-manager.patch,
debian/patches/lp1461593-add-nm-settings-connection-reset-retries-methods.patch,
debian/patches/add_ofono_settings_support.patch,
debian/patches/lp1461593-add-modem-reconnect-delay-to-policy.patch: More changes
to NMModemOfono's modem_state handling. Added get/set_reset_retries_timeout
methods to NMSettingsConnection, and use the set method to lower the timeout for
ofono connections to 30s. Finally added a 5s delay to NM_POLICY's activation
logic triggered when a modem device is disconnected. This allows modem time to
settle and NM to process the resulting DBus state changes. (LP: #1461593)

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Looks fine overall, though I've added some nitpicks inline. The extra delay/retries patches will need careful testing in a silo to make sure they don't break ModemManager, but they do look harmless.

review: Needs Fixing
969. By Tony Espy

Updated new patches for DEP-3, and re-ordered ofono patches.

Revision history for this message
Tony Espy (awe) wrote :

Updated patches for DEP-3, and re-ordered based on inline comments.

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2015-07-17 15:50:46 +0000
3+++ debian/changelog 2015-07-17 15:50:46 +0000
4@@ -5,6 +5,16 @@
5 NM doesn't actually need access to these settings, and USERNAME/
6 PASSWORD can cause issues with NM's secrets needed logic.
7
8+ * debian/patches/0001-wwan-add-support-for-using-oFono-as-a-modem-manager.patch,
9+ debian/patches/lp1461593-add-nm-settings-connection-reset-retries-methods.patch,
10+ debian/patches/add_ofono_settings_support.patch,
11+ debian/patches/lp1461593-add-modem-reconnect-delay-to-policy.patch: More changes
12+ to NMModemOfono's modem_state handling. Added get/set_reset_retries_timeout
13+ methods to NMSettingsConnection, and use the set method to lower the timeout for
14+ ofono connections to 30s. Finally added a 5s delay to NM_POLICY's activation
15+ logic triggered when a modem device is disconnected. This allows modem time to
16+ settle and NM to process the resulting DBus state changes. (LP: #1461593)
17+
18 -- Tony Espy <espy@canonical.com> Wed, 15 Jul 2015 15:35:17 -0400
19
20 network-manager (0.9.10.0-4ubuntu18) wily; urgency=medium
21
22=== modified file 'debian/patches/0001-wwan-add-support-for-using-oFono-as-a-modem-manager.patch'
23--- debian/patches/0001-wwan-add-support-for-using-oFono-as-a-modem-manager.patch 2015-04-13 04:34:55 +0000
24+++ debian/patches/0001-wwan-add-support-for-using-oFono-as-a-modem-manager.patch 2015-07-17 15:50:46 +0000
25@@ -304,7 +304,7 @@
26 ===================================================================
27 --- /dev/null
28 +++ network-manager-0.9.10.0/src/devices/wwan/nm-modem-ofono.c
29-@@ -0,0 +1,1140 @@
30+@@ -0,0 +1,1147 @@
31 +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
32 +/* NetworkManager -- Network link manager
33 + *
34@@ -414,7 +414,8 @@
35 +{
36 + SimpleDisconnectContext *ctx = (SimpleDisconnectContext*) user_data;
37 + NMModemOfono *self = ctx->self;
38-+ NMModemState state = nm_modem_get_state (NM_MODEM (self));
39++ NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self);
40++ NMModemState state;
41 + GError *error = NULL;
42 +
43 + nm_log_dbg (LOGD_MB, "in %s", __func__);
44@@ -429,10 +430,15 @@
45 +
46 + simple_disconnect_context_free (ctx);
47 +
48-+ if (state != NM_MODEM_STATE_SEARCHING)
49-+ nm_modem_set_state (NM_MODEM (self),
50-+ NM_MODEM_STATE_REGISTERED,
51-+ nm_modem_state_to_string (NM_MODEM_STATE_REGISTERED));
52++ /* No need to re-read contexts in this case... */
53++
54++ if (priv->modem_online && priv->gprs_powered && priv->gprs_attached)
55++ state = NM_MODEM_STATE_REGISTERED;
56++ else
57++ state = NM_MODEM_STATE_SEARCHING;
58++
59++ nm_modem_set_state (NM_MODEM (self), state,
60++ nm_modem_state_to_string (state));
61 +}
62 +
63 +static void
64@@ -449,6 +455,10 @@
65 + ctx->self = g_object_ref (self);
66 + ctx->warn = warn;
67 +
68++ nm_modem_set_state (NM_MODEM (self),
69++ NM_MODEM_STATE_DISCONNECTING,
70++ nm_modem_state_to_string (NM_MODEM_STATE_DISCONNECTING));
71++
72 + g_value_init (&value, G_TYPE_BOOLEAN);
73 + g_value_set_boolean (&value, FALSE);
74 +
75@@ -493,18 +503,15 @@
76 +{
77 + NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self);
78 + NMModemState new_state;
79-+ NMDeviceStateReason reason;
80 +
81 + if (new_enabled == priv->enabled)
82 + return;
83 +
84 + if (new_enabled) {
85 + new_state = NM_MODEM_STATE_REGISTERED;
86-+ reason = NM_DEVICE_STATE_REASON_NONE;
87 + ofono_read_contexts (self);
88 + } else {
89 + new_state = NM_MODEM_STATE_SEARCHING;
90-+ reason = NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER;
91 + }
92 +
93 + nm_modem_set_state (NM_MODEM (self),
94
95=== modified file 'debian/patches/add_ofono_settings_support.patch'
96--- debian/patches/add_ofono_settings_support.patch 2015-07-17 15:50:46 +0000
97+++ debian/patches/add_ofono_settings_support.patch 2015-07-17 15:50:46 +0000
98@@ -524,7 +524,7 @@
99 ===================================================================
100 --- /dev/null
101 +++ b/src/settings/plugins/ofono/plugin.c
102-@@ -0,0 +1,738 @@
103+@@ -0,0 +1,742 @@
104 +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
105 +
106 +/* Ofono modem settings service
107@@ -677,6 +677,10 @@
108 +
109 + /* add the new connection */
110 + exported = nm_ofono_connection_new (context);
111++
112++ /* Lower disabled timer to 30s */
113++ nm_settings_connection_set_reset_retries_timeout (NM_SETTINGS_CONNECTION (exported), 30);
114++
115 + setting = nm_connection_get_setting_connection (NM_CONNECTION (exported));
116 + g_object_set (setting, NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NULL);
117 + if (exported) {
118
119=== added file 'debian/patches/lp1461593-add-modem-reconnect-delay-to-policy.patch'
120--- debian/patches/lp1461593-add-modem-reconnect-delay-to-policy.patch 1970-01-01 00:00:00 +0000
121+++ debian/patches/lp1461593-add-modem-reconnect-delay-to-policy.patch 2015-07-17 15:50:46 +0000
122@@ -0,0 +1,117 @@
123+Author: Tony Espy <espy@canonical.com>
124+Subject: Introduce NMPolicy delay for modem activate retries
125+
126+This patch introduces a 5s delay between retry activations
127+for modem devices. Otherwise, the activation attempts can
128+flood the modem all at once, and then trigger the reset_retries
129+timeout ( which defaults to 300s ).
130+
131+Bug: https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1461593
132+
133+---
134+
135+Index: b/src/nm-policy.c
136+===================================================================
137+--- a/src/nm-policy.c
138++++ b/src/nm-policy.c
139+@@ -1229,7 +1229,7 @@ sleeping_changed (NMManager *manager, GP
140+ }
141+
142+ static void
143+-schedule_activate_check (NMPolicy *policy, NMDevice *device)
144++schedule_activate_check (NMPolicy *policy, NMDevice *device, guint delay)
145+ {
146+ NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (policy);
147+ ActivateData *data;
148+@@ -1258,7 +1258,12 @@ schedule_activate_check (NMPolicy *polic
149+ data = g_malloc0 (sizeof (ActivateData));
150+ data->policy = policy;
151+ data->device = g_object_ref (device);
152+- data->autoactivate_id = g_idle_add (auto_activate_device, data);
153++
154++ if (delay)
155++ data->autoactivate_id = g_timeout_add_seconds (delay, auto_activate_device, data);
156++ else
157++ data->autoactivate_id = g_idle_add (auto_activate_device, data);
158++
159+ priv->pending_activation_checks = g_slist_append (priv->pending_activation_checks, data);
160+ }
161+
162+@@ -1438,6 +1443,7 @@ device_state_changed (NMDevice *device,
163+ NMIP4Config *ip4_config;
164+ NMIP6Config *ip6_config;
165+ NMSettingConnection *s_con = NULL;
166++ guint delay = 0;
167+
168+ switch (new_state) {
169+ case NM_DEVICE_STATE_FAILED:
170+@@ -1455,7 +1461,7 @@ device_state_changed (NMDevice *device,
171+
172+ nm_settings_connection_set_autoconnect_blocked_reason (connection, NM_DEVICE_STATE_REASON_NO_SECRETS);
173+ } else if (tries > 0) {
174+- nm_log_dbg (LOGD_DEVICE, "Connection '%s' failed to autoconnect; %d tries left",
175++ nm_log_info (LOGD_DEVICE, "Connection '%s' failed to autoconnect; %d tries left",
176+ nm_connection_get_id (NM_CONNECTION (connection)), tries);
177+ nm_settings_connection_set_autoconnect_retries (connection, tries - 1);
178+ }
179+@@ -1466,9 +1472,14 @@ device_state_changed (NMDevice *device,
180+ /* Schedule a handler to reset retries count */
181+ if (!priv->reset_retries_id) {
182+ gint32 retry_time = nm_settings_connection_get_autoconnect_retry_time (connection);
183++ gint32 actual_time = MAX (0, retry_time - nm_utils_get_monotonic_timestamp_s ());
184++
185++ nm_log_info (LOGD_DEVICE, "Disabling autoconnect for connection '%s'; setting retry of %d.",
186++ nm_connection_get_id (NM_CONNECTION (connection)), actual_time);
187++
188+
189+ g_warn_if_fail (retry_time != 0);
190+- priv->reset_retries_id = g_timeout_add_seconds (MAX (0, retry_time - nm_utils_get_monotonic_timestamp_s ()), reset_connections_retries, policy);
191++ priv->reset_retries_id = g_timeout_add_seconds (actual_time, reset_connections_retries, policy);
192+ }
193+ }
194+ nm_connection_clear_secrets (NM_CONNECTION (connection));
195+@@ -1532,7 +1543,18 @@ device_state_changed (NMDevice *device,
196+ update_routing_and_dns (policy, FALSE);
197+
198+ /* Device is now available for auto-activation */
199+- schedule_activate_check (policy, device);
200++
201++ if (nm_device_get_device_type (device) == NM_DEVICE_TYPE_MODEM)
202++ delay = 5;
203++
204++ if (connection)
205++ nm_log_info (LOGD_DEVICE, "Connection '%s' disconnected, scheduling activate_check in %u seconds.",
206++ nm_connection_get_id (NM_CONNECTION (connection)), delay);
207++ else
208++ nm_log_info (LOGD_DEVICE, "Device has no connection; scheduling activate_check in %u seconds.",
209++ delay);
210++
211++ schedule_activate_check (policy, device, delay);
212+ break;
213+
214+ case NM_DEVICE_STATE_PREPARE:
215+@@ -1642,13 +1664,13 @@ device_autoconnect_changed (NMDevice *de
216+ gpointer user_data)
217+ {
218+ if (nm_device_get_autoconnect (device))
219+- schedule_activate_check ((NMPolicy *) user_data, device);
220++ schedule_activate_check ((NMPolicy *) user_data, device, 0);
221+ }
222+
223+ static void
224+ device_recheck_auto_activate (NMDevice *device, gpointer user_data)
225+ {
226+- schedule_activate_check (NM_POLICY (user_data), device);
227++ schedule_activate_check (NM_POLICY (user_data), device, 0);
228+ }
229+
230+ typedef struct {
231+@@ -1845,7 +1867,7 @@ schedule_activate_all (NMPolicy *policy)
232+ const GSList *iter;
233+
234+ for (iter = nm_manager_get_devices (priv->manager); iter; iter = g_slist_next (iter))
235+- schedule_activate_check (policy, NM_DEVICE (iter->data));
236++ schedule_activate_check (policy, NM_DEVICE (iter->data), 0);
237+ }
238+
239+ static void
240
241=== added file 'debian/patches/lp1461593-add-nm-settings-connection-reset-retries-methods.patch'
242--- debian/patches/lp1461593-add-nm-settings-connection-reset-retries-methods.patch 1970-01-01 00:00:00 +0000
243+++ debian/patches/lp1461593-add-nm-settings-connection-reset-retries-methods.patch 2015-07-17 15:50:46 +0000
244@@ -0,0 +1,73 @@
245+Author: Tony Espy <espy@canonical.com>
246+Subject: Add new NMSettingsConnection reset_retries get/set methods
247+
248+This patch adds get/set methods to NMSettingsConnection for the
249+reset_retries_timeout. This allows sub-classes to override the
250+default setting ( 300s ).
251+
252+Bug: https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1461593
253+
254+---
255+Index: network-manager-0.9.10.0/src/settings/nm-settings-connection.c
256+===================================================================
257+--- network-manager-0.9.10.0.orig/src/settings/nm-settings-connection.c
258++++ network-manager-0.9.10.0/src/settings/nm-settings-connection.c
259+@@ -132,6 +132,7 @@ typedef struct {
260+
261+ int autoconnect_retries;
262+ gint32 autoconnect_retry_time;
263++ int reset_retries_timeout;
264+ NMDeviceStateReason autoconnect_blocked_reason;
265+
266+ } NMSettingsConnectionPrivate;
267+@@ -1922,6 +1923,19 @@ nm_settings_connection_get_autoconnect_r
268+ return NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->autoconnect_retries;
269+ }
270+
271++int
272++nm_settings_connection_get_reset_retries_timeout (NMSettingsConnection *connection)
273++{
274++ return NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->reset_retries_timeout;
275++}
276++
277++void
278++nm_settings_connection_set_reset_retries_timeout (NMSettingsConnection *connection,
279++ int timeout)
280++{
281++ NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->reset_retries_timeout = timeout;
282++}
283++
284+ void
285+ nm_settings_connection_set_autoconnect_retries (NMSettingsConnection *connection,
286+ int retries)
287+@@ -1932,7 +1946,7 @@ nm_settings_connection_set_autoconnect_r
288+ if (retries)
289+ priv->autoconnect_retry_time = 0;
290+ else
291+- priv->autoconnect_retry_time = nm_utils_get_monotonic_timestamp_s () + AUTOCONNECT_RESET_RETRIES_TIMER;
292++ priv->autoconnect_retry_time = nm_utils_get_monotonic_timestamp_s () + priv->reset_retries_timeout;
293+ }
294+
295+ void
296+@@ -2039,6 +2053,7 @@ nm_settings_connection_init (NMSettingsC
297+
298+ priv->autoconnect_retries = AUTOCONNECT_RETRIES_DEFAULT;
299+ priv->autoconnect_blocked_reason = NM_DEVICE_STATE_REASON_NONE;
300++ priv->reset_retries_timeout = AUTOCONNECT_RESET_RETRIES_TIMER;
301+
302+ g_signal_connect (self, NM_CONNECTION_SECRETS_CLEARED, G_CALLBACK (secrets_cleared_cb), NULL);
303+ g_signal_connect (self, NM_CONNECTION_CHANGED, G_CALLBACK (changed_cb), GUINT_TO_POINTER (TRUE));
304+Index: network-manager-0.9.10.0/src/settings/nm-settings-connection.h
305+===================================================================
306+--- network-manager-0.9.10.0.orig/src/settings/nm-settings-connection.h
307++++ network-manager-0.9.10.0/src/settings/nm-settings-connection.h
308+@@ -156,6 +156,9 @@ void nm_settings_connection_reset_autoco
309+
310+ gint32 nm_settings_connection_get_autoconnect_retry_time (NMSettingsConnection *connection);
311+
312++int nm_settings_connection_get_reset_retries_timeout (NMSettingsConnection *connection);
313++void nm_settings_connection_set_reset_retries_timeout (NMSettingsConnection *connection, int timeout);
314++
315+ NMDeviceStateReason nm_settings_connection_get_autoconnect_blocked_reason (NMSettingsConnection *connection);
316+ void nm_settings_connection_set_autoconnect_blocked_reason (NMSettingsConnection *connection,
317+ NMDeviceStateReason reason);
318
319=== modified file 'debian/patches/series'
320--- debian/patches/series 2015-07-14 18:08:41 +0000
321+++ debian/patches/series 2015-07-17 15:50:46 +0000
322@@ -63,7 +63,9 @@
323 lp1099983_ignore-p2p-wifi-devices.patch
324 prioritize_3g_later.patch
325 0001-wwan-add-support-for-using-oFono-as-a-modem-manager.patch
326+lp1461593-add-nm-settings-connection-reset-retries-methods.patch
327 add_ofono_settings_support.patch
328+lp1461593-add-modem-reconnect-delay-to-policy.patch
329
330 # killswitch
331 ignore_rfkill_if_urfkill_is_present.patch

Subscribers

People subscribed via source and target branches