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. [PATCH] vpn: Reset flags before calling vpn_newlink() if VPN
      interface was up (Jussi Laakkonen)
   2. [PATCH] vpn: Add remove function callback to VPN driver
      (Jussi Laakkonen)


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

Message: 1
Date: Tue, 25 Sep 2018 16:53:58 +0300
From: Jussi Laakkonen <[email protected]>
To: [email protected]
Subject: [PATCH] vpn: Reset flags before calling vpn_newlink() if VPN
        interface was up
Message-ID: <[email protected]>

This fixes the issue of VPN provider not being set ready as VPN
interface was already up when vpn_notify() was called. It is required to
reset the flags before calling vpn_newlink(), otherwise the state of the
VPN provider is not changed.

This would result in a situation where VPN provider settings were not
sent to connmand and later adding the routes of a VPN will fail as the
interface index was not updated. Also other information (interface type,
nameservers, domain) of the VPN provider is outdated. This happens when
same VPN is re-connected after transport service has been changed.
---
 vpn/plugins/vpn.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/vpn/plugins/vpn.c b/vpn/plugins/vpn.c
index a26bcc60..6ce8f45d 100644
--- a/vpn/plugins/vpn.c
+++ b/vpn/plugins/vpn.c
@@ -308,19 +308,22 @@ static DBusMessage *vpn_notify(struct connman_task *task,
                                                     vpn_newlink, provider);
                err = connman_inet_ifup(index);
                if (err < 0) {
-                       if (err == -EALREADY)
+                       if (err == -EALREADY) {
                                /*
                                 * So the interface is up already, that is just
                                 * great. Unfortunately in this case the
                                 * newlink watch might not have been called at
                                 * all. We must manually call it here so that
                                 * the provider can go to ready state and the
-                                * routes are setup properly.
+                                * routes are setup properly. Also reset flags
+                                * so vpn_newlink() can handle the change.
                                 */
+                               data->flags = 0;
                                vpn_newlink(IFF_UP, 0, provider);
-                       else
+                       } else {
                                DBG("Cannot take interface %d up err %d/%s",
                                        index, -err, strerror(-err));
+                       }
                }
                break;
 
-- 
2.11.0



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

Message: 2
Date: Tue, 25 Sep 2018 16:54:29 +0300
From: Jussi Laakkonen <[email protected]>
To: [email protected]
Subject: [PATCH] vpn: Add remove function callback to VPN driver
Message-ID: <[email protected]>

This commit adds remove function callback to the VPN driver structure.
The prototype is int (remove*) (struct vpn_provider *provider) and is to
be registered within the VPN plugin.

This function is called from vpn/plugins/vpn.c when removing a provider
after it has been stopped. It is meant for VPNs that need to cleanup
some VPN specific content when removed or to notify other services after
removal.
---
 vpn/plugins/vpn.c | 22 ++++++++++++++++++++--
 vpn/plugins/vpn.h |  1 +
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/vpn/plugins/vpn.c b/vpn/plugins/vpn.c
index 6ce8f45d..dd686492 100644
--- a/vpn/plugins/vpn.c
+++ b/vpn/plugins/vpn.c
@@ -562,10 +562,15 @@ static int vpn_disconnect(struct vpn_provider *provider)
 static int vpn_remove(struct vpn_provider *provider)
 {
        struct vpn_data *data;
+       struct vpn_driver_data *driver_data;
+       const char *name;
+       int err = 0;
 
        data = vpn_provider_get_data(provider);
+       name = vpn_provider_get_driver_name(provider);
+
        if (!data)
-               return 0;
+               goto call_remove;
 
        if (data->watch != 0) {
                vpn_provider_unref(provider);
@@ -577,7 +582,20 @@ static int vpn_remove(struct vpn_provider *provider)
 
        g_usleep(G_USEC_PER_SEC);
        stop_vpn(provider);
-       return 0;
+
+call_remove:
+       if (!name)
+               return 0;
+
+       driver_data = g_hash_table_lookup(driver_hash, name);
+
+       if (driver_data && driver_data->vpn_driver->remove)
+               err = driver_data->vpn_driver->remove(provider);
+
+       if (err)
+               DBG("%p vpn_driver->remove() returned %d", provider, err);
+       
+       return err;
 }
 
 static int vpn_save(struct vpn_provider *provider, GKeyFile *keyfile)
diff --git a/vpn/plugins/vpn.h b/vpn/plugins/vpn.h
index 863576db..265fd82f 100644
--- a/vpn/plugins/vpn.h
+++ b/vpn/plugins/vpn.h
@@ -48,6 +48,7 @@ struct vpn_driver {
                        vpn_provider_connect_cb_t cb, const char *dbus_sender,
                        void *user_data);
        void (*disconnect) (struct vpn_provider *provider);
+       int (*remove) (struct vpn_provider *provider);
        int (*error_code) (struct vpn_provider *provider, int exit_code);
        int (*save) (struct vpn_provider *provider, GKeyFile *keyfile);
        int (*device_flags) (struct vpn_provider *provider);
-- 
2.11.0



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

Subject: Digest Footer

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


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

End of connman Digest, Vol 35, Issue 10
***************************************

Reply via email to