platform: rework link type detection for better fallback (bgo #743209)

See "Revert "wireless: Support of IFLA_INFO_KIND rtnl attribute""
http://www.spinics.net/lists/linux-wireless/msg132219.html

The reverted kernel patch caused rtnl_link_get_type() to return "wlan"
for WiFi devices.  Since NM depends on this function returning
NULL for WiFi devices so that it goes on to check the sysfs DEVTYPE
attribute, the kernel patch caused WiFi devices to show up as Generic
ones instead.  That's wrong, and NM should be able to more easily
handle changes in the kernel drivers from NULL to a more descriptive
rtnl_link_get_type() return, since that's the kernel trend.

What NM should be doing here is to fall back to other detection
schemes if the type is NULL or unrecognized. Make that happen and
clean things up to use a table instead of a giant if(strcmp()) block.

https://bugzilla.gnome.org/show_bug.cgi?id=743209
This commit is contained in:
Dan Williams
2015-04-14 17:18:34 -05:00
parent b484b03acf
commit 2d527b30ff
3 changed files with 59 additions and 80 deletions

View File

@@ -170,20 +170,13 @@ wifi_utils_deinit (WifiData *data)
}
gboolean
wifi_utils_is_wifi (const char *iface, const char *sysfs_path, const char *devtype)
wifi_utils_is_wifi (const char *iface, const char *sysfs_path)
{
char phy80211_path[255];
struct stat s;
g_return_val_if_fail (iface != NULL, FALSE);
if (g_strcmp0 (devtype, "wlan") == 0) {
/* All Wi-Fi drivers should set DEVTYPE=wlan. Since the kernel's
* cfg80211/nl80211 stack does, this check should match any nl80211
* capable driver (including mac82011-based ones). */
return TRUE;
}
if (sysfs_path) {
/* Check for nl80211 sysfs paths */
g_snprintf (phy80211_path, sizeof (phy80211_path), "%s/phy80211", sysfs_path);