management: add timer to push BYTECOUNT
PATCH 2/2 management: add timer to push BYTECOUNT
From: Lev Stipakov <[email protected]...>
At the moment BYTECOUNT in,out is pushed if there is traffic. With DCO, userspace process doesn't see the traffic, so we need to add a timer which periodically fetches stats from DCO and pushes to management client. The timer interval is set by existing "bytecount n" management command.
This commit only adds a timer, stats fetching from DCO will be added later.
--- src/openvpn/forward.c | 11 ++++++++-- src/openvpn/manage.c | 51 ++++++++++++++++++++++++++++++++++++------- src/openvpn/manage.h | 10 +++++++-- 3 files changed, 60 insertions(+), 12 deletions(-)
src/openvpn/forward.c +9 -2
@@ -766,6 +766,13 @@ process_coarse_timers(struct context *c)/* Should we ping the remote? */ check_ping_send (c); + +#ifdef ENABLE_MANAGEMENT +if (management) + { +management_check_bytecount (c, management, &c->c2.timeval); + } +#endif /* ENABLE_MANAGEMENT */ } static void
@@ -949,7 +956,7 @@ process_incoming_link_part1(struct context *c, struct link_socket_info *lsi, booif (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); +management_bytes_server (management, c->c2.link_read_bytes, c->c2.link_write_bytes, &c->c2.mda_context); }#endif }
@@ -1789,7 +1796,7 @@ process_outgoing_link(struct context *c)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); +management_bytes_server (management, c->c2.link_read_bytes, c->c2.link_write_bytes, &c->c2.mda_context); }#endif }
src/openvpn/manage.c +43 -8
107 lines not on this page · raw message
src/openvpn/manage.h +8 -2
@@ -296,6 +296,7 @@ struct man_connection {bool echo_realtime;int bytecount_update_seconds;time_t bytecount_last_update; +struct event_timeout bytecount_update_interval;const char *up_query_type;int up_query_mode;
@@ -518,10 +519,15 @@ management_bytes_client(struct management *man,void management_bytes_server (struct management *man, -const counter_type *bytes_in_total, -const counter_type *bytes_out_total, +const counter_type bytes_in_total, +const counter_type bytes_out_total,struct man_def_auth_context *mdac); +void +management_check_bytecount (struct context *c, +struct management *man, +struct timeval *timeval); +#endif /* ifdef ENABLE_MANAGEMENT */ /**
Signature · 1 line
2.38.1.windows.1
Am 12.12.22 um 12:56 schrieb Lev Stipakov:
Quoted 10 lines
From: Lev Stipakov <[email protected]...>
At the moment BYTECOUNT in,out is pushed if there is traffic. With DCO, userspace process doesn't see the traffic, so we need to add a timer which periodically fetches stats from DCO and pushes to management client. The timer interval is set by existing "bytecount n" management command.
This commit only adds a timer, stats fetching from DCO will be added later.
If you do the timers anyway why keep the other logic that triggers on
updating the byte count? That feels duplicating and
unnecessary complexity. So if we switch to a timer, I would strongly advocate to remove the other code path to avoid having two code paths that only add complexity but do not offer any significant (none?) benefit vs only keeping the timer.
Arne