summaryrefslogtreecommitdiffstats
path: root/src/openvpn/init.c
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2014-03-21 14:18:36 +0100
committerGert Doering <gert@greenie.muc.de>2014-03-22 19:16:41 +0100
commitc058cbffc182b6618182a3ff8b13c66d01ce937d (patch)
tree5e877124d8c16ad33d461f6a35362fbb9f7e052e /src/openvpn/init.c
parentac1c2f259b44d1229a65a3e639b09d57a4e2a53b (diff)
downloadopenvpn-c058cbffc182b6618182a3ff8b13c66d01ce937d.tar.gz
openvpn-c058cbffc182b6618182a3ff8b13c66d01ce937d.tar.xz
openvpn-c058cbffc182b6618182a3ff8b13c66d01ce937d.zip
Workaround broken Android 4.4 VpnService API for persist-tun mode
In Android 4.4 it is not possible to open a new tun device and then close the old tun device without breaking the whole VPNService stack until the device is rebooted. Add new management method to ask the UI what method should be taken to ensure the optimal solution for the situation. Then do open-before-close or close-before-open inside open_tun() as requested. Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <1395407925-25518-4-git-send-email-arne@rfc2549.org> URL: http://article.gmane.org/gmane.network.openvpn.devel/8373 Signed-off-by: Gert Doering <gert@greenie.muc.de>
Diffstat (limited to 'src/openvpn/init.c')
-rw-r--r--src/openvpn/init.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/openvpn/init.c b/src/openvpn/init.c
index c50b5c2..21e3052 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/init.c
@@ -1426,10 +1426,10 @@ do_open_tun (struct context *c)
#ifdef TARGET_ANDROID
/* If we emulate persist-tun on android we still have to open a new tun and
- then close the old */
+ * then close the old */
int oldtunfd=-1;
if (c->c1.tuntap)
- oldtunfd = c->c1.tuntap->fd;
+ oldtunfd = c->c1.tuntap->fd;
#endif
/* initialize (but do not open) tun/tap object */
@@ -1463,14 +1463,14 @@ do_open_tun (struct context *c)
do_route (&c->options, c->c1.route_list, c->c1.route_ipv6_list,
c->c1.tuntap, c->plugins, c->c2.es);
}
-
+#ifdef TARGET_ANDROID
+ /* Store the old fd inside the fd so open_tun can use it */
+ c->c1.tuntap->fd = oldtunfd;
+#endif
/* open the tun device */
open_tun (c->options.dev, c->options.dev_type, c->options.dev_node,
c->c1.tuntap);
-#ifdef TARGET_ANDROID
- if (oldtunfd>=0)
- close(oldtunfd);
-#endif
+
/* set the hardware address */
if (c->options.lladdr)
set_lladdr(c->c1.tuntap->actual_name, c->options.lladdr, c->c2.es);
@@ -3767,7 +3767,10 @@ close_context (struct context *c, int sig, unsigned int flags)
{
if ((flags & CC_USR1_TO_HUP)
|| (c->sig->source == SIG_SOURCE_HARD && (flags & CC_HARD_USR1_TO_HUP)))
- c->sig->signal_received = SIGHUP;
+ {
+ c->sig->signal_received = SIGHUP;
+ c->sig->signal_text = "close_context usr1 to hup";
+ }
}
if (!(flags & CC_NO_CLOSE))