From: "stipa (Code Review)" Date: Wed, 27 Aug 2025 11:50:25 +0000 References: Reply-To: lstipakov@...277..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="dAxXhy6aXn8="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Don't call bytecount client logic in server mode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --dAxXhy6aXn8= 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/+/1157?usp=3Demail to review the following change. Change subject: Don't call bytecount client logic in server mode ...................................................................... Don't call bytecount client logic in server mode Calling this in server mode is wrong because: - we only output those counters via management interface (>BYTECOUT:) in client mode, so in server mode this is no-op - the timer callback to fetch DCO stats is triggerer independenty for each peer. It is a waste of resources in server mode where we could fetch stats for all peers with the single ioctl. Change-Id: I7bc7de284fdbfd4be26a907ecd5c21c075bc5ac4 Signed-off-by: Lev Stipakov --- M src/openvpn/forward.c M src/openvpn/manage.c M src/openvpn/manage.h 3 files changed, 5 insertions(+), 8 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/57/1157/1 diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 75ca9d5..e8bdf35 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -818,7 +818,7 @@ #ifdef ENABLE_MANAGEMENT if (management) { - management_check_bytecount(c, management, &c->c2.timeval); + management_check_bytecount_client(c, management, &c->c2.timeval); } #endif /* ENABLE_MANAGEMENT */ } diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index aed04f5..f057fb2 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -4065,9 +4065,9 @@ } void -management_check_bytecount(struct context *c, struct management *man, stru= ct timeval *timeval) +management_check_bytecount_client(struct context *c, struct management *ma= n, struct timeval *timeval) { - if (event_timeout_trigger(&man->connection.bytecount_update_interval, = timeval, ETT_DEFAULT)) + if (!(man->persist.callback.flags & MCF_SERVER) && event_timeout_trigg= er(&man->connection.bytecount_update_interval, timeval, ETT_DEFAULT)) { counter_type dco_read_bytes =3D 0; counter_type dco_write_bytes =3D 0; @@ -4083,10 +4083,7 @@ dco_write_bytes =3D c->c2.dco_write_bytes; } - if (!(man->persist.callback.flags & MCF_SERVER)) - { - man_bytecount_output_client(man, dco_read_bytes, dco_write_byt= es); - } + man_bytecount_output_client(man, dco_read_bytes, dco_write_bytes); } } diff --git a/src/openvpn/manage.h b/src/openvpn/manage.h index 083caf5..038691f 100644 --- a/src/openvpn/manage.h +++ b/src/openvpn/manage.h @@ -492,7 +492,7 @@ * These functions drive the bytecount in/out counters. */ -void management_check_bytecount(struct context *c, struct management *man,= struct timeval *timeval); +void management_check_bytecount_client(struct context *c, struct managemen= t *man, struct timeval *timeval); static inline void management_bytes_client(struct management *man, const int size_in, const i= nt size_out) -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1157?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: I7bc7de284fdbfd4be26a907ecd5c21c075bc5ac4 Gerrit-Change-Number: 1157 Gerrit-PatchSet: 1 Gerrit-Owner: stipa Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --dAxXhy6aXn8= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos.

stipa would like plaisthos and flichtenheld to review t= his change.

V= iew Change

Don't call bytecount client logic in server mode

= Calling this in server mode is wrong because:

- we only output thos= e counters via management interface
(>BYTECOUT:) in client mode, so = in server mode this is no-op

- the timer callback to fetch DCO stat= s is triggerer
independenty for each peer. It is a waste of resources i= n server mode
where we could fetch stats for all peers with the single = ioctl.

Change-Id: I7bc7de284fdbfd4be26a907ecd5c21c075bc5ac4
Signe= d-off-by: Lev Stipakov <lev@...515...>
---
M src/openvpn/forwar= d.c
M src/openvpn/manage.c
M src/openvpn/manage.h
3 files changed,= 5 insertions(+), 8 deletions(-)

git pull ssh://gerrit.openvpn.ne=
t:29418/openvpn refs/changes/57/1157/1
diff --git a/src/openvpn/for=
ward.c b/src/openvpn/forward.c
index 75ca9d5..e8bdf35 10064= 4
--- a/src/openvpn/forward.c
+++ b/src/ope= nvpn/forward.c
@@ -818,7 +818,7 @@
#ifdef = ENABLE_MANAGEMENT
if (management)
= {
- management_= check_bytecount(c, management, &c->c2.timeval);
+ management_check_bytecount_clien= t(c, management, &c->c2.timeval);
}
<= span> #endif /* ENABLE_MANAGEMENT */
}
dif= f --git a/src/openvpn/manage.c b/src/openvpn/manage.c
index= aed04f5..f057fb2 100644
--- a/src/openvpn/manage.c<= br>+++ b/src/openvpn/manage.c
@@ -4065,9 +4065,9 @@
}

void
-management_check_bytecount(struct conte= xt *c, struct management *man, struct timeval *timeval)
+management_check_bytecount_client(struc= t context *c, struct management *man, struct timeval *timeval)
{

- if (event_t= imeout_trigger(&man->connection.bytecount_update_interval, timeval, = ETT_DEFAULT))
+ if= (!(man->persist.callback.flags & MCF_SERVER) && event_timeo= ut_trigger(&man->connection.bytecount_update_interval, timeval, ETT_= DEFAULT))
{
counter_type dco_= read_bytes =3D 0;
counter_type dco_write_bytes =3D= 0;
@@ -4083,10 +4083,7 @@
dco= _write_bytes =3D c->c2.dco_write_bytes;
}

- i= f (!(man->persist.callback.flags & MCF_SERVER))
- {
- man_bytecount_output_client(man, dco_read_= bytes, dco_write_bytes);
+ = man_bytecount_output_client(man, dco_read_bytes, dco_write_bytes);<= br> }
}

diff -= -git a/src/openvpn/manage.h b/src/openvpn/manage.h
index 08= 3caf5..038691f 100644
--- a/src/openvpn/manage.h
= +++ b/src/openvpn/manage.h
@@ -492,7 +492,7 @@=
* These functions drive the bytecount in/out counters. */

-void management_check_bytecount(struct context *c, struct manageme= nt *man, struct timeval *timeval);
+void management_check_bytecount_client(struct context *c, st= ruct management *man, struct timeval *timeval);
static inline void
management_bytes_client(struct = management *man, const int size_in, const int size_out)

To view, visit change 1157. To unsubscribe, or for help writin= g mail filters, visit settin= gs.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7bc7de284fdbfd4be26a907ecd5= c21c075bc5ac4
Gerrit-Change-Number: 1157
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <lstipakov@...277...>= ;
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
--dAxXhy6aXn8=--