Browse code

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: I1474d232278433d097baf85352dfc9a79853bad1
Signed-off-by: Ralf Lici <ralf@mandelbit.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250902163514.22339-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg32765.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Ralf Lici authored on 2025/09/03 01:35:09
Showing 1 changed files
... ...
@@ -501,6 +501,13 @@ man_status(struct management *man, const int version, struct status_output *so)
501 501
 }
502 502
 
503 503
 static void
504
+man_bytecount_stop(struct management *man)
505
+{
506
+    man->connection.bytecount_update_seconds = 0;
507
+    event_timeout_clear(&man->connection.bytecount_update_interval);
508
+}
509
+
510
+static void
504 511
 man_bytecount(struct management *man, const int update_seconds)
505 512
 {
506 513
     if (update_seconds > 0)
... ...
@@ -511,8 +518,7 @@ man_bytecount(struct management *man, const int update_seconds)
511 511
     }
512 512
     else
513 513
     {
514
-        man->connection.bytecount_update_seconds = 0;
515
-        event_timeout_clear(&man->connection.bytecount_update_interval);
514
+        man_bytecount_stop(man);
516 515
     }
517 516
 
518 517
     /* The newly received bytecount interval may be sooner than the existing
... ...
@@ -1992,6 +1998,7 @@ man_reset_client_socket(struct management *man, const bool exiting)
1992 1992
 {
1993 1993
     if (socket_defined(man->connection.sd_cli))
1994 1994
     {
1995
+        man_bytecount_stop(man);
1995 1996
 #ifdef _WIN32
1996 1997
         man_stop_ne32(man);
1997 1998
 #endif