Send connman mailing list submissions to
        connman@lists.01.org

To subscribe or unsubscribe via email, send a message with subject or
body 'help' to
        connman-requ...@lists.01.org

You can reach the person managing the list at
        connman-ow...@lists.01.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."

Today's Topics:

   1. [PATCH] wifi: Fix connection before disconnection completed
      (VAUTRIN Emmanuel (Canal Plus Prestataire))
   2. RE: strange connection problem
      (VAUTRIN Emmanuel (Canal Plus Prestataire))


----------------------------------------------------------------------

Date: Mon, 18 Jan 2021 13:05:11 +0000
From: "VAUTRIN Emmanuel (Canal Plus Prestataire)"
        <emmanuel.vaut...@cpexterne.org>
Subject: [PATCH] wifi: Fix connection before disconnection completed
To: "connman@lists.01.org" <connman@lists.01.org>
Message-ID:  <pr1pr02mb47942ac44a4bd19ea540339493...@pr1pr02mb4794.eur
        prd02.prod.outlook.com>
Content-Type: text/plain; charset="iso-8859-1"

>From 08aefcb3bad90041505acaf95400c5a1ac9c711a Mon Sep 17 00:00:00 2001
From: Gabriel FORTE <gfo...@wyplay.com>
Date: Fri, 15 Jan 2021 19:40:00 +0100
Subject: [PATCH] wifi: Fix connection before disconnection completed

Prevents an input/output error when a network tries to connect before
the complete disconnection of the former connected one.
---
 plugins/wifi.c | 51 +++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 44 insertions(+), 7 deletions(-)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index fc304e3b..8975a9ff 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -165,6 +165,11 @@ struct wifi_data {
        int assoc_code;
 };
 
+struct disconnect_cb_data {
+       struct wifi_data *wifi;
+       struct connman_network *network;
+};
+
 static GList *iface_list = NULL;
 
 static GList *pending_wifi_device = NULL;
@@ -2220,18 +2225,32 @@ static int network_connect(struct connman_network 
*network)
 static void disconnect_callback(int result, GSupplicantInterface *interface,
                                                                void *user_data)
 {
-       struct wifi_data *wifi = user_data;
+       struct disconnect_cb_data *cb_data = user_data;
+       struct wifi_data *wifi = cb_data->wifi;
+       struct connman_network *network = cb_data->network;
+
+       g_free(cb_data);
 
-       DBG("result %d supplicant interface %p wifi %p",
-                       result, interface, wifi);
+       DBG("result %d supplicant interface %p wifi %p networks: current %p \
+               pending %p disconnected %p", result, interface, wifi,
+               wifi->network, wifi->pending_network, network);
 
        if (result == -ECONNABORTED) {
                DBG("wifi interface no longer available");
                return;
        }
 
-       if (wifi->network && wifi->network != wifi->pending_network)
-               connman_network_set_connected(wifi->network, false);
+       if (network)
+               connman_network_set_connected(network, false);
+
+       if (network != wifi->network) {
+               if (network == wifi->pending_network) {
+                       wifi->pending_network = NULL;
+               }
+               DBG("current wifi network has changed since disconnection");
+               return;
+       }
+
        wifi->network = NULL;
 
        wifi->disconnecting = false;
@@ -2250,6 +2269,7 @@ static int network_disconnect(struct connman_network 
*network)
        struct connman_device *device = connman_network_get_device(network);
        struct wifi_data *wifi;
        int err;
+       struct disconnect_cb_data *cb_data;
 
        DBG("network %p", network);
 
@@ -2264,8 +2284,16 @@ static int network_disconnect(struct connman_network 
*network)
 
        wifi->disconnecting = true;
 
+       cb_data = g_try_malloc0(sizeof(*cb_data));
+       if (!cb_data) {
+               connman_error("Failed to allocate cb_data");
+               return -ENOMEM;
+       }
+
+       cb_data->wifi = wifi;
+       cb_data->network = network;
        err = g_supplicant_interface_disconnect(wifi->interface,
-                                               disconnect_callback, wifi);
+                                               disconnect_callback, cb_data);
        if (err < 0)
                wifi->disconnecting = false;
 
@@ -2387,9 +2415,18 @@ static bool handle_wps_completion(GSupplicantInterface 
*interface,
 
                if (!wps_ssid || wps_ssid_len != ssid_len ||
                                memcmp(ssid, wps_ssid, ssid_len) != 0) {
+                       struct disconnect_cb_data *cb_data = 
+                               g_try_malloc0(sizeof(*cb_data));
+                       if (!cb_data) {
+                               connman_error("Failed to allocate cb_data");
+                               return false;
+                       }
+
+                       cb_data->wifi = wifi;
+                       cb_data->network = network;
                        connman_network_set_associating(network, false);
                        g_supplicant_interface_disconnect(wifi->interface,
-                                               disconnect_callback, wifi);
+                                               disconnect_callback, cb_data);
                        return false;
                }
 
-- 
2.25.1



------------------------------

Date: Mon, 18 Jan 2021 13:37:04 +0000
From: "VAUTRIN Emmanuel (Canal Plus Prestataire)"
        <emmanuel.vaut...@cpexterne.org>
Subject: RE: strange connection problem
To: Thomas Green <tgre...@sorenson.com>, "connman@lists.01.org"
        <connman@lists.01.org>
Message-ID:  <pr1pr02mb4794604cfcea831bd65b572d93...@pr1pr02mb4794.eur
        prd02.prod.outlook.com>
Content-Type: text/plain; charset="iso-8859-1"

Thomas,

I have just proposed our fix ("[PATCH] wifi: Fix connection before 
disconnection completed").
Can you apply the patch, and check if it solves your bug?


B.R.

Emmanuel

------------------------------

Subject: Digest Footer

_______________________________________________
connman mailing list -- connman@lists.01.org
To unsubscribe send an email to connman-le...@lists.01.org


------------------------------

End of connman Digest, Vol 63, Issue 6
**************************************

Reply via email to