Send connman mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.01.org/mailman/listinfo/connman
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

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


Today's Topics:

   1. Re: [PATCH 1/3] vpn: Use Connect2 method only when D-Bus
      sender is set (Jussi Laakkonen)
   2. Force disable a service (Alexandru Vasiu)
   3. Re: [PATCH] vpn: Save provider configuration when properties
      are changed (Jussi Laakkonen)
   4. [PATCH 1/3] vpn: Read user routes from D-Bus message into
      sorted list (Jussi Laakkonen)
   5. [PATCH 0/3] VPN D-Bus property management fixes (Jussi Laakkonen)
   6. [PATCH 2/3] vpn: Save provider configuration when properties
      are changed (Jussi Laakkonen)
   7. [PATCH 3/3] vpn: Save configuration only when a parameter has
      been changed (Jussi Laakkonen)


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

Message: 1
Date: Mon, 1 Oct 2018 12:16:12 +0300
From: Jussi Laakkonen <[email protected]>
To: Daniel Wagner <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 1/3] vpn: Use Connect2 method only when D-Bus
        sender is set
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8; format=flowed

Hi Daniel,

On 9/29/18 12:48 PM, Daniel Wagner wrote:
> Hi Jussi,
> 
> On 09/28/2018 02:33 PM, Jussi Laakkonen wrote:
>> This fix addresses the issue of not being able to connect a VPN if it
>> has autoconnect set and connection is triggered by connmand. In such
>> case dbus_sender is not set and call to Connect2 method of
>> net.connman.vpn.Connection cannot be done.
>>
>> Also, print correct D-Bus method called in case of error. If the
>> dbus_sender is not set or is empty Connect() will be used instead of
>> Connect2().
>>
>> This amends changes of commit 3997c1595fe44d7c85215fd1cd89ecf778c62206.
> 
> All three patches applied. The VPN stuff works really nicely now. I 
> really appreciate your work on it!
> 
> Thanks,
> Daniel
Good to hear. More VPN fixes and features will arrive when time allows.

- Jussi


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

Message: 2
Date: Mon, 1 Oct 2018 13:42:54 +0000
From: Alexandru Vasiu <[email protected]>
To: "[email protected]" <[email protected]>
Subject: Force disable a service
Message-ID:
        
<sn6pr04mb4926942dcbb1841dadafcf6e98...@sn6pr04mb4926.namprd04.prod.outlook.com>
        
Content-Type: text/plain; charset="iso-8859-1"

Hi,


I want to disable a service and to remain like that (even if I pull out the 
cable and I plug in) until I enable it (using DHCP or static method), without 
restarting connman daemon.

I tried with a config file in /var/lib/connman:

root:/var/lib/connman# cat interfaces.config
[service_00802F23CA1B]
MAC = 00:80:2F:23:CA:1B
Name = ethernet_cable_00802F23CA1B
IPv4 = off

and then I disconnected the service using disconnect command. The problem is 
that after I re-plug in the cable, connman ignores the config file and sets 
that interface using DHCP.

I also tried with NetworkInterfaceBlacklist from /etc/connman/main.conf, but 
this requires a restart of connmand.

Is there another solution to this issue?


Thank you,
Alex Vasiu


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

Message: 3
Date: Mon, 1 Oct 2018 18:31:48 +0300
From: Jussi Laakkonen <[email protected]>
To: [email protected]
Subject: Re: [PATCH] vpn: Save provider configuration when properties
        are changed
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8; format=flowed

On 9/27/18 5:54 PM, Jussi Laakkonen wrote:
> This commit adds saving of provider configuration when a property
> is added, changed or cleared via net.connman.vpn D-Bus interface
> net.connman.vpn.Connection using SetProperty or ClearProperty
> methods.
> ---
>   vpn/vpn-provider.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/vpn/vpn-provider.c b/vpn/vpn-provider.c
> index dd54ac08..adc41754 100644
> --- a/vpn/vpn-provider.c
> +++ b/vpn/vpn-provider.c
> @@ -91,6 +91,7 @@ struct vpn_provider {
>   
>   static void append_properties(DBusMessageIter *iter,
>                               struct vpn_provider *provider);
> +static int vpn_provider_save(struct vpn_provider *provider);
>   
>   static void free_route(gpointer data)
>   {
> @@ -456,6 +457,8 @@ static DBusMessage *set_property(DBusConnection *conn, 
> DBusMessage *msg,
>               vpn_provider_set_string(provider, name, str);
>       }
>   
> +     vpn_provider_save(provider);
> +
>       return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
>   }
>   
> @@ -484,6 +487,8 @@ static DBusMessage *clear_property(DBusConnection *conn, 
> DBusMessage *msg,
>               return __connman_error_invalid_property(msg);
>       }
>   
> +     vpn_provider_save(provider);
> +
>       return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
>   }
>   
> 

Actually. discard this. I have another one incoming that includes this 
change.

- Jussi


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

Message: 4
Date: Mon,  1 Oct 2018 18:58:31 +0300
From: Jussi Laakkonen <[email protected]>
To: [email protected]
Subject: [PATCH 1/3] vpn: Read user routes from D-Bus message into
        sorted list
Message-ID: <[email protected]>

This commit adds a sorting function for adding user routes into the
GSList. Order of the routes is determined by 1) IP protocol (based on
their numeric values), 2) network addresses, 3) netmask addresses and
4) gateway address.
---
 vpn/vpn-provider.c | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/vpn/vpn-provider.c b/vpn/vpn-provider.c
index dd54ac08..d94d73ef 100644
--- a/vpn/vpn-provider.c
+++ b/vpn/vpn-provider.c
@@ -190,6 +190,39 @@ static int provider_routes_changed(struct vpn_provider 
*provider)
        return 0;
 }
 
+/*
+ * Sort vpn_route struct based on (similarly to the route key in hash table):
+ * 1) IP protocol number
+ * 2) Network addresses
+ * 3) Netmask addresses
+ * 4) Gateway addresses
+ */
+static gint compare_route(gconstpointer a, gconstpointer b)
+{
+       const struct vpn_route *route_a = a;
+       const struct vpn_route *route_b = b;
+       int difference;
+
+       /* If IP families differ, prefer IPv6 over IPv4 */
+       if (route_a->family != route_b->family) {
+               if (route_a->family < route_b->family)
+                       return -1;
+
+               if (route_b->family > route_b->family)
+                       return 1;
+       }
+
+       /* If networks differ, return  */
+       if ((difference = g_strcmp0(route_a->network, route_b->network)))
+               return difference;
+
+       /* If netmasks differ, return. */
+       if ((difference = g_strcmp0(route_a->netmask, route_b->netmask)))
+               return difference;
+
+       return g_strcmp0(route_a->gateway, route_b->gateway);
+}
+
 static GSList *read_route_dict(GSList *routes, DBusMessageIter *dicts)
 {
        DBusMessageIter dict, value, entry;
@@ -274,7 +307,7 @@ static GSList *read_route_dict(GSList *routes, 
DBusMessageIter *dicts)
        route->netmask = g_strdup(netmask);
        route->gateway = g_strdup(gateway);
 
-       routes = g_slist_prepend(routes, route);
+       routes = g_slist_insert_sorted(routes, route, compare_route);
        return routes;
 }
 
-- 
2.19.0



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

Message: 5
Date: Mon,  1 Oct 2018 18:58:30 +0300
From: Jussi Laakkonen <[email protected]>
To: [email protected]
Subject: [PATCH 0/3] VPN D-Bus property management fixes
Message-ID: <[email protected]>

This set of commits improves the management of VPN properties changed
over D-Bus. The properties, if changed, are saved accordingly now. The
routes provided via D-Bus are added into sorted list to allow checking
if they have changed and need to be saved.

Thanks to Slava Monich for pre-patch comments.

Jussi Laakkonen (3):
  vpn: Read user routes from D-Bus message into sorted list
  vpn: Save provider configuration when properties are changed
  vpn: Save configuration only when a parameter has been changed

 vpn/vpn-provider.c | 128 +++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 119 insertions(+), 9 deletions(-)

-- 
2.19.0



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

Message: 6
Date: Mon,  1 Oct 2018 18:58:32 +0300
From: Jussi Laakkonen <[email protected]>
To: [email protected]
Subject: [PATCH 2/3] vpn: Save provider configuration when properties
        are changed
Message-ID: <[email protected]>

This commit adds saving of provider configuration when a property
is added, changed or cleared via net.connman.vpn D-Bus interface
net.connman.vpn.Connection using SetProperty or ClearProperty
methods.
---
 vpn/vpn-provider.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/vpn/vpn-provider.c b/vpn/vpn-provider.c
index d94d73ef..ec1fbfc3 100644
--- a/vpn/vpn-provider.c
+++ b/vpn/vpn-provider.c
@@ -91,6 +91,7 @@ struct vpn_provider {
 
 static void append_properties(DBusMessageIter *iter,
                                struct vpn_provider *provider);
+static int vpn_provider_save(struct vpn_provider *provider);
 
 static void free_route(gpointer data)
 {
@@ -489,6 +490,8 @@ static DBusMessage *set_property(DBusConnection *conn, 
DBusMessage *msg,
                vpn_provider_set_string(provider, name, str);
        }
 
+       vpn_provider_save(provider);
+
        return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
 }
 
@@ -517,6 +520,8 @@ static DBusMessage *clear_property(DBusConnection *conn, 
DBusMessage *msg,
                return __connman_error_invalid_property(msg);
        }
 
+       vpn_provider_save(provider);
+
        return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
 }
 
-- 
2.19.0



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

Message: 7
Date: Mon,  1 Oct 2018 18:58:33 +0300
From: Jussi Laakkonen <[email protected]>
To: [email protected]
Subject: [PATCH 3/3] vpn: Save configuration only when a parameter has
        been changed
Message-ID: <[email protected]>

This commit improves the saving procedure by reducing the amount of
writes to disk when a property change (or clearing a property) does not
introduce a change to values. PropertyChanged signal is now emitted only
for the properties that have changed.

The set_string() now returns PROP_NOT_CHANGED value (1) when there is
no change in the property value, otherwise PROP_CHANGED is retured.
This return value (via wrappers to set_string()) is handled by
set_property() and clear_property() methods that are connected to D-Bus.

Additionally added a functionality to check if the user network lists
have any difference. This is done before deleting the routes to see if
the new user given routes are a match on the old routes used by the
provider.
---
 vpn/vpn-provider.c | 92 +++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 82 insertions(+), 10 deletions(-)

diff --git a/vpn/vpn-provider.c b/vpn/vpn-provider.c
index ec1fbfc3..bdef2c94 100644
--- a/vpn/vpn-provider.c
+++ b/vpn/vpn-provider.c
@@ -23,6 +23,9 @@
 #include <config.h>
 #endif
 
+#define PROP_CHANGED 0
+#define PROP_NOT_CHANGED 1
+
 #include <errno.h>
 #include <stdio.h>
 #include <string.h>
@@ -438,6 +441,41 @@ static DBusMessage *get_properties(DBusConnection *conn,
        return reply;
 }
 
+static bool network_lists_equal(GSList *a, GSList *b)
+{
+       struct vpn_route *route_a, *route_b;
+       GSList *iter_a, *iter_b;
+       bool ret = false;
+
+       /* No change if both are NULL. */
+       if (!a && !b)
+               return true;
+
+       /*
+        * If either of lists is NULL or sizes do not match the lists are not
+        * equal.
+        */
+       if ((!a || !b) || (g_slist_length(a) != g_slist_length(b)))
+               return false;
+
+       /* Routes are in sorted list so items can be compared in order. */
+       for (iter_a = a, iter_b = b; iter_a && iter_b; iter_a = iter_a->next,
+               iter_b = iter_b->next) {
+
+               route_a = iter_a->data;
+               route_b = iter_b->data;
+
+               if (compare_route(route_a, route_b) != 0)
+                       goto done;
+
+       }
+
+       ret = true;
+
+done:
+       return ret;
+}
+
 static DBusMessage *set_property(DBusConnection *conn, DBusMessage *msg,
                                                                void *data)
 {
@@ -445,6 +483,7 @@ static DBusMessage *set_property(DBusConnection *conn, 
DBusMessage *msg,
        DBusMessageIter iter, value;
        const char *name;
        int type;
+       bool change = false;
 
        DBG("conn %p", conn);
 
@@ -474,7 +513,8 @@ static DBusMessage *set_property(DBusConnection *conn, 
DBusMessage *msg,
                        return __connman_error_invalid_arguments(msg);
 
                networks = get_user_networks(&value);
-               if (networks) {
+               if (networks && !network_lists_equal(provider->user_networks,
+                               networks)) {
                        del_routes(provider);
                        provider->user_networks = networks;
                        set_user_networks(provider, provider->user_networks);
@@ -482,15 +522,21 @@ static DBusMessage *set_property(DBusConnection *conn, 
DBusMessage *msg,
                        if (!handle_routes)
                                send_routes(provider, provider->user_routes,
                                                                "UserRoutes");
+
+                       change = true;
                }
        } else {
                const char *str;
 
                dbus_message_iter_get_basic(&value, &str);
-               vpn_provider_set_string(provider, name, str);
+
+               if (vpn_provider_set_string(provider, name, str) ==
+                               PROP_CHANGED)
+                       change = true;
        }
 
-       vpn_provider_save(provider);
+       if (change)
+               vpn_provider_save(provider);
 
        return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
 }
@@ -500,6 +546,7 @@ static DBusMessage *clear_property(DBusConnection *conn, 
DBusMessage *msg,
 {
        struct vpn_provider *provider = data;
        const char *name;
+       bool change = false;
 
        DBG("conn %p", conn);
 
@@ -514,13 +561,19 @@ static DBusMessage *clear_property(DBusConnection *conn, 
DBusMessage *msg,
 
                if (!handle_routes)
                        send_routes(provider, provider->user_routes, name);
+
+               change = true;
        } else if (vpn_provider_get_string(provider, name)) {
-               vpn_provider_set_string(provider, name, NULL);
+
+               if (vpn_provider_set_string(provider, name, NULL) ==
+                               PROP_CHANGED)
+                       change = true;
        } else {
                return __connman_error_invalid_property(msg);
        }
 
-       vpn_provider_save(provider);
+       if (change)
+               vpn_provider_save(provider);
 
        return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
 }
@@ -2216,19 +2269,35 @@ static int set_string(struct vpn_provider *provider,
                hide_value ? "<not printed>" : value);
 
        if (g_str_equal(key, "Type")) {
+
+               if (!g_strcmp0(provider->type, value))
+                       return PROP_NOT_CHANGED;
+
                g_free(provider->type);
                provider->type = g_ascii_strdown(value, -1);
                send_value(provider->path, "Type", provider->type);
        } else if (g_str_equal(key, "Name")) {
+
+               if (!g_strcmp0(provider->name, value))
+                       return PROP_NOT_CHANGED;
+
                g_free(provider->name);
                provider->name = g_strdup(value);
                send_value(provider->path, "Name", provider->name);
        } else if (g_str_equal(key, "Host")) {
+
+               if (!g_strcmp0(provider->host, value))
+                       return PROP_NOT_CHANGED;
+
                g_free(provider->host);
                provider->host = g_strdup(value);
                send_value(provider->path, "Host", provider->host);
        } else if (g_str_equal(key, "VPN.Domain") ||
                        g_str_equal(key, "Domain")) {
+
+               if (!g_strcmp0(provider->domain, value))
+                       return PROP_NOT_CHANGED;
+
                g_free(provider->domain);
                provider->domain = g_strdup(value);
                send_value(provider->path, "Domain", provider->domain);
@@ -2236,10 +2305,13 @@ static int set_string(struct vpn_provider *provider,
                struct vpn_setting *setting;
 
                setting = g_hash_table_lookup(provider->setting_strings, key);
-               if (setting && !immutable &&
-                                               setting->immutable) {
-                       DBG("Trying to set immutable variable %s", key);
-                       return -EPERM;
+               if (setting) {
+                       if (!immutable && setting->immutable) {
+                               DBG("Trying to set immutable variable %s", key);
+                               return -EPERM;
+                       } else if (!g_strcmp0(setting->value, value)) {
+                               return PROP_NOT_CHANGED;
+                       }
                }
 
                setting = g_try_new0(struct vpn_setting, 1);
@@ -2259,7 +2331,7 @@ static int set_string(struct vpn_provider *provider,
                                g_strdup(key), setting);
        }
 
-       return 0;
+       return PROP_CHANGED;
 }
 
 int vpn_provider_set_string(struct vpn_provider *provider,
-- 
2.19.0



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

Subject: Digest Footer

_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman


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

End of connman Digest, Vol 36, Issue 1
**************************************

Reply via email to