Change in openvpn[master]: Refactor management bytecount tracking
A message that is not in the archive (sent off-list or not yet received): gerrit.1756460812000.I43a93f0d84f01fd808a64115e1b8c3b806706491@...2715...
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/+/1162?usp=email
to review the following change.
Change subject: Refactor management bytecount tracking
......................................................................
Refactor management bytecount tracking
There are few issues with it:
- when using DCO, the server part doesn't output BYTECOUNT_CLI since process_incoming_link_part1/process_outgoing_link are not called
- when using DCO, the server part applies bytecount timer to the each connection, unneccessary making too many calls to the kernel and also uses incorect BYTECOUNT output.
- client part outputs counters using timer, server part utilizes traffic activity -> inconsistency
Following changes have been made:
- Use timer to output counters in client and server mode. Code which deals with bytecount on traffic activity has been removed. This unifies DCO and non-DCO, as well as client and server mode
- In server mode, peers stats are fetched with the single ioctl call
- Per-packet stats are not persisted anymore in the client mode during traffic activity. Instead cumulative stats (including DCO stats) are persisted when the session closes.
GitHub: https://github.com/OpenVPN/openvpn/issues/820
---
M src/openvpn/forward.c
M src/openvpn/manage.c
M src/openvpn/manage.h
M src/openvpn/multi.c
4 files changed, 62 insertions(+), 71 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/62/1162/1
src/openvpn/forward.c +1 -17
@@ -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 */ }
@@ -998,14 +998,6 @@ }#endif c->c2.original_recv_size = c->c2.buf.len; -#ifdef ENABLE_MANAGEMENT -if (management) - { -management_bytes_client (management, c->c2.buf.len,0 ); -management_bytes_server (management, &c->c2.link_read_bytes, &c->c2.link_write_bytes, - &c->c2.mda_context); - } -#endif }else {
@@ -1823,14 +1815,6 @@ mmap_stats->link_write_bytes = link_write_bytes_global; }#endif -#ifdef ENABLE_MANAGEMENT -if (management) - { -management_bytes_client (management,0 , size); -management_bytes_server (management, &c->c2.link_read_bytes, - &c->c2.link_write_bytes, &c->c2.mda_context); - } -#endif } }
src/openvpn/manage.c +52 -25
129 lines not on this page · raw message
src/openvpn/manage.h +2 -29
@@ -70,8 +70,6 @@unsigned int flags;unsigned int mda_key_id_counter; - -time_t bytecount_last_update; };/*
@@ -492,34 +490,9 @@* 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 management *man,struct timeval *timeval); -static inline void -management_bytes_client (struct management *man,const int size_in,const int size_out) -{ -if (!(man->persist.callback.flags &MCF_SERVER )) - { - man->persist.bytes_in += size_in; - man->persist.bytes_out += size_out; - } -} - -void man_bytecount_output_server (const counter_type *bytes_in_total, -const counter_type *bytes_out_total, -struct man_def_auth_context *mdac); - -static inline void -management_bytes_server (struct management *man,const counter_type *bytes_in_total, -const counter_type *bytes_out_total,struct man_def_auth_context *mdac) -{ -if (man->connection.bytecount_update_seconds >0 - && now >= mdac->bytecount_last_update + man->connection.bytecount_update_seconds - && (mdac->flags & (DAF_CONNECTION_ESTABLISHED |DAF_CONNECTION_CLOSED )) - ==DAF_CONNECTION_ESTABLISHED ) - { -man_bytecount_output_server (bytes_in_total, bytes_out_total, mdac); - } -} +void management_check_bytecount_server (struct multi_context *multi);void man_persist_client_stats (struct management *man,struct context *c);
src/openvpn/multi.c +7 -0
@@ -3812,6 +3812,13 @@ {check_stale_routes (m); } + +#ifdef ENABLE_MANAGEMENT +if (management) + { +management_check_bytecount_server (m); + } +#endif /* ENABLE_MANAGEMENT */ } static void
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1162?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I43a93f0d84f01fd808a64115e1b8c3b806706491
Gerrit-Change-Number: 1162
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: flichtenheld, plaisthos, stipa.
ralf_lici has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1162?usp=email )
Change subject: Refactor management bytecount tracking
......................................................................
Patch Set 1: Code-Review+2
(1 comment)
Patchset:
PS1:
Tested on Linux and it works perfectly.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1162?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I43a93f0d84f01fd808a64115e1b8c3b806706491
Gerrit-Change-Number: 1162
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: ralf_lici <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Fri, 29 Aug 2025 14:25:36 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH 1/1 Refactor management bytecount tracking
In reply to a message not in the archiveFrom: Lev Stipakov <[email protected]...>
There are few issues with it:
- when using DCO, the server part doesn't output BYTECOUNT_CLI since process_incoming_link_part1/process_outgoing_link are not called
- when using DCO, the server part applies bytecount timer to the each connection, unneccessary making too many calls to the kernel and also uses incorect BYTECOUNT output.
- client part outputs counters using timer, server part utilizes traffic activity -> inconsistency
Following changes have been made:
- Use timer to output counters in client and server mode. Code which deals with bytecount on traffic activity has been removed. This unifies DCO and non-DCO, as well as client and server mode
- In server mode, peers stats are fetched with the single ioctl call
- Per-packet stats are not persisted anymore in the client mode during traffic activity. Instead cumulative stats (including DCO stats) are persisted when the session closes.
GitHub: https://github.com/OpenVPN/openvpn/issues/820
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1162
This mail reflects revision 1 of this Change.
Acked-by according to Gerrit (reflected above):
Ralf Lici <[email protected]...>
src/openvpn/forward.c +1 -17
@@ -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 */ }
@@ -998,14 +998,6 @@ }#endif c->c2.original_recv_size = c->c2.buf.len; -#ifdef ENABLE_MANAGEMENT -if (management) - { -management_bytes_client (management, c->c2.buf.len,0 ); -management_bytes_server (management, &c->c2.link_read_bytes, &c->c2.link_write_bytes, - &c->c2.mda_context); - } -#endif }else {
@@ -1823,14 +1815,6 @@ mmap_stats->link_write_bytes = link_write_bytes_global; }#endif -#ifdef ENABLE_MANAGEMENT -if (management) - { -management_bytes_client (management,0 , size); -management_bytes_server (management, &c->c2.link_read_bytes, - &c->c2.link_write_bytes, &c->c2.mda_context); - } -#endif } }
src/openvpn/manage.c +52 -25
129 lines not on this page · raw message
src/openvpn/manage.h +2 -29
@@ -70,8 +70,6 @@unsigned int flags;unsigned int mda_key_id_counter; - -time_t bytecount_last_update; };/*
@@ -492,34 +490,9 @@* 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 management *man,struct timeval *timeval); -static inline void -management_bytes_client (struct management *man,const int size_in,const int size_out) -{ -if (!(man->persist.callback.flags &MCF_SERVER )) - { - man->persist.bytes_in += size_in; - man->persist.bytes_out += size_out; - } -} - -void man_bytecount_output_server (const counter_type *bytes_in_total, -const counter_type *bytes_out_total, -struct man_def_auth_context *mdac); - -static inline void -management_bytes_server (struct management *man,const counter_type *bytes_in_total, -const counter_type *bytes_out_total,struct man_def_auth_context *mdac) -{ -if (man->connection.bytecount_update_seconds >0 - && now >= mdac->bytecount_last_update + man->connection.bytecount_update_seconds - && (mdac->flags & (DAF_CONNECTION_ESTABLISHED |DAF_CONNECTION_CLOSED )) - ==DAF_CONNECTION_ESTABLISHED ) - { -man_bytecount_output_server (bytes_in_total, bytes_out_total, mdac); - } -} +void management_check_bytecount_server (struct multi_context *multi);void man_persist_client_stats (struct management *man,struct context *c);
src/openvpn/multi.c +7 -0
@@ -3812,6 +3812,13 @@ {check_stale_routes (m); } + +#ifdef ENABLE_MANAGEMENT +if (management) + { +management_check_bytecount_server (m); + } +#endif /* ENABLE_MANAGEMENT */ } static void
Attention is currently required from: flichtenheld, plaisthos, ralf_lici, stipa.
Hello flichtenheld, plaisthos, ralf_lici,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1162?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Code-Review+2 by ralf_lici
The change is no longer submittable: Code-Review and checks~ChecksSubmitRule are unsatisfied now.
Change subject: Refactor management bytecount tracking
......................................................................
Refactor management bytecount tracking
There are few issues with it:
- when using DCO, the server part doesn't output BYTECOUNT_CLI since process_incoming_link_part1/process_outgoing_link are not called
- when using DCO, the server part applies bytecount timer to the each connection, unneccessary making too many calls to the kernel and also uses incorect BYTECOUNT output.
- client part outputs counters using timer, server part utilizes traffic activity -> inconsistency
Following changes have been made:
- Use timer to output counters in client and server mode. Code which deals with bytecount on traffic activity has been removed. This unifies DCO and non-DCO, as well as client and server mode
- In server mode, peers stats are fetched with the single ioctl call
- Per-packet stats are not persisted anymore in the client mode during traffic activity. Instead cumulative stats (including DCO stats) are persisted when the session closes.
GitHub: https://github.com/OpenVPN/openvpn/issues/820
---
M src/openvpn/forward.c
M src/openvpn/manage.c
M src/openvpn/manage.h
M src/openvpn/multi.c
4 files changed, 70 insertions(+), 70 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/62/1162/2
src/openvpn/forward.c +1 -17
@@ -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 */ }
@@ -998,14 +998,6 @@ }#endif c->c2.original_recv_size = c->c2.buf.len; -#ifdef ENABLE_MANAGEMENT -if (management) - { -management_bytes_client (management, c->c2.buf.len,0 ); -management_bytes_server (management, &c->c2.link_read_bytes, &c->c2.link_write_bytes, - &c->c2.mda_context); - } -#endif }else {
@@ -1823,14 +1815,6 @@ mmap_stats->link_write_bytes = link_write_bytes_global; }#endif -#ifdef ENABLE_MANAGEMENT -if (management) - { -management_bytes_client (management,0 , size); -management_bytes_server (management, &c->c2.link_read_bytes, - &c->c2.link_write_bytes, &c->c2.mda_context); - } -#endif } }
src/openvpn/manage.c +60 -24
137 lines not on this page · raw message
src/openvpn/manage.h +2 -29
@@ -70,8 +70,6 @@unsigned int flags;unsigned int mda_key_id_counter; - -time_t bytecount_last_update; };/*
@@ -492,34 +490,9 @@* 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 management *man,struct timeval *timeval); -static inline void -management_bytes_client (struct management *man,const int size_in,const int size_out) -{ -if (!(man->persist.callback.flags &MCF_SERVER )) - { - man->persist.bytes_in += size_in; - man->persist.bytes_out += size_out; - } -} - -void man_bytecount_output_server (const counter_type *bytes_in_total, -const counter_type *bytes_out_total, -struct man_def_auth_context *mdac); - -static inline void -management_bytes_server (struct management *man,const counter_type *bytes_in_total, -const counter_type *bytes_out_total,struct man_def_auth_context *mdac) -{ -if (man->connection.bytecount_update_seconds >0 - && now >= mdac->bytecount_last_update + man->connection.bytecount_update_seconds - && (mdac->flags & (DAF_CONNECTION_ESTABLISHED |DAF_CONNECTION_CLOSED )) - ==DAF_CONNECTION_ESTABLISHED ) - { -man_bytecount_output_server (bytes_in_total, bytes_out_total, mdac); - } -} +void management_check_bytecount_server (struct multi_context *multi);void man_persist_client_stats (struct management *man,struct context *c);
src/openvpn/multi.c +7 -0
@@ -3812,6 +3812,13 @@ {check_stale_routes (m); } + +#ifdef ENABLE_MANAGEMENT +if (management) + { +management_check_bytecount_server (m); + } +#endif /* ENABLE_MANAGEMENT */ } static void
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1162?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I43a93f0d84f01fd808a64115e1b8c3b806706491
Gerrit-Change-Number: 1162
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: ralf_lici <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ralf_lici <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: flichtenheld, plaisthos, ralf_lici, stipa.
Hello flichtenheld, plaisthos, ralf_lici,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1162?usp=email
to look at the new patch set (#3).
Change subject: Refactor management bytecount tracking
......................................................................
Refactor management bytecount tracking
There are few issues with it:
- when using DCO, the server part doesn't output BYTECOUNT_CLI since process_incoming_link_part1/process_outgoing_link are not called
- when using DCO, the server part applies bytecount timer to the each connection, unneccessary making too many calls to the kernel and also uses incorect BYTECOUNT output.
- client part outputs counters using timer, server part utilizes traffic activity -> inconsistency
Following changes have been made:
- Use timer to output counters in client and server mode. Code which deals with bytecount on traffic activity has been removed. This unifies DCO and non-DCO, as well as client and server mode
- In server mode, peers stats are fetched with the single ioctl call
- Per-packet stats are not persisted anymore in the client mode during traffic activity. Instead cumulative stats (including DCO stats) are persisted when the session closes.
GitHub: https://github.com/OpenVPN/openvpn/issues/820
---
M src/openvpn/forward.c
M src/openvpn/manage.c
M src/openvpn/manage.h
M src/openvpn/multi.c
4 files changed, 72 insertions(+), 69 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/62/1162/3
src/openvpn/forward.c +1 -17
@@ -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 */ }
@@ -998,14 +998,6 @@ }#endif c->c2.original_recv_size = c->c2.buf.len; -#ifdef ENABLE_MANAGEMENT -if (management) - { -management_bytes_client (management, c->c2.buf.len,0 ); -management_bytes_server (management, &c->c2.link_read_bytes, &c->c2.link_write_bytes, - &c->c2.mda_context); - } -#endif }else {
@@ -1823,14 +1815,6 @@ mmap_stats->link_write_bytes = link_write_bytes_global; }#endif -#ifdef ENABLE_MANAGEMENT -if (management) - { -management_bytes_client (management,0 , size); -management_bytes_server (management, &c->c2.link_read_bytes, - &c->c2.link_write_bytes, &c->c2.mda_context); - } -#endif } }
src/openvpn/manage.c +62 -23
139 lines not on this page · raw message
src/openvpn/manage.h +2 -29
@@ -70,8 +70,6 @@unsigned int flags;unsigned int mda_key_id_counter; - -time_t bytecount_last_update; };/*
@@ -492,34 +490,9 @@* 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 management *man,struct timeval *timeval); -static inline void -management_bytes_client (struct management *man,const int size_in,const int size_out) -{ -if (!(man->persist.callback.flags &MCF_SERVER )) - { - man->persist.bytes_in += size_in; - man->persist.bytes_out += size_out; - } -} - -void man_bytecount_output_server (const counter_type *bytes_in_total, -const counter_type *bytes_out_total, -struct man_def_auth_context *mdac); - -static inline void -management_bytes_server (struct management *man,const counter_type *bytes_in_total, -const counter_type *bytes_out_total,struct man_def_auth_context *mdac) -{ -if (man->connection.bytecount_update_seconds >0 - && now >= mdac->bytecount_last_update + man->connection.bytecount_update_seconds - && (mdac->flags & (DAF_CONNECTION_ESTABLISHED |DAF_CONNECTION_CLOSED )) - ==DAF_CONNECTION_ESTABLISHED ) - { -man_bytecount_output_server (bytes_in_total, bytes_out_total, mdac); - } -} +void management_check_bytecount_server (struct multi_context *multi);void man_persist_client_stats (struct management *man,struct context *c);
src/openvpn/multi.c +7 -0
@@ -3812,6 +3812,13 @@ {check_stale_routes (m); } + +#ifdef ENABLE_MANAGEMENT +if (management) + { +management_check_bytecount_server (m); + } +#endif /* ENABLE_MANAGEMENT */ } static void
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1162?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I43a93f0d84f01fd808a64115e1b8c3b806706491
Gerrit-Change-Number: 1162
Gerrit-PatchSet: 3
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: ralf_lici <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ralf_lici <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: flichtenheld, plaisthos, ralf_lici, stipa.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1162?usp=email )
Change subject: Refactor management bytecount tracking
......................................................................
Patch Set 3: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1162?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I43a93f0d84f01fd808a64115e1b8c3b806706491
Gerrit-Change-Number: 1162
Gerrit-PatchSet: 3
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: ralf_lici <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ralf_lici <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Tue, 02 Sep 2025 10:35:44 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH v3 1/1 Refactor management bytecount tracking
In reply to a message not in the archiveFrom: Lev Stipakov <[email protected]...>
There are few issues with it:
- when using DCO, the server part doesn't output BYTECOUNT_CLI since process_incoming_link_part1/process_outgoing_link are not called
- when using DCO, the server part applies bytecount timer to the each connection, unneccessary making too many calls to the kernel and also uses incorect BYTECOUNT output.
- client part outputs counters using timer, server part utilizes traffic activity -> inconsistency
Following changes have been made:
- Use timer to output counters in client and server mode. Code which deals with bytecount on traffic activity has been removed. This unifies DCO and non-DCO, as well as client and server mode
- In server mode, peers stats are fetched with the single ioctl call
- Per-packet stats are not persisted anymore in the client mode during traffic activity. Instead cumulative stats (including DCO stats) are persisted when the session closes.
GitHub: https://github.com/OpenVPN/openvpn/issues/820
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1162
This mail reflects revision 3 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/forward.c +1 -17
@@ -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 */ }
@@ -998,14 +998,6 @@ }#endif c->c2.original_recv_size = c->c2.buf.len; -#ifdef ENABLE_MANAGEMENT -if (management) - { -management_bytes_client (management, c->c2.buf.len,0 ); -management_bytes_server (management, &c->c2.link_read_bytes, &c->c2.link_write_bytes, - &c->c2.mda_context); - } -#endif }else {
@@ -1823,14 +1815,6 @@ mmap_stats->link_write_bytes = link_write_bytes_global; }#endif -#ifdef ENABLE_MANAGEMENT -if (management) - { -management_bytes_client (management,0 , size); -management_bytes_server (management, &c->c2.link_read_bytes, - &c->c2.link_write_bytes, &c->c2.mda_context); - } -#endif } }
src/openvpn/manage.c +62 -23
139 lines not on this page · raw message
src/openvpn/manage.h +2 -29
@@ -70,8 +70,6 @@unsigned int flags;unsigned int mda_key_id_counter; - -time_t bytecount_last_update; };/*
@@ -492,34 +490,9 @@* 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 management *man,struct timeval *timeval); -static inline void -management_bytes_client (struct management *man,const int size_in,const int size_out) -{ -if (!(man->persist.callback.flags &MCF_SERVER )) - { - man->persist.bytes_in += size_in; - man->persist.bytes_out += size_out; - } -} - -void man_bytecount_output_server (const counter_type *bytes_in_total, -const counter_type *bytes_out_total, -struct man_def_auth_context *mdac); - -static inline void -management_bytes_server (struct management *man,const counter_type *bytes_in_total, -const counter_type *bytes_out_total,struct man_def_auth_context *mdac) -{ -if (man->connection.bytecount_update_seconds >0 - && now >= mdac->bytecount_last_update + man->connection.bytecount_update_seconds - && (mdac->flags & (DAF_CONNECTION_ESTABLISHED |DAF_CONNECTION_CLOSED )) - ==DAF_CONNECTION_ESTABLISHED ) - { -man_bytecount_output_server (bytes_in_total, bytes_out_total, mdac); - } -} +void management_check_bytecount_server (struct multi_context *multi);void man_persist_client_stats (struct management *man,struct context *c);
src/openvpn/multi.c +7 -0
@@ -3812,6 +3812,13 @@ {check_stale_routes (m); } + +#ifdef ENABLE_MANAGEMENT +if (management) + { +management_check_bytecount_server (m); + } +#endif /* ENABLE_MANAGEMENT */ } static void
[Openvpn-devel] [PATCH applied] Re: Refactor management bytecount tracking
Tested this on client and server side, with and without DCO.
Can confirm that "counters with DCO" did not work without this patch, and also the change to just get the counters from DCO once for all peers is obviously beneficial for larger instances.
It took me a while to understand the multiple levels of code complexity that were there *before* (management_bytes_client() doing something totally different than management_bytes_server(), for example) - so thanks a lot for refactoring this, the result is much easier to understand, and due to the event based timing, bytecounts are properly printed "on schedule" now (sometimes +1-2 seconds due to coarse timer granularity).
The mailing list and mail-archive.org are not playing nicely today, so I've linked to the sourceforge.net list archive instead.
Your patch has been applied to the master branch.
commit da309c1e8bed7b9c25e800499400c8ad908276db
Author: Lev Stipakov Date: Tue Sep 2 12:36:01 2025 +0200
Refactor management bytecount tracking
Signed-off-by: Lev Stipakov <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59228150/
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#4) to the change originally created by stipa. ( http://gerrit.openvpn.net/c/openvpn/+/1162?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: Refactor management bytecount tracking
......................................................................
Refactor management bytecount tracking
There are few issues with it:
- when using DCO, the server part doesn't output BYTECOUNT_CLI since process_incoming_link_part1/process_outgoing_link are not called
- when using DCO, the server part applies bytecount timer to the each connection, unneccessary making too many calls to the kernel and also uses incorrect BYTECOUNT output.
- client part outputs counters using timer, server part utilizes traffic activity -> inconsistency
Following changes have been made:
- Use timer to output counters in client and server mode. Code which deals with bytecount on traffic activity has been removed. This unifies DCO and non-DCO, as well as client and server mode
- In server mode, peers stats are fetched with the single ioctl call
- Per-packet stats are not persisted anymore in the client mode during traffic activity. Instead cumulative stats (including DCO stats) are persisted when the session closes.
GitHub: closes OpenVPN/openvpn#820
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59228150/
---
M src/openvpn/forward.c
M src/openvpn/manage.c
M src/openvpn/manage.h
M src/openvpn/multi.c
4 files changed, 73 insertions(+), 70 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/62/1162/4
src/openvpn/forward.c +1 -17
@@ -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 */ }
@@ -998,14 +998,6 @@ }#endif c->c2.original_recv_size = c->c2.buf.len; -#ifdef ENABLE_MANAGEMENT -if (management) - { -management_bytes_client (management, c->c2.buf.len,0 ); -management_bytes_server (management, &c->c2.link_read_bytes, &c->c2.link_write_bytes, - &c->c2.mda_context); - } -#endif }else {
@@ -1823,14 +1815,6 @@ mmap_stats->link_write_bytes = link_write_bytes_global; }#endif -#ifdef ENABLE_MANAGEMENT -if (management) - { -management_bytes_client (management,0 , size); -management_bytes_server (management, &c->c2.link_read_bytes, - &c->c2.link_write_bytes, &c->c2.mda_context); - } -#endif } }
src/openvpn/manage.c +63 -24
140 lines not on this page · raw message
src/openvpn/manage.h +2 -29
@@ -70,8 +70,6 @@unsigned int flags;unsigned int mda_key_id_counter; - -time_t bytecount_last_update; };/*
@@ -492,34 +490,9 @@* 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 management *man,struct timeval *timeval); -static inline void -management_bytes_client (struct management *man,const int size_in,const int size_out) -{ -if (!(man->persist.callback.flags &MCF_SERVER )) - { - man->persist.bytes_in += size_in; - man->persist.bytes_out += size_out; - } -} - -void man_bytecount_output_server (const counter_type *bytes_in_total, -const counter_type *bytes_out_total, -struct man_def_auth_context *mdac); - -static inline void -management_bytes_server (struct management *man,const counter_type *bytes_in_total, -const counter_type *bytes_out_total,struct man_def_auth_context *mdac) -{ -if (man->connection.bytecount_update_seconds >0 - && now >= mdac->bytecount_last_update + man->connection.bytecount_update_seconds - && (mdac->flags & (DAF_CONNECTION_ESTABLISHED |DAF_CONNECTION_CLOSED )) - ==DAF_CONNECTION_ESTABLISHED ) - { -man_bytecount_output_server (bytes_in_total, bytes_out_total, mdac); - } -} +void management_check_bytecount_server (struct multi_context *multi);void man_persist_client_stats (struct management *man,struct context *c);
src/openvpn/multi.c +7 -0
@@ -3812,6 +3812,13 @@ {check_stale_routes (m); } + +#ifdef ENABLE_MANAGEMENT +if (management) + { +management_check_bytecount_server (m); + } +#endif /* ENABLE_MANAGEMENT */ } static void
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1162?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I43a93f0d84f01fd808a64115e1b8c3b806706491
Gerrit-Change-Number: 1162
Gerrit-PatchSet: 4
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: ralf_lici <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1162?usp=email )
Change subject: Refactor management bytecount tracking
......................................................................
Refactor management bytecount tracking
There are few issues with it:
- when using DCO, the server part doesn't output BYTECOUNT_CLI since process_incoming_link_part1/process_outgoing_link are not called
- when using DCO, the server part applies bytecount timer to the each connection, unneccessary making too many calls to the kernel and also uses incorrect BYTECOUNT output.
- client part outputs counters using timer, server part utilizes traffic activity -> inconsistency
Following changes have been made:
- Use timer to output counters in client and server mode. Code which deals with bytecount on traffic activity has been removed. This unifies DCO and non-DCO, as well as client and server mode
- In server mode, peers stats are fetched with the single ioctl call
- Per-packet stats are not persisted anymore in the client mode during traffic activity. Instead cumulative stats (including DCO stats) are persisted when the session closes.
GitHub: closes OpenVPN/openvpn#820
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59228150/
---
M src/openvpn/forward.c
M src/openvpn/manage.c
M src/openvpn/manage.h
M src/openvpn/multi.c
4 files changed, 73 insertions(+), 70 deletions(-)
src/openvpn/forward.c +1 -17
@@ -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 */ }
@@ -998,14 +998,6 @@ }#endif c->c2.original_recv_size = c->c2.buf.len; -#ifdef ENABLE_MANAGEMENT -if (management) - { -management_bytes_client (management, c->c2.buf.len,0 ); -management_bytes_server (management, &c->c2.link_read_bytes, &c->c2.link_write_bytes, - &c->c2.mda_context); - } -#endif }else {
@@ -1823,14 +1815,6 @@ mmap_stats->link_write_bytes = link_write_bytes_global; }#endif -#ifdef ENABLE_MANAGEMENT -if (management) - { -management_bytes_client (management,0 , size); -management_bytes_server (management, &c->c2.link_read_bytes, - &c->c2.link_write_bytes, &c->c2.mda_context); - } -#endif } }
src/openvpn/manage.c +63 -24
140 lines not on this page · raw message
src/openvpn/manage.h +2 -29
@@ -70,8 +70,6 @@unsigned int flags;unsigned int mda_key_id_counter; - -time_t bytecount_last_update; };/*
@@ -492,34 +490,9 @@* 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 management *man,struct timeval *timeval); -static inline void -management_bytes_client (struct management *man,const int size_in,const int size_out) -{ -if (!(man->persist.callback.flags &MCF_SERVER )) - { - man->persist.bytes_in += size_in; - man->persist.bytes_out += size_out; - } -} - -void man_bytecount_output_server (const counter_type *bytes_in_total, -const counter_type *bytes_out_total, -struct man_def_auth_context *mdac); - -static inline void -management_bytes_server (struct management *man,const counter_type *bytes_in_total, -const counter_type *bytes_out_total,struct man_def_auth_context *mdac) -{ -if (man->connection.bytecount_update_seconds >0 - && now >= mdac->bytecount_last_update + man->connection.bytecount_update_seconds - && (mdac->flags & (DAF_CONNECTION_ESTABLISHED |DAF_CONNECTION_CLOSED )) - ==DAF_CONNECTION_ESTABLISHED ) - { -man_bytecount_output_server (bytes_in_total, bytes_out_total, mdac); - } -} +void management_check_bytecount_server (struct multi_context *multi);void man_persist_client_stats (struct management *man,struct context *c);
src/openvpn/multi.c +7 -0
@@ -3812,6 +3812,13 @@ {check_stale_routes (m); } + +#ifdef ENABLE_MANAGEMENT +if (management) + { +management_check_bytecount_server (m); + } +#endif /* ENABLE_MANAGEMENT */ } static void
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1162?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I43a93f0d84f01fd808a64115e1b8c3b806706491
Gerrit-Change-Number: 1162
Gerrit-PatchSet: 4
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: ralf_lici <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged