summaryrefslogtreecommitdiffstats
path: root/src/openvpn
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2015-09-15 11:23:37 +0200
committerGert Doering <gert@greenie.muc.de>2015-09-15 13:19:48 +0200
commitd967ec289df5c5196f68a3708a9f36a5ba354833 (patch)
tree72fa38b6ea6a227847302ccef505f8fe2d5a30c0 /src/openvpn
parentacd487d0f3597e67f451aa23b73ad03dc19842b0 (diff)
downloadopenvpn-d967ec289df5c5196f68a3708a9f36a5ba354833.tar.gz
openvpn-d967ec289df5c5196f68a3708a9f36a5ba354833.tar.xz
openvpn-d967ec289df5c5196f68a3708a9f36a5ba354833.zip
Extend network-change command to allow reprotecting on the same network (for short connection losses)
Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <1442309019-7586-7-git-send-email-arne@rfc2549.org> URL: http://article.gmane.org/gmane.network.openvpn.devel/10106 Signed-off-by: Gert Doering <gert@greenie.muc.de>
Diffstat (limited to 'src/openvpn')
-rw-r--r--src/openvpn/init.c6
-rw-r--r--src/openvpn/manage.c11
-rw-r--r--src/openvpn/manage.h2
3 files changed, 12 insertions, 7 deletions
diff --git a/src/openvpn/init.c b/src/openvpn/init.c
index b6cfece..48542c9 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/init.c
@@ -3162,14 +3162,14 @@ management_show_net_callback (void *arg, const int msglevel)
#ifdef TARGET_ANDROID
int
-management_callback_network_change (void *arg)
+management_callback_network_change (void *arg, bool samenetwork)
{
/* Check if the client should translate the network change to a SIGUSR1 to
reestablish the connection or just reprotect the socket
At the moment just assume that, for all settings that use pull (not
--static) and are not using peer-id reestablishing the connection is
- required
+ required (unless the network is the same)
The function returns -1 on invalid fd and -2 if the socket cannot be
reused. On the -2 return value the man_network_change function triggers
@@ -3184,7 +3184,7 @@ management_callback_network_change (void *arg)
return -1;
socketfd = c->c2.link_socket->sd;
- if (!c->options.pull || c->c2.tls_multi->use_peer_id)
+ if (!c->options.pull || c->c2.tls_multi->use_peer_id || samenetwork)
return socketfd;
else
return -2;
diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c
index af4aa44..d02dac9 100644
--- a/src/openvpn/manage.c
+++ b/src/openvpn/manage.c
@@ -1129,7 +1129,7 @@ man_remote (struct management *man, const char **p)
#ifdef TARGET_ANDROID
static void
-man_network_change (struct management *man)
+man_network_change (struct management *man, bool samenetwork)
{
/* Called to signal the OpenVPN that the network configuration has changed and
the client should either float or reconnect.
@@ -1138,7 +1138,8 @@ man_network_change (struct management *man)
*/
if (man->persist.callback.network_change)
{
- int fd = (*man->persist.callback.network_change)(man->persist.callback.arg);
+ int fd = (*man->persist.callback.network_change)
+ (man->persist.callback.arg, samenetwork);
man->connection.fdtosend = fd;
msg (M_CLIENT, "PROTECTFD: fd '%d' sent to be protected", fd);
if (fd == -2)
@@ -1193,7 +1194,11 @@ man_dispatch_command (struct management *man, struct status_output *so, const ch
#ifdef TARGET_ANDROID
else if (streq (p[0], "network-change"))
{
- man_network_change(man);
+ bool samenetwork = false;
+ if (p[1] && streq(p[1], "samenetwork"))
+ samenetwork = true;
+
+ man_network_change(man, samenetwork);
}
#endif
else if (streq (p[0], "load-stats"))
diff --git a/src/openvpn/manage.h b/src/openvpn/manage.h
index 7318377..a97e8a2 100644
--- a/src/openvpn/manage.h
+++ b/src/openvpn/manage.h
@@ -174,7 +174,7 @@ struct management_callback
bool (*proxy_cmd) (void *arg, const char **p);
bool (*remote_cmd) (void *arg, const char **p);
#ifdef TARGET_ANDROID
- int (*network_change) (void *arg);
+ int (*network_change) (void *arg, bool samenetwork);
#endif
};