]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Don't call connection script in ssl_reconnect if tunnel is not up
authorDaniel Lenski <dlenski@gmail.com>
Tue, 13 Apr 2021 16:49:44 +0000 (09:49 -0700)
committerDavid Woodhouse <dwmw2@infradead.org>
Fri, 16 Apr 2021 15:06:36 +0000 (16:06 +0100)
This refines the DTLS-to-TLS fallback in ppp_tcp_mainloop.

Calling the connection script (with the attempt-reconnect and reconnect
reasons) is confusing if this is actually the *initial* connection, and
the tunnel isn't up yet.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
ssl.c

diff --git a/ssl.c b/ssl.c
index dc81887f023ebdf91348d8e3c580731525ea87d2..97f20630f6e5945178508132561bef93978ac260 100644 (file)
--- a/ssl.c
+++ b/ssl.c
@@ -1110,6 +1110,7 @@ int ssl_reconnect(struct openconnect_info *vpninfo)
        int ret;
        int timeout;
        int interval;
+       int tun_up = tun_is_up(vpninfo);
 
        openconnect_close_https(vpninfo, 0);
 
@@ -1123,7 +1124,8 @@ int ssl_reconnect(struct openconnect_info *vpninfo)
        vpninfo->tun_pkt = NULL;
 
        while (1) {
-               script_config_tun(vpninfo, "attempt-reconnect");
+               if (tun_up)
+                       script_config_tun(vpninfo, "attempt-reconnect");
                ret = vpninfo->proto->tcp_connect(vpninfo);
                if (!ret)
                        break;
@@ -1149,9 +1151,11 @@ int ssl_reconnect(struct openconnect_info *vpninfo)
                        interval = RECONNECT_INTERVAL_MAX;
        }
 
-       script_config_tun(vpninfo, "reconnect");
-       if (vpninfo->reconnected)
-               vpninfo->reconnected(vpninfo->cbdata);
+       if (tun_up) {
+               script_config_tun(vpninfo, "reconnect");
+               if (vpninfo->reconnected)
+                       vpninfo->reconnected(vpninfo->cbdata);
+       }
 
        return 0;
 }