Blame SOURCES/0036-rh1267327-wifi-scan.patch

ab7d06
From 4b9b3d02c9e749d4e9ed99ee47ebcd7fc1b27d85 Mon Sep 17 00:00:00 2001
ab7d06
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= <jklimes@redhat.com>
ab7d06
Date: Wed, 30 Sep 2015 13:08:05 +0200
ab7d06
Subject: [PATCH] supplicant: fix BSSs property type
ab7d06
MIME-Version: 1.0
ab7d06
Content-Type: text/plain; charset=UTF-8
ab7d06
Content-Transfer-Encoding: 8bit
ab7d06
ab7d06
BSSs property is an array of object paths, not strings.
ab7d06
ab7d06
Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
ab7d06
---
ab7d06
 src/supplicant-manager/nm-supplicant-interface.c | 2 +-
ab7d06
 1 file changed, 1 insertion(+), 1 deletion(-)
ab7d06
ab7d06
diff --git a/src/supplicant-manager/nm-supplicant-interface.c b/src/supplicant-manager/nm-supplicant-interface.c
ab7d06
index 08b850a..7d33db4 100644
ab7d06
--- a/src/supplicant-manager/nm-supplicant-interface.c
ab7d06
+++ b/src/supplicant-manager/nm-supplicant-interface.c
ab7d06
@@ -556,7 +556,7 @@ props_changed_cb (GDBusProxy *proxy,
ab7d06
 		set_state_from_string (self, s);
ab7d06
 	}
ab7d06
 
ab7d06
-	if (g_variant_lookup (changed_properties, "BSSs", "^a&s", &array)) {
ab7d06
+	if (g_variant_lookup (changed_properties, "BSSs", "^a&o", &array)) {
ab7d06
 		iter = array;
ab7d06
 		while (*iter)
ab7d06
 			handle_new_bss (self, *iter++);
ab7d06
-- 
ab7d06
2.1.0
ab7d06
ab7d06
From 1649fb2928cedb7512888e3856d8a742ea40916b Mon Sep 17 00:00:00 2001
ab7d06
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= <jklimes@redhat.com>
ab7d06
Date: Wed, 30 Sep 2015 17:05:40 +0200
ab7d06
Subject: [PATCH] wifi: emit NEW_BSS on ScanDone to update APs in Wi-Fi device
ab7d06
 (rh #1267327)
ab7d06
MIME-Version: 1.0
ab7d06
Content-Type: text/plain; charset=UTF-8
ab7d06
Content-Transfer-Encoding: 8bit
ab7d06
ab7d06
When a Wi-Fi is switched to AP mode, NMDeviceWifi forgets the AP scan list.
ab7d06
Later, when the device goes back to normal managed mode, the device was not
ab7d06
able to acquire the AP list again (for a long time), because the list is only
ab7d06
populated when a new BSS is signalled. And that could take very long or never
ab7d06
happen as the supplicant would have to lost the BSS and announce it later.
ab7d06
ab7d06
Fix the problem by announcing known BSSs as a response to ScanDone signal.
ab7d06
ab7d06
Testcase:
ab7d06
$ nmcli con add type wifi ifname wlan0 con-name my-wifi-ap autoconnect off ssid MYSSID
ab7d06
$ nmcli con modify my-wifi-ap wifi.mode ap ipv4.method shared
ab7d06
$ nmcli con up my-wifi-ap
ab7d06
$ nmcli con down my-wifi-ap
ab7d06
$ nmcli device wifi list
ab7d06
ab7d06
https://bugzilla.redhat.com/show_bug.cgi?id=1267327
ab7d06
Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
ab7d06
---
ab7d06
 src/supplicant-manager/nm-supplicant-interface.c | 62 ++++++++++++++++++------
ab7d06
 1 file changed, 47 insertions(+), 15 deletions(-)
ab7d06
ab7d06
diff --git a/src/supplicant-manager/nm-supplicant-interface.c b/src/supplicant-manager/nm-supplicant-interface.c
ab7d06
index 7d33db4..30be23a 100644
ab7d06
--- a/src/supplicant-manager/nm-supplicant-interface.c
ab7d06
+++ b/src/supplicant-manager/nm-supplicant-interface.c
ab7d06
@@ -128,16 +128,36 @@ bss_props_changed_cb (GDBusProxy *proxy,
ab7d06
 	               changed_properties);
ab7d06
 }
ab7d06
 
ab7d06
+static GVariant *
ab7d06
+_get_bss_proxy_properties (NMSupplicantInterface *self, GDBusProxy *proxy)
ab7d06
+{
ab7d06
+	gs_strfreev char **properties = NULL;
ab7d06
+	GVariantBuilder builder;
ab7d06
+	char **iter;
ab7d06
+
ab7d06
+	iter = properties = g_dbus_proxy_get_cached_property_names (proxy);
ab7d06
+	if (!iter)
ab7d06
+		return NULL;
ab7d06
+
ab7d06
+	g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
ab7d06
+	while (*iter) {
ab7d06
+		GVariant *copy = g_dbus_proxy_get_cached_property (proxy, *iter);
ab7d06
+
ab7d06
+		g_variant_builder_add (&builder, "{sv}", *iter++, copy);
ab7d06
+		g_variant_unref (copy);
ab7d06
+	}
ab7d06
+
ab7d06
+	return g_variant_builder_end (&builder);
ab7d06
+}
ab7d06
+
ab7d06
+#define BSS_PROXY_INITED "bss-proxy-inited"
ab7d06
+
ab7d06
 static void
ab7d06
 on_bss_proxy_acquired (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data)
ab7d06
 {
ab7d06
 	NMSupplicantInterface *self;
ab7d06
-	NMSupplicantInterfacePrivate *priv;
ab7d06
 	gs_free_error GError *error = NULL;
ab7d06
-	gs_strfreev char **properties = NULL;
ab7d06
 	gs_unref_variant GVariant *props = NULL;
ab7d06
-	GVariantBuilder builder;
ab7d06
-	char **iter;
ab7d06
 
ab7d06
 	if (!g_async_initable_init_finish (G_ASYNC_INITABLE (proxy), result, &error)) {
ab7d06
 		if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
ab7d06
@@ -149,19 +169,12 @@ on_bss_proxy_acquired (GDBusProxy *proxy, GAsyncResult *result, gpointer user_da
ab7d06
 	}
ab7d06
 
ab7d06
 	self = NM_SUPPLICANT_INTERFACE (user_data);
ab7d06
-	priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
ab7d06
-
ab7d06
-	g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
ab7d06
-
ab7d06
-	iter = properties = g_dbus_proxy_get_cached_property_names (proxy);
ab7d06
-	while (iter && *iter) {
ab7d06
-		GVariant *copy = g_dbus_proxy_get_cached_property (proxy, *iter);
ab7d06
+	props = _get_bss_proxy_properties (self, proxy);
ab7d06
+	if (!props)
ab7d06
+		return;
ab7d06
 
ab7d06
-		g_variant_builder_add (&builder, "{sv}", *iter++, copy);
ab7d06
-		g_variant_unref (copy);
ab7d06
-	}
ab7d06
+	g_object_set_data (G_OBJECT (proxy), BSS_PROXY_INITED, GUINT_TO_POINTER (TRUE));
ab7d06
 
ab7d06
-	props = g_variant_builder_end (&builder);
ab7d06
 	g_signal_emit (self, signals[NEW_BSS], 0,
ab7d06
 	               g_dbus_proxy_get_object_path (proxy),
ab7d06
 	               g_variant_ref_sink (props));
ab7d06
@@ -508,11 +521,30 @@ signal_cb (GDBusProxy  *proxy,
ab7d06
 	gboolean success;
ab7d06
 
ab7d06
 	if (MATCH_SIGNAL (signal, "ScanDone", args, G_VARIANT_TYPE ("(b)"))) {
ab7d06
+		GVariant *props;
ab7d06
+		GHashTableIter iter;
ab7d06
+		char *bss_path;
ab7d06
+		GDBusProxy *bss_proxy;
ab7d06
+
ab7d06
 		/* Cache last scan completed time */
ab7d06
 		priv->last_scan = nm_utils_get_monotonic_timestamp_s ();
ab7d06
 
ab7d06
 		g_variant_get (args, "(b)", &success);
ab7d06
 		g_signal_emit (self, signals[SCAN_DONE], 0, success);
ab7d06
+
ab7d06
+		/* Emit NEW_BSS so that wifi device has the APs (in case it removed them) */
ab7d06
+		g_hash_table_iter_init (&iter, priv->bss_proxies);
ab7d06
+		while (g_hash_table_iter_next (&iter, (gpointer) &bss_path, (gpointer) &bss_proxy)) {
ab7d06
+			if (g_object_get_data (G_OBJECT (bss_proxy), BSS_PROXY_INITED)) {
ab7d06
+				props = _get_bss_proxy_properties (self, bss_proxy);
ab7d06
+				if (props) {
ab7d06
+					g_signal_emit (self, signals[NEW_BSS], 0,
ab7d06
+					               bss_path,
ab7d06
+					               g_variant_ref_sink (props));
ab7d06
+					g_variant_unref (props);
ab7d06
+				}
ab7d06
+			}
ab7d06
+		}
ab7d06
 	} else if (MATCH_SIGNAL (signal, "BSSAdded", args, G_VARIANT_TYPE ("(oa{sv})"))) {
ab7d06
 		if (priv->scanning)
ab7d06
 			priv->last_scan = nm_utils_get_monotonic_timestamp_s ();
ab7d06
-- 
ab7d06
2.1.0
ab7d06