From: "ralf_lici (Code Review)" Date: Fri, 25 Jul 2025 13:15:21 +0000 References: Reply-To: ralf@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <4365f7d00e085c8673f7f7f4e9ce98c669e7bac7-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="Rp3LM7nb1dQ="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: management: resync timer on bytecount interval change List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --Rp3LM7nb1dQ= 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/+/1113?usp=3Demail to review the following change. Change subject: management: resync timer on bytecount interval change ...................................................................... management: resync timer on bytecount interval change coarse_timer_wakeup tracks when the next timer-driven task will occur. When a user issues `bytecount n` on the management interface but the existing wakeup is more than n seconds ahead, bandwidth logging won=E2=80= =99t run until that original timer fires, delaying logs. Introduce a flag to detect when the bytecount interval changes and, when set, recalculate coarse_timer_wakeup so logging fires exactly n seconds after the command. This guarantees bytecount adheres to the user-specified interval. Change-Id: Ic0035d52e0ea123398318870d2f4d21af927a602 Signed-off-by: Ralf Lici --- M src/openvpn/forward.c M src/openvpn/manage.c M src/openvpn/manage.h 3 files changed, 15 insertions(+), 0 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/13/1113/1 diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index a4f260a..192fff4 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -838,6 +838,19 @@ static void check_coarse_timers(struct context *c) { +#ifdef ENABLE_MANAGEMENT + /* The 'bytecount' command starts a timer at runtime, but it would not= be + * processed if coarse_timer_wakeup was previously set to a higher val= ue. + * Therefore, if the command has arrived, we reset coarse_timer_wakeup= in + * to order to update it accordingly. + */ + if (management && management->connection.bytecount_interval_changed) + { + reset_coarse_timers(c); + management->connection.bytecount_interval_changed =3D false; + } +#endif /* ENABLE_MANAGEMENT */ + if (now < c->c2.coarse_timer_wakeup) { context_reschedule_sec(c, c->c2.coarse_timer_wakeup - now); diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index 8836e79..0df78ee 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -503,6 +503,7 @@ man->connection.bytecount_update_seconds =3D 0; event_timeout_clear(&man->connection.bytecount_update_interval); } + man->connection.bytecount_interval_changed =3D true; msg(M_CLIENT, "SUCCESS: bytecount interval changed"); } diff --git a/src/openvpn/manage.h b/src/openvpn/manage.h index eb19a4e..00e3931 100644 --- a/src/openvpn/manage.h +++ b/src/openvpn/manage.h @@ -318,6 +318,7 @@ bool state_realtime; bool log_realtime; bool echo_realtime; + bool bytecount_interval_changed; int bytecount_update_seconds; struct event_timeout bytecount_update_interval; -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1113?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ic0035d52e0ea123398318870d2f4d21af927a602 Gerrit-Change-Number: 1113 Gerrit-PatchSet: 1 Gerrit-Owner: ralf_lici Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --Rp3LM7nb1dQ= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos.

ralf_lici would like plaisthos and flichtenheld to review this change.

V= iew Change

management: resync timer on bytecount interval change
coarse_timer_wakeup tracks when the next timer-driven task will occur.
= When a user issues `bytecount n` on the management interface but the
exi= sting wakeup is more than n seconds ahead, bandwidth logging won=E2=80=99t<= br>run until that original timer fires, delaying logs.

Introduce a f= lag to detect when the bytecount interval changes and,
when set, recalcu= late coarse_timer_wakeup so logging fires exactly
n seconds after the co= mmand. This guarantees bytecount adheres to the
user-specified interval.=

Change-Id: Ic0035d52e0ea123398318870d2f4d21af927a602
Signed-off-= by: Ralf Lici <ralf@...2726...>
---
M src/openvpn/forward.c
= M src/openvpn/manage.c
M src/openvpn/manage.h
3 files changed, 15 ins= ertions(+), 0 deletions(-)

git pull ssh://gerrit.openvpn.net:2941=
8/openvpn refs/changes/13/1113/1
diff --git a/src/openvpn/forward.c=
 b/src/openvpn/forward.c
index a4f260a..192fff4 100644
--- a/src/openvpn/forward.c
+++ b/src/openvpn/f= orward.c
@@ -838,6 +838,19 @@
static void<= /span>
check_coarse_timers(struct context *c)
{<= /span>
+#ifdef ENABLE_MANAGE= MENT
+ /* The '= ;bytecount' command starts a timer at runtime, but it would not be
+ * processed if coar= se_timer_wakeup was previously set to a higher value.
+ * Therefore, if the command has arri= ved, we reset coarse_timer_wakeup in
+ * to order to update it accordingly.
+ */
+ if (management && management->con= nection.bytecount_interval_changed)
+ {
+ reset_coarse_timers(c);
+ management->connection.bytecount_interval_changed = =3D false;
+ }
+#endif /* ENABLE_MANAGE= MENT */
+
<= span> if (now < c->c2.coarse_timer_wakeup)

{=
context_reschedule_sec(c, c->c2.coarse_timer_w= akeup - now);
diff --git a/src/openvpn/manage.c b/src/openv= pn/manage.c
index 8836e79..0df78ee 100644
-= -- a/src/openvpn/manage.c
+++ b/src/openvpn/manage.c=
@@ -503,6 +503,7 @@
man->connection.b= ytecount_update_seconds =3D 0;
event_timeout_clear= (&man->connection.bytecount_update_interval);
}=
+ man->connect= ion.bytecount_interval_changed =3D true;
msg(M_CLIENT,= "SUCCESS: bytecount interval changed");
}

diff --git a/src/openvpn/manage.h b/src/openvp= n/manage.h
index eb19a4e..00e3931 100644
--= - a/src/openvpn/manage.h
+++ b/src/openvpn/manage.h<= br>@@ -318,6 +318,7 @@
bool state_realtime;
bool log_realtime;
bool echo_realtime= ;
+ bool bytecount= _interval_changed;
int bytecount_update_seconds;
struct event_timeout bytecount_update_interval;
<= span>


To view, visit change 1113. To unsub= scribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic0035d52e0ea123398318870d2f= 4d21af927a602
Gerrit-Change-Number: 1113
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...>
Gerrit-MessageType: newchange
--Rp3LM7nb1dQ=--