[PATCH] Fix connection stats rekey times

Daniel Lenski dlenski at gmail.com
Tue Feb 27 09:04:09 PST 2024


On Mon, Feb 26, 2024 at 6:50 PM Cline, Wade <wade.cline at intel.com> wrote:
>
> ---
>  main.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/main.c b/main.c
> index 65be6a2f..ef426dd6 100644
> --- a/main.c
> +++ b/main.c
> @@ -1565,14 +1565,14 @@ static void print_connection_stats(void *_vpninfo, const struct oc_stats *stats)
>                      vpninfo->proto->udp_protocol ? : "UDP", openconnect_get_dtls_cipher(vpninfo));
>         if (vpninfo->ssl_times.last_rekey && vpninfo->ssl_times.rekey)
>                 vpn_progress(vpninfo, PRG_INFO, _("Next SSL rekey in %ld seconds\n"),
> -                            (long)(time(NULL) - vpninfo->ssl_times.last_rekey + vpninfo->ssl_times.rekey));
> +                            (long)(vpninfo->ssl_times.last_rekey + vpninfo->ssl_times.rekey - time(NULL)));
>         if (vpninfo->dtls_times.last_rekey && vpninfo->dtls_times.rekey)
>                 vpn_progress(vpninfo, PRG_INFO, _("Next %s rekey in %ld seconds\n"),
>                              vpninfo->proto->udp_protocol ? : "UDP",
> -                            (long)(time(NULL) - vpninfo->ssl_times.last_rekey + vpninfo->ssl_times.rekey));
> +                            (long)(vpninfo->ssl_times.last_rekey + vpninfo->ssl_times.rekey - time(NULL)));
>         if (vpninfo->trojan_interval && vpninfo->last_trojan)
>                 vpn_progress(vpninfo, PRG_INFO, _("Next Trojan invocation in %ld seconds\n"),
> -                            (long)(time(NULL) - vpninfo->last_trojan + vpninfo->trojan_interval));
> +                            (long)(vpninfo->last_trojan + vpninfo->trojan_interval - time(NULL)));
>
>         /* XX: restore loglevel */
>         openconnect_set_loglevel(vpninfo, saved_loglevel);

Thank you, good catch here. These have been calculated incorrectly
ever since I added the SIGUSR1 handler to log connection stats in
https://gitlab.com/openconnect/openconnect/-/commit/b156b581e894b03e7169827b9e293ca2f13e1366.

And thanks Dimitri for creating
https://gitlab.com/openconnect/openconnect/-/merge_requests/539 for
this.

Daniel



More information about the openconnect-devel mailing list