Merge lp:~phablet-team/network-manager/wifi-fix-cancel-scan into lp:~phablet-team/network-manager/vivid-phone-overlay

Proposed by Tony Espy
Status: Merged
Approved by: Alfonso Sanchez-Beato
Approved revision: 975
Merged at revision: 972
Proposed branch: lp:~phablet-team/network-manager/wifi-fix-cancel-scan
Merge into: lp:~phablet-team/network-manager/vivid-phone-overlay
Diff against target: 246 lines (+154/-13)
5 files modified
debian/changelog (+20/-0)
debian/patches/ignore_rfkill_if_urfkill_is_present.patch (+5/-5)
debian/patches/lp1099983_ignore-p2p-wifi-devices.patch (+9/-8)
debian/patches/series (+1/-0)
debian/patches/wifi-fix-cancel-scan.patch (+119/-0)
To merge this branch: bzr merge lp:~phablet-team/network-manager/wifi-fix-cancel-scan
Reviewer Review Type Date Requested Status
Simon Fels Approve
Alfonso Sanchez-Beato Approve
Mathieu Trudel-Lapierre Pending
Review via email: mp+288440@code.launchpad.net

Description of the change

This patch fixes a race condition in NMDeviceWiFi's scanning logic.
It's possible for cancel_pending_scan() to be called when an actual
supplicant scan is pending, which can cause scanning to stall,
effectively preventing the device from re-connecting to WiFi.

To post a comment you must log in.
973. By Tony Espy

* d/p/lp1099983_ignore-p2p-wifi-devices.patch: updated to ignore
  all p2p devices ( not just p2p0 ), as some drivers dynamically
  create differently named p2p devices which are managed externally
  in the case of WiFi Direct usage.
* d/p/lp1099983_ignore-p2p-wifi-devices.patch: refreshed

974. By Tony Espy

d/p/wifi-fix-cancel-scan.patch: add logic to supplicant_iface_state_cb
to schedule a scan if supplicant state becomes inactive, and
old_state was scanning.

975. By Tony Espy

d/p/wifi-fix-cancel-scan.patch: cancel_pending_scan, and use
request_wireless_scan instead of sched_scan to re-trigger scanning
logic when supplicant_state becomes inactive.

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

LGTM

review: Approve
Revision history for this message
Simon Fels (morphis) wrote :

LGTM

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-10-02 14:56:14 +0000
3+++ debian/changelog 2016-03-15 23:32:40 +0000
4@@ -1,3 +1,23 @@
5+network-manager (0.9.10.0-4ubuntu15.1.10) UNRELEASED; urgency=medium
6+
7+ [ Vicamo Yang ]
8+ * d/p/wifi-fix-cancel-scan.patch: This patch fixes a race condition
9+ in NMDeviceWiFi's scanning logic which can cause scanning to
10+ stall, leading to a situation where the device never re-connects
11+ to WiFi.
12+
13+ [ Tony Espy ]
14+ * d/p/lp1099983_ignore-p2p-wifi-devices.patch: updated to ignore
15+ all p2p devices ( not just p2p0 ), as some drivers dynamically
16+ create differently named p2p devices which are managed externally
17+ in the case of WiFi Direct usage.
18+ * d/p/lp1099983_ignore-p2p-wifi-devices.patch: refreshed
19+ * d/p/wifi-fix-cancel-scan.patch: add logic to supplicant_iface_state_cb
20+ to schedule a scan if supplicant state becomes inactive, and
21+ old_state was scanning.
22+
23+ -- Tony Espy <espy@canonical.com> Sat, 12 Mar 2016 15:37:31 -0500
24+
25 network-manager (0.9.10.0-4ubuntu15.1.8) vivid; urgency=medium
26
27 * d/p/0002-wifi-cull-the-scan-list-before-signalling-ScanDone-b.patch:
28
29=== modified file 'debian/patches/ignore_rfkill_if_urfkill_is_present.patch'
30--- debian/patches/ignore_rfkill_if_urfkill_is_present.patch 2014-11-18 22:46:35 +0000
31+++ debian/patches/ignore_rfkill_if_urfkill_is_present.patch 2016-03-15 23:32:40 +0000
32@@ -34,7 +34,7 @@
33
34 /* List of NMDeviceFactoryFunc pointers sorted in priority order */
35 GSList *factories;
36-@@ -217,6 +221,7 @@ typedef struct {
37+@@ -219,6 +223,7 @@ typedef struct {
38 gboolean ifstate_force_online;
39
40 guint timestamp_update_id;
41@@ -42,7 +42,7 @@
42
43 gboolean startup;
44 } NMManagerPrivate;
45-@@ -670,7 +675,20 @@ find_unmanaged_state (NMManager *manager
46+@@ -673,7 +678,20 @@ find_unmanaged_state (NMManager *manager
47 if (state == NM_DEVICE_STATE_UNMANAGED) {
48 const char *iface = nm_device_get_ip_iface (dev);
49 if (priv->ifstate_force_online) {
50@@ -63,7 +63,7 @@
51 nm_log_dbg (LOGD_CORE, "Unmanaged device found: %s; state CONNECTED forced.", iface);
52 }
53 }
54-@@ -4669,6 +4687,49 @@ dbus_connection_changed_cb (NMDBusManage
55+@@ -4784,6 +4802,49 @@ dbus_connection_changed_cb (NMDBusManage
56
57 /**********************************************************************/
58
59@@ -113,7 +113,7 @@
60 static NMManager *singleton = NULL;
61
62 NMManager *
63-@@ -4686,6 +4747,43 @@ nm_connection_provider_get (void)
64+@@ -4801,6 +4862,43 @@ nm_connection_provider_get (void)
65 return NM_CONNECTION_PROVIDER (NM_MANAGER_GET_PRIVATE (singleton)->settings);
66 }
67
68@@ -157,7 +157,7 @@
69 NMManager *
70 nm_manager_new (NMSettings *settings,
71 const char *state_file,
72-@@ -4777,13 +4875,35 @@ nm_manager_new (NMSettings *settings,
73+@@ -4892,13 +4990,35 @@ nm_manager_new (NMSettings *settings,
74 G_CALLBACK (rfkill_manager_rfkill_changed_cb),
75 singleton);
76
77
78=== modified file 'debian/patches/lp1099983_ignore-p2p-wifi-devices.patch'
79--- debian/patches/lp1099983_ignore-p2p-wifi-devices.patch 2015-02-27 00:29:09 +0000
80+++ debian/patches/lp1099983_ignore-p2p-wifi-devices.patch 2016-03-15 23:32:40 +0000
81@@ -2,23 +2,24 @@
82 Subject: Ignore p2p0 wifi devices from android.
83
84 ---
85- src/nm-manager.c | 10 ++++++++++
86- 1 file changed, 10 insertions(+)
87+ src/nm-manager.c | 11 +++++++++++
88+ 1 file changed, 11 insertions(+)
89
90-Index: network-manager-0.9.10.0/src/nm-manager.c
91+Index: b/src/nm-manager.c
92 ===================================================================
93---- network-manager-0.9.10.0.orig/src/nm-manager.c
94-+++ network-manager-0.9.10.0/src/nm-manager.c
95-@@ -2060,6 +2060,16 @@ platform_link_added (NMManager *self,
96+--- a/src/nm-manager.c
97++++ b/src/nm-manager.c
98+@@ -2151,6 +2151,17 @@ platform_link_added (NMManager *self,
99 !strncmp (plink->name, "ccmni", STRLEN ("ccmni")))
100 return;
101
102 + /*
103-+ * Ubuntu: Explicitly unmanage p2p Wi-Fi devices exposed by Android JB Wi-Fi drivers.
104++ * Ubuntu: Explicitly unmanage all p2p Wi-Fi devices which are
105++ * managed externally in the case of Wi-Fi Direct.
106 + */
107 + NMDeviceType devtype = nm_device_get_device_type (device);
108 + if ((plink->type == NM_LINK_TYPE_WIFI)
109-+ && !strncmp (plink->name, "p2p0", STRLEN ("p2p0"))) {
110++ && !strncmp (plink->name, "p2p", STRLEN ("p2p"))) {
111 + nm_log_info (LOGD_HW, "(%s): ignoring P2P wireless iface", plink->name);
112 + return;
113 + }
114
115=== modified file 'debian/patches/series'
116--- debian/patches/series 2015-10-01 21:39:53 +0000
117+++ debian/patches/series 2016-03-15 23:32:40 +0000
118@@ -76,3 +76,4 @@
119 lp1444162-add-ip6-config-to-nm-ofono-connections.patch
120 fix-ofono-plugin-leaks.patch
121 rm-scofono-plugin-dbus.patch
122+wifi-fix-cancel-scan.patch
123
124=== added file 'debian/patches/wifi-fix-cancel-scan.patch'
125--- debian/patches/wifi-fix-cancel-scan.patch 1970-01-01 00:00:00 +0000
126+++ debian/patches/wifi-fix-cancel-scan.patch 2016-03-15 23:32:40 +0000
127@@ -0,0 +1,119 @@
128+From: Vicamo Yang <vicamo.yang@canonical.com>
129+Date: Tue, 11 Jan 2016 18:40:30 -0500
130+Subject: [PATCH] wwan: add support for using oFono as a modem manager
131+
132+This patch fixes a race condition in NMDeviceWiFi's scanning logic.
133+It's possible for cancel_pending_scan() to be called when an actual
134+supplicant scan is pending, which can cause scanning to stall,
135+effectively preventing the device from re-connecting to WiFi.
136+
137+---
138+ src/devices/wifi/nm-device-wifi.c | 44 +++++++++++++++++++++++++++++++-------
139+ src/nm-policy.c | 4 ++-
140+ 2 files changed, 39 insertions(+), 9 deletions(-)
141+
142+Index: b/src/devices/wifi/nm-device-wifi.c
143+===================================================================
144+--- a/src/devices/wifi/nm-device-wifi.c
145++++ b/src/devices/wifi/nm-device-wifi.c
146+@@ -774,8 +774,10 @@ deactivate (NMDevice *dev)
147+
148+ /* Ensure we trigger a scan after deactivating a Hotspot */
149+ if (old_mode == NM_802_11_MODE_AP) {
150+- cancel_pending_scan (self);
151+- request_wireless_scan (self);
152++ if (!priv->requested_scan) {
153++ cancel_pending_scan (self);
154++ request_wireless_scan (self);
155++ }
156+ }
157+ }
158+
159+@@ -1236,6 +1238,7 @@ request_scan_cb (NMDevice *device,
160+ gpointer user_data)
161+ {
162+ NMDeviceWifi *self = NM_DEVICE_WIFI (device);
163++ NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
164+ GError *local = NULL;
165+
166+ if (error) {
167+@@ -1252,8 +1255,10 @@ request_scan_cb (NMDevice *device,
168+ return;
169+ }
170+
171+- cancel_pending_scan (self);
172+- request_wireless_scan (self);
173++ if (!priv->requested_scan) {
174++ cancel_pending_scan (self);
175++ request_wireless_scan (self);
176++ }
177+ dbus_g_method_return (context);
178+ }
179+
180+@@ -2139,8 +2144,13 @@ supplicant_iface_state_cb (NMSupplicantI
181+ nm_device_get_iface (device));
182+
183+ /* Request a scan to get latest results */
184+- cancel_pending_scan (self);
185+- request_wireless_scan (self);
186++ if (!priv->requested_scan) {
187++ /* Scan request should have been issued in nm_device_state_changed if
188++ * the device was previously unavailable.
189++ */
190++ cancel_pending_scan (self);
191++ request_wireless_scan (self);
192++ }
193+
194+ if (old_state < NM_SUPPLICANT_INTERFACE_STATE_READY)
195+ nm_device_remove_pending_action (device, "waiting for supplicant", TRUE);
196+@@ -2219,6 +2229,22 @@ supplicant_iface_state_cb (NMSupplicantI
197+ NM_DEVICE_STATE_UNAVAILABLE,
198+ NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED);
199+ break;
200++ case NM_SUPPLICANT_INTERFACE_STATE_INACTIVE:
201++ if (old_state == NM_SUPPLICANT_INTERFACE_STATE_SCANNING) {
202++ nm_log_warn (LOGD_HW | LOGD_WIFI, "(%s): supplicant state: SCANNING -> INACTIVE",
203++ nm_device_get_iface (NM_DEVICE (self)));
204++
205++ if (priv->requested_scan) {
206++ nm_log_dbg (LOGD_WIFI_SCAN, "(%s): clearing requested_scan",
207++ nm_device_get_iface (NM_DEVICE (self)));
208++
209++ priv->requested_scan = FALSE;
210++ }
211++
212++ cancel_pending_scan (self);
213++ request_wireless_scan (self);
214++ }
215++
216+ default:
217+ break;
218+ }
219+@@ -3109,8 +3135,10 @@ device_state_changed (NMDevice *device,
220+ case NM_DEVICE_STATE_DISCONNECTED:
221+ /* Kick off a scan to get latest results */
222+ priv->scan_interval = SCAN_INTERVAL_MIN;
223+- cancel_pending_scan (self);
224+- request_wireless_scan (self);
225++ if (!priv->requested_scan) {
226++ cancel_pending_scan (self);
227++ request_wireless_scan (self);
228++ }
229+ break;
230+ default:
231+ break;
232+Index: b/src/nm-policy.c
233+===================================================================
234+--- a/src/nm-policy.c
235++++ b/src/nm-policy.c
236+@@ -1034,7 +1034,9 @@ auto_activate_device (gpointer user_data
237+ g_error_free (error);
238+ }
239+ g_object_unref (subject);
240+- }
241++ } else
242++ nm_log_dbg (LOGD_DEVICE, "auto_activate_connection: no best_connection found for '%s'!",
243++ nm_device_get_iface (data->device));
244+
245+ g_slist_free (connections);
246+

Subscribers

People subscribed via source and target branches

to all changes: