[ltp] Re: spotty wireless with t520 w/Intel wifi and xubuntu 13.04

Michael Livshin linux-thinkpad@linux-thinkpad.org
Thu, 24 Oct 2013 21:57:15 +0300

Content-Type: text/plain

It's NetworkManager.  OK, it's the combination of NetworkManager and the
wireless driver.  Even though Intel wireless cards are supposed to be
well-supported in Linux.  Go figure.  Then again, I have an RTL8192CE
card in my T420 -- now _that_ one's driver is utter shit.  Believe you
me, you have it good.

Where was I?  Ah, yes, NetworkManager.  See, that piece of software is
periodically (every two minutes, basically) issuing scans.  _While_ you
are connected.  The idea, as I understand it, is to support WiFi roaming
transparently (I mean, who cares for those sedentary idiots who just
want to sit at the table, or on the couch, and work on their laptops?
Cool portable devices, which have WiFi?  While _seated_?  Really, who
does that, right?).

Now, it looks like many Linux wireless drivers (or perhaps it's a deeper
kernel WiFi infrastructure problem?  Apparently nobody has a real clue!)
have trouble keeping the connection up and scanning at the same time,
which is manifested by disconnecting from the AP and, in many cases,
ceasing to see it for some time (usually, but not always, cured by
reloading the driver module).  The problem is greatly exacerbated by
poor (60% or less) signal in the first place.

The NetworkManager maintainers are refusing to introduce a configuration
knob to turn their moronic periodic scans off, because they figure that
any problem caused by those scans are always the driver's fault.  So
everyone should just fix their drivers.  In case you didn't know, all
the NetworkManager maintainers work for RedHat.

The proper solution, obviously, is to nuke the NetworkManager maintainer
office (if such a place exists) from orbit.  A workaround is to pull the
source and rebuild the network-manager deb in such a way that it doesn't
scan when you are connected.

See the attached patch.

You'd expect some nice individual to maintain a PPA and The Community
(whatever that is) to plaster the internets with friendly links to said
PPA, right?  Or perhaps you'd expect Ubuntu to just fix the stupid
problem in their packaged version, right?  Right.

Content-Type: text/x-diff
Content-Disposition: inline; filename=p.diff
Content-Description: patch to unbork NetworkManager

--- a/src/nm-device-wifi.c	2013-02-20 22:56:16.000000000 +0200
+++ b/src/nm-device-wifi.c	2013-10-18 16:51:20.266374157 +0300
@@ -1807,14 +1757,17 @@
 	if (!priv->pending_scan_id) {
 		guint factor = 2, next_scan = priv->scan_interval;
+		int is_activated = (nm_device_get_state (NM_DEVICE (self)) == NM_DEVICE_STATE_ACTIVATED);
 		if (    nm_device_is_activating (NM_DEVICE (self))
 		    || (nm_device_get_state (NM_DEVICE (self)) == NM_DEVICE_STATE_ACTIVATED))
 			factor = 1;
-		priv->pending_scan_id = g_timeout_add_seconds (next_scan,
-		                                               request_wireless_scan,
-		                                               self);
+		if (!is_activated) {
+			priv->pending_scan_id = g_timeout_add_seconds (next_scan,
+														   request_wireless_scan,
+														   self);
+		}
 		priv->scheduled_scan_time = now + priv->scan_interval;
 		if (backoff && (priv->scan_interval < (SCAN_INTERVAL_MAX / factor))) {
@@ -1830,10 +1783,12 @@
 			priv->scan_interval = 5;
-		nm_log_dbg (LOGD_WIFI_SCAN, "(%s): scheduled scan in %d seconds (interval now %d seconds)",
-		            nm_device_get_iface (NM_DEVICE (self)),
-		            next_scan,
-		            priv->scan_interval);
+		if (!is_activated) {
+			nm_log_dbg (LOGD_WIFI_SCAN, "(%s): scheduled scan in %d seconds (interval now %d seconds)",
+						nm_device_get_iface (NM_DEVICE (self)),
+						next_scan,
+						priv->scan_interval);
+		}