[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#495676: hw-detect: hw-detect new device detection misbehaves with wlan* devices



Package: hw-detect
Version: 1.65
Severity: important

Hi!

While testing a daily image on a Lenovo R61 with a manually updated
2.6.26 image, I was puzzled when I was asked "Do you intend to use
FireWire Ethernet?" on a machine which has both wired and wireless LAN
cards.

2.6.26 kernels re-introduced the old FireWire stack.  So we are back
having the eth1394 module available, and thus FireWire ethernet.  That's
why the following issue did not pop up before.

After digging through the logs, I eventually found that every single
card was listed as "FireWire ethernet" in /etc/network/devnames.  Next
step was figuring out why could make that happen.

More tests later, I eventually found that this was due to the way
hw-detect finds a new network interface after loading a module.

The list of available interface is known by snapshot_devs()
after sorting the content of the first column in /proc/net/dev,
e.g. "lo eth0".

This list is kept while a new module is loaded, then snapshot_devs() is
called again to get something like "lo eth0 eth1".  To compare those
lists and get the new interfaces, compare_devs() is used.

compare_devs() basically currently works by doing:
  echo ${devs#$olddevs}

In the previous case, as ethX interfaces are always added at the end,
both lists have the same start, and so compare_devs() nicely output
"eth1".

Unfortunately, thanks to new Wi-Fi stacks, we now have interfaces that
are not named "ethX".  On this laptop we get the following:

  compare_devs "lo eth0 wlan0 wmaster0" "lo eth0 eth1 wlan0 wmaster0"
                                                 ^^^^
                                       not inserted at the end!

I see two possible fixes here:

 * Stop sorting devices in snapshot_devs() anymore.  I don't see why
   the kernel would reorder the content of /proc/net/dev when new
   modules are inserted.  From my tests, this nicely solved the issue.
 * Make compare_dev() able to detect the addition in the middle of the
   device list.  For the record, modifying compare_devs to use the
   following did the trick:

     sed="$(echo $olddevs | sed -e 's#\([a-z0-9]\+\) *#s/\1 *//;#g')"
     echo $devs | sed -e "$sed"

I tried to dig the history of the repository in order to figure out why
snapshot_dev() used "sort" in the first place, but I was not able to get
any meaningful result.  Do anyone have an idea?

Otherwise, removing the sorting sounds like the best option to me.

Cheers,
-- 
Jérémy Bobbio                        .''`. 
lunar@debian.org                    : :Ⓐ  :  # apt-get install anarchism
                                    `. `'` 
                                      `-   

Attachment: signature.asc
Description: Digital signature


Reply to: