]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Fast recovery when host is in unreachable network
authorLev Stipakov <lstipakov@gmail.com>
Mon, 2 Mar 2015 17:58:31 +0000 (19:58 +0200)
committerGert Doering <gert@greenie.muc.de>
Sat, 10 Oct 2015 08:21:59 +0000 (10:21 +0200)
When client connects to the server which is in unreachable network (for
example hostname got resolved into ipv6 address and client has no ipv6),
throw SIGUSR1 and connect to the next server without waiting 60 seconds
for "TLS key negotiation failed".
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1425319111-21291-1-git-send-email-lstipakov@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9498

Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/forward.c

index 7a5d383853694db8db90e4d9faf0897c665ae0fb..513fbae9bc5d7e869ede121a907de671012e6399 100644 (file)
@@ -1093,6 +1093,7 @@ void
 process_outgoing_link (struct context *c)
 {
   struct gc_arena gc = gc_new ();
+  int error_code = 0;
 
   perf_push (PERF_PROC_OUT_LINK);
 
@@ -1180,6 +1181,7 @@ process_outgoing_link (struct context *c)
        }
 
       /* Check return status */
+      error_code = openvpn_errno();
       check_status (size, "write", c->c2.link_socket, NULL);
 
       if (size > 0)
@@ -1196,6 +1198,14 @@ process_outgoing_link (struct context *c)
       /* if not a ping/control message, indicate activity regarding --inactive parameter */
       if (c->c2.buf.len > 0 )
         register_activity (c, size);
+
+      /* for unreachable network and "connecting" state switch to the next host */
+      if (size < 0 && ENETUNREACH == error_code && !tls_initial_packet_received (c->c2.tls_multi)
+         && c->options.mode == MODE_POINT_TO_POINT)
+       {
+         msg (M_INFO, "Network unreachable, restarting");
+         register_signal (c, SIGUSR1, "network-unreachable");
+       }
     }
   else
     {