From ea8185ca76b5ba1b9247e1445f2805948ed09a34 Mon Sep 17 00:00:00 2001 From: Ralf Lici Date: Mon, 2 Mar 2026 17:35:51 +0100 Subject: [PATCH] management: stop bytecount on client disconnection When a management interface client requests periodic bytecount notifications, openvpn continues to emit them even after the client has disconnected. Additionally, upon reconnecting, the client starts receiving these notifications without having issued a new bytecount command. Stop the periodic bytecount operation when the management interface client disconnects, preventing unnecessary stats polling when using DCO and ensuring that clients only receive notifications they have explicitly requested. Change-Id: I6bdded6c70596b69428e6a00a405ac3cedc405fa Signed-off-by: Ralf Lici Acked-by: Arne Schwabe Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1533 Message-Id: <20260302163557.18358-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg35825.html Signed-off-by: Gert Doering (cherry-picked from fccdb21733d2826bcdc080fdfa93b0283b5231b8) --- src/openvpn/manage.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index 0e4afa2f..3a2e84e4 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -470,6 +470,13 @@ man_status(struct management *man, const int version, struct status_output *so) } } +static void +man_bytecount_stop(struct management *man) +{ + man->connection.bytecount_update_seconds = 0; + event_timeout_clear(&man->connection.bytecount_update_interval); +} + static void man_bytecount(struct management *man, const int update_seconds) { @@ -482,8 +489,7 @@ man_bytecount(struct management *man, const int update_seconds) } else { - man->connection.bytecount_update_seconds = 0; - event_timeout_clear(&man->connection.bytecount_update_interval); + man_bytecount_stop(man); } msg(M_CLIENT, "SUCCESS: bytecount interval changed"); } @@ -1992,6 +1998,7 @@ man_reset_client_socket(struct management *man, const bool exiting) { if (socket_defined(man->connection.sd_cli)) { + man_bytecount_stop(man); #ifdef _WIN32 man_stop_ne32(man); #endif