From: "cron2 (Code Review)" Date: Tue, 28 Oct 2025 18:53:25 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, ralf@...2726..., frank@...2641..., lstipakov@...277... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="Cda3CiR0Das="; charset=UTF-8 Subject: [Openvpn-devel] [M] Change in openvpn[master]: management: ensure consistent BYTECOUNT timing on server List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: ralf_lici , plaisthos , flichtenheld , stipa Cc: openvpn-devel --Cda3CiR0Das= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#3) to the change originally created by= ralf_lici. ( http://gerrit.openvpn.net/c/openvpn/+/1285?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by stipa 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 Acked-by: Lev Stipakov Message-Id: <20251021070825.20773-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg33= 812.html Signed-off-by: Gert Doering --- M src/openvpn/manage.c M src/openvpn/manage.h M src/openvpn/multi.c M src/openvpn/multi.h 4 files changed, 33 insertions(+), 18 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/85/1285/3 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 f60944d..11e4d8c 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -3797,13 +3797,6 @@ { check_stale_routes(m); } - -#ifdef ENABLE_MANAGEMENT - if (management) - { - management_check_bytecount_server(m); - } -#endif /* ENABLE_MANAGEMENT */ } static void @@ -4154,6 +4147,29 @@ ASSERT(mi->context.c2.tls_multi->peer_id < m->max_clients); } +/** + * @brief Determines the earliest wakeup interval based on periodic operat= ions. + * + * Updates the \c timeval to reflect the next scheduled wakeup time. + * Also sets \c multi->earliest_wakeup to the instance with the earliest w= akeup. + * + * @param multi Pointer to the multi context + * @param timeval Pointer to the timeval structure to be updated with the + * next wakeup time + */ +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 /* ENABLE_MANAGEMENT */ +} + /*************************************************************************= */ /** * Main event loop for OpenVPN in point-to-multipoint server mode. diff --git a/src/openvpn/multi.h b/src/openvpn/multi.h index 594ea3a..50f8d10 100644 --- a/src/openvpn/multi.h +++ b/src/openvpn/multi.h @@ -581,15 +581,16 @@ } /* - * Compute earliest timeout expiry from the set of - * all instances. Output: + * Updates \c dest with the earliest timeout as a delta relative to the cu= rrent + * time and sets \c m->earliest_wakeup to the \c multi_instance with the + * soonest scheduled wakeup. * - * m->earliest_wakeup : instance needing the earliest service. - * dest : earliest timeout as a delta in relation - * to current time. + * @param m Pointer to the multi context + * @param dest Pointer to a timeval struct that will hold the earliest ti= meout + * delta. */ 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; --=20 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: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ifb1c49fce75e671f699f5db5f6da7246f6e0b519 Gerrit-Change-Number: 1285 Gerrit-PatchSet: 3 Gerrit-Owner: ralf_lici Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-Reviewer: stipa Gerrit-CC: openvpn-devel --Cda3CiR0Das= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 upl= oaded patch set #3 to the change originally created by ralf_lici.<= /p>

Vi= ew Change

The following approvals got outdated and were removed: Code-Review+2 by stipa

management: ensure consistent BYTEC=
OUNT timing on server

The BYTECOUNT notification is expected to be e= mitted every N seconds
when a management client issues the 'bytecoun= t N' command. However, the
server currently relies on timeouts from = unrelated periodic operations,
resulting in irregular notification timin= g.

This issue is especially noticeable with low bytecount intervals = and DCO
enabled, as openvpn handles less traffic in userspace, causing t= he main
loop to run less frequently.

To address this, refactor th= e timeout logic and pass the timeval
reference to management_check_bytec= ount_server so that the timeout is
correctly set and notifications adher= e to the specified interval.

Change-Id: Ifb1c49fce75e671f699f5db5f6d= a7246f6e0b519
Signed-off-by: Ralf Lici <ralf@...2726...>
Acked-= by: Lev Stipakov <lstipakov@...277...>
Message-Id: <20251021070= 825.20773-1-gert@...1296...>
URL: https://www.mail-archive.com/openvp= n-devel@lists.sourceforge.net/msg33812.html
Signed-off-by: Gert Doering = <gert@...1296...>
---
M src/openvpn/manage.c
M src/openvpn/m= anage.h
M src/openvpn/multi.c
M src/openvpn/multi.h
4 files change= d, 33 insertions(+), 18 deletions(-)

git pull ss=
h://gerrit.openvpn.net:29418/openvpn refs/changes/85/1285/3
diff --=
git a/src/openvpn/manage.c b/src/openvpn/manage.c
index 1cb= 5c63..685b137 100644
--- a/src/openvpn/manage.c
<= span>+++ 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 tim= eval *timeval)
{
if (!(management->= ;persist.callback.flags & MCF_SERVER))
{ return;
}

= - struct timeval null;<= br>- CLEAR(null);
- if (event_timeout_trigger(&= ;management->connection.bytecount_update_interval, &null, ETT_DEFAUL= T))

+ if (event_ti= meout_trigger(&management->connection.bytecount_update_interval, tim= eval, ETT_DEFAULT))
{
/* fetc= h counters from dco */
if (dco_enabled(&multi-= >top.options))
diff --git a/src/openvpn/manage.h b/src/o= penvpn/manage.h
index a31eb06..fe460bf 100644
--- a/src/openvpn/manage.h
+++ b/src/openvpn/manage.h
@@ -493,7 +493,7 @@

void m= anagement_check_bytecount_client(struct context *c, struct management *man,= struct timeval *timeval);

-void management_check_bytecount_server(struct multi_= context *multi);
+voi= d management_check_bytecount_server(struct multi_context *multi, struct tim= eval *timeval);

void man_persist_client_= stats(struct management *man, struct context *c);
<= br>diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
<= span>index f60944d..11e4d8c 100644

--- a/src/openvpn/multi.= c
+++ b/src/openvpn/multi.c
@@ -3797,13 +37= 97,6 @@
{
check_stale_routes(= m);
}
-
-#ifdef ENABLE_MA= NAGEMENT
- if (manag= ement)
- {- management_check_byteco= unt_server(m);
- }
-#endif /* ENABLE_MANAGE= MENT */
}

static void
@@ -4154,6 +4147,29 @@
ASSERT(mi->co= ntext.c2.tls_multi->peer_id < m->max_clients);
}<= /span>

+/*= *
+ * @brief Determin= es the earliest wakeup interval based on periodic operations.
+ *

+ * Updates the \c timeval to reflect the next sche= duled wakeup time.
+ = * Also sets \c multi->earliest_wakeup to the instance with the earliest = wakeup.
+ *+ * @param multi Pointer t= o the multi context
+= * @param timeval Pointer to the timeval structure to be updated with the=
+ * = next wakeup time
+ *= /
+static void=
+multi_get_timeout(struct m= ulti_context *multi, struct timeval *timeval)
+{
+ multi_get_timeout_instance(multi, timeval);
+
+#ifdef ENABLE_MANAGEMENT
+ if (management)
+ {
+ management_check_bytecount_server(multi, timeval);+ }
+#endif /* ENABLE_MANAGEMENT */
= +}
+
/*****************************= *********************************************/
/**<= br> * Main event loop for OpenVPN in point-to-multipoint server mode= .
diff --git a/src/openvpn/multi.h b/src/openvpn/multi.h
index 594ea3a..50f8d10 100644
--- a/src/openv= pn/multi.h
+++ b/src/openvpn/multi.h
@@ -58= 1,15 +581,16 @@
}

/*
- * Compute earliest time= out expiry from the set of
- * all instances. Output:
+ * Updates \c dest with the earliest timeout as a delta relativ= e to the current
+ * = time and sets \c m->earliest_wakeup to the \c multi_instance with the
+ * soonest scheduled w= akeup.
*
- * m->earliest_wakeup : instance needing the earliest service.
- * dest : ea= rliest timeout as a delta in relation
- * to current time.
+ * @param m Pointer to the multi c= ontext
+ * @param des= t Pointer to a timeval struct that will hold the earliest timeout+ * delta.
*/
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 change 1285. To = unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ifb1c49fce75e671f699f5db5f6d= a7246f6e0b519
Gerrit-Change-Number: 1285
Gerrit-PatchSet: 3
Gerrit-Owner: ralf_lici <ralf@...2726...>= ;
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-Reviewer: stipa <lstipakov@...277...= >
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --Cda3CiR0Das=--