Hi,

On Wed, Mar 22, 2023 at 7:34 AM Lev Stipakov <lstipa...@gmail.com> wrote:

> From: Lev Stipakov <l...@openvpn.net>
>
> Change-Id: I465febdf7ee5fe573e88255844f718efb60f8e8a
> Signed-off-by: Lev Stipakov <l...@openvpn.net>
> ---
>  src/openvpn/sig.c | 13 +++++++++----
>  src/openvpn/sig.h |  2 +-
>  2 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/src/openvpn/sig.c b/src/openvpn/sig.c
> index 5b89bb42..05c0054b 100644
> --- a/src/openvpn/sig.c
> +++ b/src/openvpn/sig.c
> @@ -300,18 +300,23 @@ restore_signal_state(void)
>   * Triggered by SIGUSR2 or F2 on Windows.
>   */
>  void
> -print_status(const struct context *c, struct status_output *so)
> +print_status(struct context *c, struct status_output *so)

 {
>      struct gc_arena gc = gc_new();
>
>      status_reset(so);
>
> +    if (dco_enabled(&c->options))
> +    {
> +        dco_get_peer_stats(c);
> +    }
> +
>

While this is expedient, adding dco dependence to parts of code which
should be independent of such inner details look wrong style to me. Finding
a way to keep struct context a const here will lead to a better logic, I
think.

Can't we have a coarse timer that keeps the stats updated? It doesn't have
to be frequent as this is just for information.


>      status_printf(so, "OpenVPN STATISTICS");
>      status_printf(so, "Updated,%s", time_string(0, 0, false, &gc));
>      status_printf(so, "TUN/TAP read bytes," counter_format,
> c->c2.tun_read_bytes);
>      status_printf(so, "TUN/TAP write bytes," counter_format,
> c->c2.tun_write_bytes);
> -    status_printf(so, "TCP/UDP read bytes," counter_format,
> c->c2.link_read_bytes);
> -    status_printf(so, "TCP/UDP write bytes," counter_format,
> c->c2.link_write_bytes);
> +    status_printf(so, "TCP/UDP read bytes," counter_format,
> c->c2.link_read_bytes + c->c2.dco_read_bytes);
> +    status_printf(so, "TCP/UDP write bytes," counter_format,
> c->c2.link_write_bytes + c->c2.dco_write_bytes);
>

Same here --  have a place to read the total count from independent of dco.

Selva
_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to