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 v3 5/6] network: Add __connman_network_native_autoconnect()
      (Daniel Wagner)
   2. [PATCH v3 6/6] service: Teach autoconnect algorithm native mode
      (Daniel Wagner)
   3. Re: [PATCH v3 0/6] Teach autoconnect algorithm native mode
      (Denis Kenzior)


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

Date: Mon, 12 Apr 2021 21:58:44 +0200
From: Daniel Wagner <w...@monom.org>
Subject: [PATCH v3 5/6] network: Add
        __connman_network_native_autoconnect()
To: connman@lists.01.org
Cc: KeithG <ys3al...@gmail.com>, Daniel Wagner <w...@monom.org>
Message-ID: <20210412195845.6394-6-w...@monom.org>

This function allows to query if the network/transport supports native
autoconnect such as iwd.
---
 src/connman.h | 1 +
 src/network.c | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/src/connman.h b/src/connman.h
index 35dae6223a50..c70999c5fbd2 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -616,6 +616,7 @@ const char *__connman_network_get_type(struct 
connman_network *network);
 const char *__connman_network_get_group(struct connman_network *network);
 const char *__connman_network_get_ident(struct connman_network *network);
 bool __connman_network_get_weakness(struct connman_network *network);
+bool __connman_network_native_autoconnect(struct connman_network *network);
 
 int __connman_config_init();
 void __connman_config_cleanup(void);
diff --git a/src/network.c b/src/network.c
index 256e3b5f1c12..b12bbc091b0c 100644
--- a/src/network.c
+++ b/src/network.c
@@ -2120,6 +2120,13 @@ int connman_network_set_autoconnect(struct 
connman_network *network,
        return network->driver->set_autoconnect(network, autoconnect);
 }
 
+bool __connman_network_native_autoconnect(struct connman_network *network)
+{
+       if (!network->driver || !network->driver->set_autoconnect)
+               return false;
+       return true;
+}
+
 uint16_t connman_network_get_wifi_channel(struct connman_network *network)
 {
        return network->wifi.channel;
-- 
2.31.1

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

Date: Mon, 12 Apr 2021 21:58:45 +0200
From: Daniel Wagner <w...@monom.org>
Subject: [PATCH v3 6/6] service: Teach autoconnect algorithm native
        mode
To: connman@lists.01.org
Cc: KeithG <ys3al...@gmail.com>, Daniel Wagner <w...@monom.org>
Message-ID: <20210412195845.6394-7-w...@monom.org>

When network supports native autoconnnect skip the internal
autoconnect algorithm for this network. Introduce for this a new
CONNMAN_SERVICE_CONNECT_REASON_NATIVE and track the service connection
reason.
---
 include/service.h |  1 +
 src/service.c     | 84 +++++++++++++++++++++++++++++++----------------
 2 files changed, 56 insertions(+), 29 deletions(-)

diff --git a/include/service.h b/include/service.h
index 4a129b49315e..8f6b36b486c0 100644
--- a/include/service.h
+++ b/include/service.h
@@ -94,6 +94,7 @@ enum connman_service_connect_reason {
        CONNMAN_SERVICE_CONNECT_REASON_AUTO     = 1,
        CONNMAN_SERVICE_CONNECT_REASON_USER     = 2,
        CONNMAN_SERVICE_CONNECT_REASON_SESSION  = 3,
+       CONNMAN_SERVICE_CONNECT_REASON_NATIVE   = 4,
 };
 
 struct connman_service;
diff --git a/src/service.c b/src/service.c
index 5bb7f12594ce..a16350c65ddc 100644
--- a/src/service.c
+++ b/src/service.c
@@ -195,6 +195,8 @@ static const char *reason2string(enum 
connman_service_connect_reason reason)
                return "auto";
        case CONNMAN_SERVICE_CONNECT_REASON_SESSION:
                return "session";
+       case CONNMAN_SERVICE_CONNECT_REASON_NATIVE:
+               return "native";
        }
 
        return "unknown";
@@ -3490,6 +3492,13 @@ static void do_auto_connect(struct connman_service 
*service,
                                service->type == CONNMAN_SERVICE_TYPE_WIFI))
                return;
 
+       /*
+        * Do not use the builtin auto connect, instead rely on the
+        * native auto connect feature of the service.
+        */
+       if (service->connect_reason == CONNMAN_SERVICE_CONNECT_REASON_NATIVE)
+               return;
+
        /*
         * Run service auto connect for other than VPN services. Afterwards
         * start also VPN auto connect process.
@@ -4215,6 +4224,12 @@ static bool auto_connect_service(GList *services,
                        continue;
                }
 
+               if (service->connect_reason ==
+                               CONNMAN_SERVICE_CONNECT_REASON_NATIVE) {
+                       DBG("service %p uses native autonnect, skip", service);
+                       continue;
+               }
+
                if (service->pending ||
                                is_connecting(service->state) ||
                                is_connected(service->state)) {
@@ -6712,6 +6727,12 @@ int __connman_service_connect(struct connman_service 
*service,
 
        __connman_service_clear_error(service);
 
+       if (__connman_network_native_autoconnect(service->network) &&
+                       service->autoconnect) {
+               DBG("service %p switch connecting reason to native", service);
+               reason = CONNMAN_SERVICE_CONNECT_REASON_NATIVE;
+       }
+
        err = service_connect(service);
 
        DBG("service %p err %d", service, err);
@@ -7340,39 +7361,44 @@ static void update_from_network(struct connman_service 
*service,
 static void trigger_autoconnect(struct connman_service *service)
 {
        struct connman_device *device;
+       bool native;
 
-       connman_network_set_autoconnect(service->network,
-                               service->favorite && service->autoconnect);
-       if (service->favorite) {
-               device = connman_network_get_device(service->network);
-               if (device && !connman_device_get_scanning(device,
-                                               CONNMAN_SERVICE_TYPE_UNKNOWN)) {
-
-                       switch (service->type) {
-                       case CONNMAN_SERVICE_TYPE_UNKNOWN:
-                       case CONNMAN_SERVICE_TYPE_SYSTEM:
-                       case CONNMAN_SERVICE_TYPE_P2P:
-                               break;
+       if (!service->favorite)
+               return;
 
-                       case CONNMAN_SERVICE_TYPE_GADGET:
-                       case CONNMAN_SERVICE_TYPE_ETHERNET:
-                               if (service->autoconnect) {
-                                       __connman_service_connect(service,
-                                               
CONNMAN_SERVICE_CONNECT_REASON_AUTO);
-                                       break;
-                               }
+       native = __connman_network_native_autoconnect(service->network);
+       if (native && service->autoconnect) {
+               DBG("trigger native autoconnect");
+               connman_network_set_autoconnect(service->network, true);
+               return;
+       }
 
-                               /* fall through */
-                       case CONNMAN_SERVICE_TYPE_BLUETOOTH:
-                       case CONNMAN_SERVICE_TYPE_GPS:
-                       case CONNMAN_SERVICE_TYPE_VPN:
-                       case CONNMAN_SERVICE_TYPE_WIFI:
-                       case CONNMAN_SERVICE_TYPE_CELLULAR:
-                               do_auto_connect(service,
-                                       CONNMAN_SERVICE_CONNECT_REASON_AUTO);
-                               break;
-                       }
+       device = connman_network_get_device(service->network);
+       if (device && connman_device_get_scanning(device, 
CONNMAN_SERVICE_TYPE_UNKNOWN))
+               return;
+
+       switch (service->type) {
+       case CONNMAN_SERVICE_TYPE_UNKNOWN:
+       case CONNMAN_SERVICE_TYPE_SYSTEM:
+       case CONNMAN_SERVICE_TYPE_P2P:
+               break;
+
+       case CONNMAN_SERVICE_TYPE_GADGET:
+       case CONNMAN_SERVICE_TYPE_ETHERNET:
+               if (service->autoconnect) {
+                       __connman_service_connect(service,
+                                               
CONNMAN_SERVICE_CONNECT_REASON_AUTO);
+                       break;
                }
+
+               /* fall through */
+       case CONNMAN_SERVICE_TYPE_BLUETOOTH:
+       case CONNMAN_SERVICE_TYPE_GPS:
+       case CONNMAN_SERVICE_TYPE_VPN:
+       case CONNMAN_SERVICE_TYPE_WIFI:
+       case CONNMAN_SERVICE_TYPE_CELLULAR:
+               do_auto_connect(service, CONNMAN_SERVICE_CONNECT_REASON_AUTO);
+               break;
        }
 }
 
-- 
2.31.1

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

Date: Mon, 12 Apr 2021 15:18:33 -0500
From: Denis Kenzior <denk...@gmail.com>
Subject: Re: [PATCH v3 0/6] Teach autoconnect algorithm native mode
To: Daniel Wagner <w...@monom.org>, connman@lists.01.org
Cc: KeithG <ys3al...@gmail.com>
Message-ID: <52180535-2d09-cd40-257d-716f73f68...@gmail.com>
Content-Type: text/plain; charset=utf-8; format=flowed

Hi Daniel,

On 4/12/21 2:58 PM, Daniel Wagner wrote:
> I saw some corner case with iwd's autoconnect algorithm. For example
> there are two network net0 and net1. Both have autoconnect set. iwd
> connects to net0. Then net0 dissapears and iwd chooses to connect
> net1. Now user decides to disconnect from net1. After that net0
> appears again, iwd doesn't auto connect to it anymore.

What do you mean by disconnect here btw?

Regards,
-Denis

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

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 66, Issue 24
***************************************

Reply via email to