aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortetsuya, kobayashi <tetsuya.x.kobayashi@sonymobile.com>2017-01-17 06:54:21 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-01-17 06:54:21 +0000
commitad8378003f950cdc3fe9fcde85ec9c31cff2e783 (patch)
treef26b2c734e7ed77415b2f94a41bb06639193a793
parent9ee934853e5afc8936c36bcd5993a8cc2c44f42d (diff)
parent8677892d4e67a8ed53b49d0bb4ab0bafa6413b0d (diff)
downloadipsec-tools-ad8378003f950cdc3fe9fcde85ec9c31cff2e783.tar.gz
Merge "VPN reconnection fails after manually disabling VPN" am: 34538ca099 am: db75984fe5 am: 7f8f84f958
am: 8677892d4e Change-Id: Ia6eddb3739299cdf1794ea87273ee568e37d387c
-rw-r--r--main.c3
-rw-r--r--setup.c9
2 files changed, 12 insertions, 0 deletions
diff --git a/main.c b/main.c
index c58bf57..01119f5 100644
--- a/main.c
+++ b/main.c
@@ -124,6 +124,7 @@ const char *android_hook(char **envp)
#endif
extern void setup(int argc, char **argv);
+extern void shutdown_session();
static int monitors;
static void (*callbacks[10])(int fd);
@@ -188,6 +189,8 @@ int main(int argc, char **argv)
for (i = 0; i < monitors; ++i) {
if (pollfds[i].revents & POLLHUP) {
do_plog(LLV_INFO, "Connection is closed\n", pollfds[i].fd);
+ shutdown_session();
+
/* Wait for few seconds to consume late messages. */
sleep(5);
exit(1);
diff --git a/setup.c b/setup.c
index 69b5b70..fce9bf4 100644
--- a/setup.c
+++ b/setup.c
@@ -53,6 +53,7 @@
#include "privsep.h"
#include "throttle.h"
#include "misc.h"
+#include "handler.h"
static struct localconf localconf;
static struct sainfo sainfo;
@@ -671,3 +672,11 @@ int throttle_host(struct sockaddr *addr, int fail)
{
return 0;
}
+
+void shutdown_session()
+{
+ flushph2();
+ flushph1();
+ isakmp_close();
+ pfkey_close(localconf.sock_pfkey);
+}