Comment 56 for bug 40125

Revision history for this message
leonbottou (leon-bottou) wrote : Re: Doesn't bring the network back online when resuming from suspend / hibernate

I believe that the problem is deeper,
and I think I have solved it.

My problem always was that network manager
would not detect the trusted networks.

So I tried understanding how scanning is implemented
on the ipw2200. I loaded the ipw2200 module
with associate=0 to make sure I had full control.
The 'iwlist eth1 scan' command is bizarre because
it only starts a scan when you run it as root.
Otherwise it simply returns the result of the last scan.
I used one terminal as root to start the scans,
and another as myself to see how and when
the detected networks appear.

It seems that ipw2200 implements scanning as
a lightweight operation that can take place simultaneously
with other activity. It apparently maintains a list
of detected networks. Running iwlist eth1 scan
as non root returns this list (which includes the
associated network when applicable.)
When you start scanning, results
are added to that list over the next few seconds.
They stay in the list about 12 seconds and
disappear.

It seems that the network manager code
assumes that scanning is very fast (and very intensive).
It starts scanning, waits 0.25 seconds,
and reads the list of detected networks.
Scanning happens every 15 or 20 seconds
depending on something I do not understand.
That means that a first scan returns next to nothing.
The actual results of the scan get added to the list
over the next few seconds, and removed about 12
seconds later. The next scan, 15 seconds later,
does not see the results of the previous scan
and starts from zero with the same result...

So I changed the scan interval to 10 seconds
in order to make sure that the next scan
will still see the results of the previous scan.
Here is the patch

--- network-manager-0.6.3.orig/src/nm-device-802-11-wireless.c
+++ network-manager-0.6.3/src/nm-device-802-11-wireless.c
@@ -276,16 +276,16 @@
        switch (interval)
        {
                case NM_WIRELESS_SCAN_INTERVAL_INIT:
- seconds = 15;
+ seconds = 10;
                        break;

                case NM_WIRELESS_SCAN_INTERVAL_INACTIVE:
- seconds = 120;
+ seconds = 60;
                        break;

                case NM_WIRELESS_SCAN_INTERVAL_ACTIVE:
                default:
- seconds = 20;
+ seconds = 10;
                        break;
        }

With this patch, network-manager
recognizes my trusted network in about 10 seconds.
The first scan still returns next to nothing,
but its results are still available when nm
performs the second scan.

This also works after suspend/resume cycles.

- L.