platform: wifi: drop old wifi data when an interface is renamed

Drop the old wifi data when the interface is renamed, otherwise WEXT
methods would use the old name.

https://bugzilla.gnome.org/show_bug.cgi?id=768433
This commit is contained in:
Beniamino Galvani
2016-07-06 17:59:08 +02:00
parent 79c48a559f
commit 45484af2af
3 changed files with 40 additions and 3 deletions

View File

@@ -5234,13 +5234,30 @@ static WifiData *
wifi_get_wifi_data (NMPlatform *platform, int ifindex)
{
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
const NMPlatformLink *pllink;
WifiData *wifi_data;
wifi_data = g_hash_table_lookup (priv->wifi_data, GINT_TO_POINTER (ifindex));
if (!wifi_data) {
const NMPlatformLink *pllink;
pllink = nm_platform_link_get (platform, ifindex);
pllink = nm_platform_link_get (platform, ifindex);
/* @wifi_data contains an interface name which is used for WEXT queries. If
* the interface name changes we should at least replace the name in the
* existing structure; but probably a complete reinitialization is better
* because during the initial creation there can be race conditions while
* the interface is renamed by udev.
*/
if (wifi_data && pllink) {
if (!nm_streq (wifi_utils_get_iface (wifi_data), pllink->name)) {
_LOGD ("wifi: interface %s renamed to %s, dropping old data for ifindex %d",
wifi_utils_get_iface (wifi_data),
pllink->name,
ifindex);
g_hash_table_remove (priv->wifi_data, GINT_TO_POINTER (ifindex));
wifi_data = NULL;
}
}
if (!wifi_data) {
if (pllink) {
if (pllink->type == NM_LINK_TYPE_WIFI)
wifi_data = wifi_utils_init (pllink->name, ifindex, TRUE);

View File

@@ -72,6 +72,22 @@ wifi_utils_init (const char *iface, int ifindex, gboolean check_scan)
return ret;
}
int
wifi_utils_get_ifindex (WifiData *data)
{
g_return_val_if_fail (data != NULL, -1);
return data->ifindex;
}
const char *
wifi_utils_get_iface (WifiData *data)
{
g_return_val_if_fail (data != NULL, NULL);
return data->iface;
}
NMDeviceWifiCapabilities
wifi_utils_get_caps (WifiData *data)
{

View File

@@ -33,6 +33,10 @@ gboolean wifi_utils_is_wifi (const char *iface);
WifiData *wifi_utils_init (const char *iface, int ifindex, gboolean check_scan);
int wifi_utils_get_ifindex (WifiData *data);
const char *wifi_utils_get_iface (WifiData *data);
void wifi_utils_deinit (WifiData *data);
NMDeviceWifiCapabilities wifi_utils_get_caps (WifiData *data);