}
if (openconnect_setup_esp_keys(vpninfo, 0))
vpn_progress(vpninfo, PRG_ERR, "Failed to setup ESP keys.\n");
- else
+ else {
/* prevent race condition between esp_mainloop() and gpst_mainloop() timers */
vpninfo->dtls_times.last_rekey = time(&vpninfo->new_dtls_started);
+ vpninfo->delay_tunnel_reason = "awaiting GPST ESP connection";
+ }
}
#else
vpn_progress(vpninfo, PRG_DEBUG, _("Ignoring ESP keys since ESP support not available in this build\n"));
case DTLS_SECRET:
case DTLS_SLEEPING:
/* Allow 5 seconds after configuration for ESP to start */
- if (!ka_check_deadline(timeout, time(NULL), vpninfo->new_dtls_started + 5))
+ if (!ka_check_deadline(timeout, time(NULL), vpninfo->new_dtls_started + 5)) {
+ vpninfo->delay_tunnel_reason = "awaiting GPST ESP connection";
return 0;
+ }
/* ... before we switch to HTTPS instead */
vpn_progress(vpninfo, PRG_ERR,
timeout = 1000;
if (!tun_is_up(vpninfo)) {
- if (vpninfo->delay_tunnel > 0) {
- vpn_progress(vpninfo, PRG_DEBUG, _("Delaying tunnel by protocol request.\n"));
+ if (vpninfo->delay_tunnel_reason) {
+ vpn_progress(vpninfo, PRG_INFO, _("Delaying tunnel with reason: %s\n"),
+ vpninfo->delay_tunnel_reason);
/* XX: don't let this spin forever */
- if (--vpninfo->delay_tunnel > 0)
- did_work++;
- } else if (vpninfo->dtls_state == DTLS_CONNECTING) {
- /* Postpone tun device creation after DTLS is connected so
- * we have a better knowledge of the link MTU. We also
- * force the creation if DTLS enters sleeping mode - i.e.,
- * we failed to connect on time. */
- vpn_progress(vpninfo, PRG_DEBUG, _("Delaying tunnel until link MTU determined.\n"));
+ vpninfo->delay_tunnel_reason = NULL;
} else {
/* No DTLS, or DTLS failed; setup TUN device unconditionally */
ret = setup_tun_device(vpninfo);
poll_cmd_fd(vpninfo, 0);
if (vpninfo->got_cancel_cmd) {
if (vpninfo->delay_close > 0) {
- vpn_progress(vpninfo, PRG_DEBUG, _("Delaying cancel.\n"));
- /* XX: don't let this spin forever */
- if (--vpninfo->delay_close > 0)
+ if (vpninfo->delay_close > 1) {
+ vpn_progress(vpninfo, PRG_DEBUG, _("Delaying cancel (until we send again).\n"));
did_work++;
+ } else
+ vpn_progress(vpninfo, PRG_DEBUG, _("Delaying cancel (until we receive again).\n"));
+ /* XX: don't let this spin forever */
+ --vpninfo->delay_close;
} else if (vpninfo->cancel_type == OC_CMD_CANCEL) {
vpninfo->quit_reason = "Aborted by caller";
vpninfo->got_cancel_cmd = 0;
if (vpninfo->got_pause_cmd) {
if (vpninfo->delay_close > 0) {
- vpn_progress(vpninfo, PRG_DEBUG, _("Delaying pause.\n"));
/* XX: don't let this spin forever */
- if (--vpninfo->delay_close > 0)
+ if (vpninfo->delay_close > 1) {
+ vpn_progress(vpninfo, PRG_DEBUG, _("Delaying cancel (need to send again).\n"));
did_work++;
+ } else
+ vpn_progress(vpninfo, PRG_DEBUG, _("Delaying cancel (need to receive again).\n"));
+ /* XX: don't let this spin forever */
+ --vpninfo->delay_close;
} else {
/* close all connections and wait for the user to call
openconnect_mainloop() again */
return -ENOMEM;
/* Delay tunnel setup during PPP negotiation */
- vpninfo->delay_tunnel = 1;
+ vpninfo->delay_tunnel_reason = "PPP negotiation";
/* Nameservers to request from peer
* (see https://tools.ietf.org/html/rfc1877#section-1) */
}
/* Delay tunnel setup until after PPP negotiation */
- vpninfo->delay_tunnel = (ppp->ppp_state == PPPS_NETWORK ? 0 : 1);
+ vpninfo->delay_tunnel_reason = (ppp->ppp_state == PPPS_NETWORK ? NULL : "PPP negotiation");
if (last_state != ppp->ppp_state) {
vpn_progress(vpninfo, PRG_DEBUG,