From: "ralf_lici (Code Review)" Date: Mon, 20 Oct 2025 06:37:19 +0000 References: Reply-To: ralf@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <03a50675a7ca1ff5effcce36d151b74ebcba78d8-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="6Ufykqg4IAI="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: management: ensure consistent BYTECOUNT timing on server List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --6Ufykqg4IAI= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1285?usp=3Demail to review the following change. Change subject: management: ensure consistent BYTECOUNT timing on server ...................................................................... management: ensure consistent BYTECOUNT timing on server The BYTECOUNT notification is expected to be emitted every N seconds when a management client issues the 'bytecount N' command. However, the server currently relies on timeouts from unrelated periodic operations, resulting in irregular notification timing. This issue is especially noticeable with low bytecount intervals and DCO enabled, as openvpn handles less traffic in userspace, causing the main loop to run less frequently. To address this, refactor the timeout logic and pass the timeval reference to management_check_bytecount_server so that the timeout is correctly set and notifications adhere to the specified interval. Change-Id: Ifb1c49fce75e671f699f5db5f6da7246f6e0b519 Signed-off-by: Ralf Lici --- M src/openvpn/manage.c M src/openvpn/manage.h M src/openvpn/multi.c M src/openvpn/multi.h 4 files changed, 17 insertions(+), 13 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/85/1285/1 diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index 1cb5c63..685b137 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -4184,16 +4184,14 @@ } void -management_check_bytecount_server(struct multi_context *multi) +management_check_bytecount_server(struct multi_context *multi, struct time= val *timeval) { if (!(management->persist.callback.flags & MCF_SERVER)) { return; } - struct timeval null; - CLEAR(null); - if (event_timeout_trigger(&management->connection.bytecount_update_int= erval, &null, ETT_DEFAULT)) + if (event_timeout_trigger(&management->connection.bytecount_update_int= erval, timeval, ETT_DEFAULT)) { /* fetch counters from dco */ if (dco_enabled(&multi->top.options)) diff --git a/src/openvpn/manage.h b/src/openvpn/manage.h index a31eb06..fe460bf 100644 --- a/src/openvpn/manage.h +++ b/src/openvpn/manage.h @@ -493,7 +493,7 @@ void management_check_bytecount_client(struct context *c, struct managemen= t *man, struct timeval *timeval); -void management_check_bytecount_server(struct multi_context *multi); +void management_check_bytecount_server(struct multi_context *multi, struct= timeval *timeval); void man_persist_client_stats(struct management *man, struct context *c); diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index e907524..f9ef781 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -3809,13 +3809,6 @@ { check_stale_routes(m); } - -#ifdef ENABLE_MANAGEMENT - if (management) - { - management_check_bytecount_server(m); - } -#endif /* ENABLE_MANAGEMENT */ } static void @@ -4166,6 +4159,19 @@ ASSERT(mi->context.c2.tls_multi->peer_id < m->max_clients); } +static void +multi_get_timeout(struct multi_context *multi, struct timeval *timeval) +{ + multi_get_timeout_instance(multi, timeval); + +#ifdef ENABLE_MANAGEMENT + if (management) + { + management_check_bytecount_server(multi, timeval); + } +#endif +} + /*************************************************************************= */ /** * Main event loop for OpenVPN in point-to-multipoint server mode. diff --git a/src/openvpn/multi.h b/src/openvpn/multi.h index 97bbc4a..8e3b9ca 100644 --- a/src/openvpn/multi.h +++ b/src/openvpn/multi.h @@ -590,7 +590,7 @@ * to current time. */ static inline void -multi_get_timeout(struct multi_context *m, struct timeval *dest) +multi_get_timeout_instance(struct multi_context *m, struct timeval *dest) { struct timeval tv, current; -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1285?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ifb1c49fce75e671f699f5db5f6da7246f6e0b519 Gerrit-Change-Number: 1285 Gerrit-PatchSet: 1 Gerrit-Owner: ralf_lici Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld --6Ufykqg4IAI= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: flichtenheld, plaisthos.

ralf_lici would like plaisthos and flichtenheld to review this change.

V= iew Change

management: ensure consistent BYTECOUNT tim=
ing on server

The BYTECOUNT notification is expected to be emitted e= very N seconds
when a management client issues the 'bytecount N'= command. However, the
server currently relies on timeouts from unrelate= d periodic operations,
resulting in irregular notification timing.
This issue is especially noticeable with low bytecount intervals and DCO<= br>enabled, as openvpn handles less traffic in userspace, causing the main<= br>loop to run less frequently.

To address this, refactor the timeou= t logic and pass the timeval
reference to management_check_bytecount_ser= ver so that the timeout is
correctly set and notifications adhere to the= specified interval.

Change-Id: Ifb1c49fce75e671f699f5db5f6da7246f6e= 0b519
Signed-off-by: Ralf Lici <ralf@...2726...>
---
M src/o= penvpn/manage.c
M src/openvpn/manage.h
M src/openvpn/multi.c
M src= /openvpn/multi.h
4 files changed, 17 insertions(+), 13 deletions(-)
<= br>
git pull ssh://gerrit.openvpn.net:29418/openvpn refs=
/changes/85/1285/1
diff --git a/src/openvpn/manage.c b/src/openvpn/=
manage.c
index 1cb5c63..685b137 100644
--- = a/src/openvpn/manage.c
+++ b/src/openvpn/manage.c@@ -4184,16 +4184,14 @@
}
<= br> void
-managem= ent_check_bytecount_server(struct multi_context *multi)
+management_check_bytecount_server(struc= t multi_context *multi, struct timeval *timeval)
{<= br> if (!(management->persist.callback.flags & MCF_SERVER)= )
{
return;
= }

- struct timeval null;
- CLEAR(null);
-= if (event_timeout_trigger(&management->connection.bytecount_upda= te_interval, &null, ETT_DEFAULT))
+ if (event_timeout_trigger(&management->connect= ion.bytecount_update_interval, timeval, ETT_DEFAULT))
= {
/* fetch counters from dco */
= if (dco_enabled(&multi->top.options))
diff --= git a/src/openvpn/manage.h b/src/openvpn/manage.h
index a31= eb06..fe460bf 100644
--- a/src/openvpn/manage.h
<= span>+++ b/src/openvpn/manage.h
@@ -493,7 +493,7 @@<= br>
void management_check_bytecount_client(struct c= ontext *c, struct management *man, struct timeval *timeval);

-void management_ch= eck_bytecount_server(struct multi_context *multi);
+void management_check_bytecount_server(struc= t multi_context *multi, struct timeval *timeval);
<= br> void man_persist_client_stats(struct management *man, struct cont= ext *c);

diff --git a/src/openvpn/multi.c= b/src/openvpn/multi.c
index e907524..f9ef781 100644=
--- a/src/openvpn/multi.c
+++ b/src/openvpn/multi= .c
@@ -3809,13 +3809,6 @@
{
= check_stale_routes(m);
}
-
-#ifdef ENABLE_MANAGEMENT
- if (management)
- {
- }
-#endif /* ENABLE_MANAGEMENT */
}

static void
@@ -4166,6 +4159,19 @@
ASSERT(mi->context.c2.tls_multi->peer_id < m->= ;max_clients);
}

+static void
+multi_get_timeout(struct multi_context *multi, st= ruct timeval *timeval)
+ multi_get_t= imeout_instance(multi, timeval);
+
+#ifdef= ENABLE_MANAGEMENT
+ = if (management)
+ = {
+ managem= ent_check_bytecount_server(multi, timeval);
+ }
+#endif
+}
+
/**= ************************************************************************/
/**
* Main event loop for OpenVPN in poin= t-to-multipoint server mode.
diff --git a/src/openvpn/multi= .h b/src/openvpn/multi.h
index 97bbc4a..8e3b9ca 100644

--- a/src/openvpn/multi.h
+++ b/src/openvpn/mul= ti.h
@@ -590,7 +590,7 @@
* = to current time.
*/
static inline= void
-multi_get_timeou= t(struct multi_context *m, struct timeval *dest)
+multi_get_timeout_instance(struct multi_contex= t *m, struct timeval *dest)
{
struct = timeval tv, current;


= To view, visit change 1285. To unsubscribe, or for help writing mail filters, v= isit settings.

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ifb1c49fce75e671f699f5db5f6d= a7246f6e0b519
Gerrit-Change-Number: 1285
Gerrit-PatchSet: 1
Gerrit-Owner: ralf_lici <ralf@...2726...>= ;
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
= --6Ufykqg4IAI=--