[Openvpn-devel,v1] management: stop bytecount on client disconnection

Message ID 20260302163557.18358-1-gert@greenie.muc.de
State New
Headers show
Series [Openvpn-devel,v1] management: stop bytecount on client disconnection | expand

Commit Message

Gert Doering March 2, 2026, 4:35 p.m. UTC
From: Ralf Lici <ralf@mandelbit.com>

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 <ralf@mandelbit.com>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1533
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to release/2.6.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1533
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Arne Schwabe <arne-openvpn@rfc2549.org>

Comments

Gert Doering March 5, 2026, 9:18 a.m. UTC | #1
This is a pretty direct backport of commit fccdb21733d2, which is easy
enough, and has been thoroughly tested in master (= I did not explicitly
test this again, beyond "buildbots are all green").  I assume that this
is a prerequisite patch for more DCO/bytecount fix backports to come :-)

Your patch has been applied to the release/2.6 branch.

commit ea8185ca76b5ba1b9247e1445f2805948ed09a34 (release/2.6)
Author: Ralf Lici
Date:   Mon Mar 2 17:35:51 2026 +0100

     management: stop bytecount on client disconnection

     Signed-off-by: Ralf Lici <ralf@mandelbit.com>
     Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
     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 <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c
index 4ed0393..48b87e9 100644
--- a/src/openvpn/manage.c
+++ b/src/openvpn/manage.c
@@ -472,6 +472,13 @@ 
 }
 
 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)
 {
     if (update_seconds > 0)
@@ -483,8 +490,7 @@ 
     }
     else
     {
-        man->connection.bytecount_update_seconds = 0;
-        event_timeout_clear(&man->connection.bytecount_update_interval);
+        man_bytecount_stop(man);
     }
 
     /* The newly received bytecount interval may be sooner than the existing
@@ -2011,6 +2017,7 @@ 
 {
     if (socket_defined(man->connection.sd_cli))
     {
+        man_bytecount_stop(man);
 #ifdef _WIN32
         man_stop_ne32(man);
 #endif