summaryrefslogtreecommitdiff
path: root/vpn/plugins/vpn.c
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2012-11-12 12:07:50 (GMT)
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-11-23 10:58:52 (GMT)
commit13f0741726c7710e998de0c9c8384e0f0279f99d (patch)
tree6d44a1a990768b33a0ec7d4fe39a1ba6cc895499 /vpn/plugins/vpn.c
parentb5bcfa6d3a39e9a2f35c823884205fa5fcf24c9d (diff)
downloadconnman-13f0741726c7710e998de0c9c8384e0f0279f99d.zip
connman-13f0741726c7710e998de0c9c8384e0f0279f99d.tar.gz
connman-13f0741726c7710e998de0c9c8384e0f0279f99d.tar.bz2
vpnd: Make sure provider is taken to ready state
If the connman_inet_ifup() says the interface is already UP, then it is possible that we might not get a call to vpn_newlink(). That would be really bad as the provider would then never go to ready state. So in this case we manually call vpn_newlink() to take the interface UP. If the newlink was called before our call, then our manual call will be ignored.
Diffstat (limited to 'vpn/plugins/vpn.c')
-rw-r--r--vpn/plugins/vpn.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/vpn/plugins/vpn.c b/vpn/plugins/vpn.c
index 2a0fdaf..3b0fd3a 100644
--- a/vpn/plugins/vpn.c
+++ b/vpn/plugins/vpn.c
@@ -216,7 +216,7 @@ static DBusMessage *vpn_notify(struct connman_task *task,
struct vpn_data *data;
struct vpn_driver_data *vpn_driver_data;
const char *name;
- int state, index;
+ int state, index, err;
data = vpn_provider_get_data(provider);
@@ -236,7 +236,22 @@ static DBusMessage *vpn_notify(struct connman_task *task,
vpn_provider_ref(provider);
data->watch = vpn_rtnl_add_newlink_watch(index,
vpn_newlink, provider);
- connman_inet_ifup(index);
+ err = connman_inet_ifup(index);
+ if (err < 0) {
+ 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.
+ */
+ vpn_newlink(IFF_UP, 0, provider);
+ else
+ DBG("Cannot take interface %d up err %d/%s",
+ index, -err, strerror(-err));
+ }
break;
case VPN_STATE_UNKNOWN: