Merge lp:~phablet-team/network-manager/lp1461593 into lp:~phablet-team/network-manager/vivid-phone-overlay

Proposed by Tony Espy
Status: Merged
Approved by: Alfonso Sanchez-Beato
Approved revision: 964
Merged at revision: 963
Proposed branch: lp:~phablet-team/network-manager/lp1461593
Merge into: lp:~phablet-team/network-manager/vivid-phone-overlay
Diff against target: 278 lines (+258/-0)
3 files modified
debian/changelog (+9/-0)
debian/patches/lp1461593-add-modem-reconnect-delay.patch (+247/-0)
debian/patches/series (+2/-0)
To merge this branch: bzr merge lp:~phablet-team/network-manager/lp1461593
Reviewer Review Type Date Requested Status
Alfonso Sanchez-Beato Approve
Review via email: mp+261450@code.launchpad.net

Commit message

  debian/patches/lp1461593-add-modem-reconnect-delay.patch: add
  a 5s delay to NM_POLICY's activation logic triggered when a
  device is disconnected. This allows the modem time to settle
  and NM to process the resulting DBus state changes (LP: #1461593).

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
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

Just some minor comments, besides that it looks great to me.

review: Needs Fixing
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

I downloaded NM from the phablet PPA (0.9.10.0-4ubuntu15.1.2~awe2) and did some testing. Switching the preferred technology between 2G and 3G works fine. Flight mode seems to be ok too. But NM was not re-establishing the connection when switching the slot with 3G capabilities.

This happened on krillin, using 2 SIMs. Version is

channel: ubuntu-touch/rc-proposed/bq-aquaris.en
last update: 2015-06-09 10:58:15
version version: 28

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

Replies to comments added.

Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) :
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

Just tested RTM, NM does re-establish the connection when switching the slot with 3G capabilities in that case.

'Powered' does not migrate from one SIM to the other when switching the 3g slot, in vivid and in rtm.

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

Thanks Alfonso... that makes sense as the NM/ofono code was forward ported to 0.9.10 for the vivid cycle, so the logic is significantly different.

964. By Tony Espy

Fixed ws formatting in patch, and added NL to series file.

Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

LGTM

review: Approve
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

Silo 31 tested (krillin/vivid ubuntu-touch/rc-proposed/bq-aquaris.en #29)

Same results as previously, as expected:

* Switching the preferred technology between 2G and 3G works fine
* Flight mode seems to be ok too.
* NM was not re-establishing the connection when switching the slot with 3G capabilities.

Additionally, I confirmed that switching cellular data between SIM1 and SIM2 does work.

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

Silo 31 tested (arale/vivid ubuntu-touch/rc-proposed/meizu.en #11)

Ran the basic test cases from the new network-manager touch-specific test plan:

https://wiki.ubuntu.com/Process/Merges/TestPlans/network-manager

Skipped the FlightMode tests due the following bug:

https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1445080

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

Silo 31 tested (mako/vivid ubuntu-touch/rc-proposed/ubuntu #153)

Ran the basic test cases from the network-manager component test plan:

https://wiki.ubuntu.com/Process/Merges/TestPlans/network-manager

The only tests not performed were the out-of-range Wi-Fi tests and the force-mobile-disconnect tests.

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-05-16 03:08:19 +0000
3+++ debian/changelog 2015-06-09 17:23:29 +0000
4@@ -1,3 +1,12 @@
5+network-manager (0.9.10.0-4ubuntu15.1.2) vivid; urgency=medium
6+
7+ * debian/patches/lp1461593-add-modem-reconnect-delay.patch: add
8+ a 5s delay to NM_POLICY's activation logic triggered when a
9+ device is disconnected. This allows the modem time to settle
10+ and NM to process the resulting DBus state changes (LP: #1461593).
11+
12+ -- Tony Espy <espy@canonical.com> Mon, 08 Jun 2015 15:49:56 -0400
13+
14 network-manager (0.9.10.0-4ubuntu15.1.1) vivid; urgency=medium
15
16 * debian/patches/lp1435776_rm_ofono_secret_settings.patch: remove code
17
18=== added file 'debian/patches/lp1461593-add-modem-reconnect-delay.patch'
19--- debian/patches/lp1461593-add-modem-reconnect-delay.patch 1970-01-01 00:00:00 +0000
20+++ debian/patches/lp1461593-add-modem-reconnect-delay.patch 2015-06-09 17:23:29 +0000
21@@ -0,0 +1,247 @@
22+Index: network-manager-0.9.10.0/src/devices/wwan/nm-modem-ofono.c
23+===================================================================
24+--- network-manager-0.9.10.0.orig/src/devices/wwan/nm-modem-ofono.c
25++++ network-manager-0.9.10.0/src/devices/wwan/nm-modem-ofono.c
26+@@ -107,7 +107,8 @@ disconnect_done (DBusGProxy *proxy, DBus
27+ {
28+ SimpleDisconnectContext *ctx = (SimpleDisconnectContext*) user_data;
29+ NMModemOfono *self = ctx->self;
30+- NMModemState state = nm_modem_get_state (NM_MODEM (self));
31++ NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self);
32++ NMModemState state;
33+ GError *error = NULL;
34+
35+ nm_log_dbg (LOGD_MB, "in %s", __func__);
36+@@ -122,10 +123,15 @@ disconnect_done (DBusGProxy *proxy, DBus
37+
38+ simple_disconnect_context_free (ctx);
39+
40+- if (state != NM_MODEM_STATE_SEARCHING)
41+- nm_modem_set_state (NM_MODEM (self),
42+- NM_MODEM_STATE_REGISTERED,
43+- nm_modem_state_to_string (NM_MODEM_STATE_REGISTERED));
44++ /* No need to re-read contexts in this case... */
45++
46++ if (priv->modem_online && priv->gprs_powered && priv->gprs_attached)
47++ state = NM_MODEM_STATE_REGISTERED;
48++ else
49++ state = NM_MODEM_STATE_SEARCHING;
50++
51++ nm_modem_set_state (NM_MODEM (self), state,
52++ nm_modem_state_to_string (state));
53+ }
54+
55+ static void
56+@@ -142,6 +148,10 @@ disconnect (NMModem *self,
57+ ctx->self = g_object_ref (self);
58+ ctx->warn = warn;
59+
60++ nm_modem_set_state (NM_MODEM (self),
61++ NM_MODEM_STATE_DISCONNECTING,
62++ nm_modem_state_to_string (NM_MODEM_STATE_DISCONNECTING));
63++
64+ g_value_init (&value, G_TYPE_BOOLEAN);
65+ g_value_set_boolean (&value, FALSE);
66+
67+@@ -186,18 +196,15 @@ update_ofono_enabled (NMModemOfono *self
68+ {
69+ NMModemOfonoPrivate *priv = NM_MODEM_OFONO_GET_PRIVATE (self);
70+ NMModemState new_state;
71+- NMDeviceStateReason reason;
72+
73+ if (new_enabled == priv->enabled)
74+ return;
75+
76+ if (new_enabled) {
77+ new_state = NM_MODEM_STATE_REGISTERED;
78+- reason = NM_DEVICE_STATE_REASON_NONE;
79+ ofono_read_contexts (self);
80+ } else {
81+ new_state = NM_MODEM_STATE_SEARCHING;
82+- reason = NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER;
83+ }
84+
85+ nm_modem_set_state (NM_MODEM (self),
86+Index: network-manager-0.9.10.0/src/nm-policy.c
87+===================================================================
88+--- network-manager-0.9.10.0.orig/src/nm-policy.c
89++++ network-manager-0.9.10.0/src/nm-policy.c
90+@@ -1229,7 +1229,7 @@ sleeping_changed (NMManager *manager, GP
91+ }
92+
93+ static void
94+-schedule_activate_check (NMPolicy *policy, NMDevice *device)
95++schedule_activate_check (NMPolicy *policy, NMDevice *device, guint delay)
96+ {
97+ NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (policy);
98+ ActivateData *data;
99+@@ -1258,7 +1258,12 @@ schedule_activate_check (NMPolicy *polic
100+ data = g_malloc0 (sizeof (ActivateData));
101+ data->policy = policy;
102+ data->device = g_object_ref (device);
103+- data->autoactivate_id = g_idle_add (auto_activate_device, data);
104++
105++ if (delay)
106++ data->autoactivate_id = g_timeout_add_seconds (delay, auto_activate_device, data);
107++ else
108++ data->autoactivate_id = g_idle_add (auto_activate_device, data);
109++
110+ priv->pending_activation_checks = g_slist_append (priv->pending_activation_checks, data);
111+ }
112+
113+@@ -1438,6 +1443,7 @@ device_state_changed (NMDevice *device,
114+ NMIP4Config *ip4_config;
115+ NMIP6Config *ip6_config;
116+ NMSettingConnection *s_con = NULL;
117++ guint delay = 0;
118+
119+ switch (new_state) {
120+ case NM_DEVICE_STATE_FAILED:
121+@@ -1455,7 +1461,7 @@ device_state_changed (NMDevice *device,
122+
123+ nm_settings_connection_set_autoconnect_blocked_reason (connection, NM_DEVICE_STATE_REASON_NO_SECRETS);
124+ } else if (tries > 0) {
125+- nm_log_dbg (LOGD_DEVICE, "Connection '%s' failed to autoconnect; %d tries left",
126++ nm_log_info (LOGD_DEVICE, "Connection '%s' failed to autoconnect; %d tries left",
127+ nm_connection_get_id (NM_CONNECTION (connection)), tries);
128+ nm_settings_connection_set_autoconnect_retries (connection, tries - 1);
129+ }
130+@@ -1466,9 +1472,14 @@ device_state_changed (NMDevice *device,
131+ /* Schedule a handler to reset retries count */
132+ if (!priv->reset_retries_id) {
133+ gint32 retry_time = nm_settings_connection_get_autoconnect_retry_time (connection);
134++ gint32 actual_time = MAX (0, retry_time - nm_utils_get_monotonic_timestamp_s ());
135++
136++ nm_log_info (LOGD_DEVICE, "Disabling autoconnect for connection '%s'; setting retry of %d.",
137++ nm_connection_get_id (NM_CONNECTION (connection)), actual_time);
138++
139+
140+ g_warn_if_fail (retry_time != 0);
141+- priv->reset_retries_id = g_timeout_add_seconds (MAX (0, retry_time - nm_utils_get_monotonic_timestamp_s ()), reset_connections_retries, policy);
142++ priv->reset_retries_id = g_timeout_add_seconds (actual_time, reset_connections_retries, policy);
143+ }
144+ }
145+ nm_connection_clear_secrets (NM_CONNECTION (connection));
146+@@ -1532,7 +1543,18 @@ device_state_changed (NMDevice *device,
147+ update_routing_and_dns (policy, FALSE);
148+
149+ /* Device is now available for auto-activation */
150+- schedule_activate_check (policy, device);
151++
152++ if (nm_device_get_device_type (device) == NM_DEVICE_TYPE_MODEM)
153++ delay = 5;
154++
155++ if (connection)
156++ nm_log_info (LOGD_DEVICE, "Connection '%s' disconnected, scheduling activate_check in %u seconds.",
157++ nm_connection_get_id (NM_CONNECTION (connection)), delay);
158++ else
159++ nm_log_info (LOGD_DEVICE, "Device has no connection; scheduling activate_check in %u seconds.",
160++ delay);
161++
162++ schedule_activate_check (policy, device, delay);
163+ break;
164+
165+ case NM_DEVICE_STATE_PREPARE:
166+@@ -1642,13 +1664,13 @@ device_autoconnect_changed (NMDevice *de
167+ gpointer user_data)
168+ {
169+ if (nm_device_get_autoconnect (device))
170+- schedule_activate_check ((NMPolicy *) user_data, device);
171++ schedule_activate_check ((NMPolicy *) user_data, device, 0);
172+ }
173+
174+ static void
175+ device_recheck_auto_activate (NMDevice *device, gpointer user_data)
176+ {
177+- schedule_activate_check (NM_POLICY (user_data), device);
178++ schedule_activate_check (NM_POLICY (user_data), device, 0);
179+ }
180+
181+ typedef struct {
182+@@ -1845,7 +1867,7 @@ schedule_activate_all (NMPolicy *policy)
183+ const GSList *iter;
184+
185+ for (iter = nm_manager_get_devices (priv->manager); iter; iter = g_slist_next (iter))
186+- schedule_activate_check (policy, NM_DEVICE (iter->data));
187++ schedule_activate_check (policy, NM_DEVICE (iter->data), 0);
188+ }
189+
190+ static void
191+Index: network-manager-0.9.10.0/src/settings/nm-settings-connection.c
192+===================================================================
193+--- network-manager-0.9.10.0.orig/src/settings/nm-settings-connection.c
194++++ network-manager-0.9.10.0/src/settings/nm-settings-connection.c
195+@@ -132,6 +132,7 @@ typedef struct {
196+
197+ int autoconnect_retries;
198+ gint32 autoconnect_retry_time;
199++ int reset_retries_timeout;
200+ NMDeviceStateReason autoconnect_blocked_reason;
201+
202+ } NMSettingsConnectionPrivate;
203+@@ -1922,6 +1923,19 @@ nm_settings_connection_get_autoconnect_r
204+ return NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->autoconnect_retries;
205+ }
206+
207++int
208++nm_settings_connection_get_reset_retries_timeout (NMSettingsConnection *connection)
209++{
210++ return NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->reset_retries_timeout;
211++}
212++
213++void
214++nm_settings_connection_set_reset_retries_timeout (NMSettingsConnection *connection,
215++ int timeout)
216++{
217++ NM_SETTINGS_CONNECTION_GET_PRIVATE (connection)->reset_retries_timeout = timeout;
218++}
219++
220+ void
221+ nm_settings_connection_set_autoconnect_retries (NMSettingsConnection *connection,
222+ int retries)
223+@@ -1932,7 +1946,7 @@ nm_settings_connection_set_autoconnect_r
224+ if (retries)
225+ priv->autoconnect_retry_time = 0;
226+ else
227+- priv->autoconnect_retry_time = nm_utils_get_monotonic_timestamp_s () + AUTOCONNECT_RESET_RETRIES_TIMER;
228++ priv->autoconnect_retry_time = nm_utils_get_monotonic_timestamp_s () + priv->reset_retries_timeout;
229+ }
230+
231+ void
232+@@ -2039,6 +2053,7 @@ nm_settings_connection_init (NMSettingsC
233+
234+ priv->autoconnect_retries = AUTOCONNECT_RETRIES_DEFAULT;
235+ priv->autoconnect_blocked_reason = NM_DEVICE_STATE_REASON_NONE;
236++ priv->reset_retries_timeout = AUTOCONNECT_RESET_RETRIES_TIMER;
237+
238+ g_signal_connect (self, NM_CONNECTION_SECRETS_CLEARED, G_CALLBACK (secrets_cleared_cb), NULL);
239+ g_signal_connect (self, NM_CONNECTION_CHANGED, G_CALLBACK (changed_cb), GUINT_TO_POINTER (TRUE));
240+Index: network-manager-0.9.10.0/src/settings/nm-settings-connection.h
241+===================================================================
242+--- network-manager-0.9.10.0.orig/src/settings/nm-settings-connection.h
243++++ network-manager-0.9.10.0/src/settings/nm-settings-connection.h
244+@@ -156,6 +156,9 @@ void nm_settings_connection_reset_autoco
245+
246+ gint32 nm_settings_connection_get_autoconnect_retry_time (NMSettingsConnection *connection);
247+
248++int nm_settings_connection_get_reset_retries_timeout (NMSettingsConnection *connection);
249++void nm_settings_connection_set_reset_retries_timeout (NMSettingsConnection *connection, int timeout);
250++
251+ NMDeviceStateReason nm_settings_connection_get_autoconnect_blocked_reason (NMSettingsConnection *connection);
252+ void nm_settings_connection_set_autoconnect_blocked_reason (NMSettingsConnection *connection,
253+ NMDeviceStateReason reason);
254+Index: network-manager-0.9.10.0/src/settings/plugins/ofono/plugin.c
255+===================================================================
256+--- network-manager-0.9.10.0.orig/src/settings/plugins/ofono/plugin.c
257++++ network-manager-0.9.10.0/src/settings/plugins/ofono/plugin.c
258+@@ -150,6 +150,10 @@ SCPluginOfono_parse_contexts (SCPluginOf
259+
260+ /* add the new connection */
261+ exported = nm_ofono_connection_new (context);
262++
263++ /* Lower disabled timer to 30s */
264++ nm_settings_connection_set_reset_retries_timeout (NM_SETTINGS_CONNECTION (exported), 30);
265++
266+ setting = nm_connection_get_setting_connection (NM_CONNECTION (exported));
267+ g_object_set (setting, NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NULL);
268+ if (exported) {
269
270=== modified file 'debian/patches/series'
271--- debian/patches/series 2015-05-16 03:08:19 +0000
272+++ debian/patches/series 2015-06-09 17:23:29 +0000
273@@ -69,3 +69,5 @@
274 ignore_rfkill_if_urfkill_is_present.patch
275 CVE-2015-1322.patch
276 lp1435776_rm_ofono_secret_settings.patch
277+lp1461593-add-modem-reconnect-delay.patch
278+

Subscribers

People subscribed via source and target branches

to all changes: