Persist DCO client data channel traffic stats on restart
PATCH 1/1 Persist DCO client data channel traffic stats on restart
From: Selva Nair <[email protected]...>
---
Tested on Windows which is the only platform that currently supports stats from DCO in client mode.
src/openvpn/init.c | 11 +++++++++++ src/openvpn/init.h | 2 ++ src/openvpn/manage.c | 9 +++++++++ src/openvpn/manage.h | 3 +++ src/openvpn/openvpn.c | 2 ++ 5 files changed, 27 insertions(+)
src/openvpn/init.c +11 -0
@@ -4164,6 +4164,17 @@ uninit_management_callback(void)#endif } +void +persist_client_stats (struct context *c) +{ +#ifdef ENABLE_MANAGEMENT +if (management) + { +man_persist_client_stats (management, c); + } +#endif +} +/* * Initialize a tunnel instance, handle pre and post-init * signal settings.
src/openvpn/init.h +2 -0
@@ -147,4 +147,6 @@ void write_pid_file(const char *filename, const char *chroot_dir);void remove_pid_file (void ); +void persist_client_stats (struct context *c); +#endif /* ifndef INIT_H */
src/openvpn/manage.c +9 -0
@@ -4068,6 +4068,15 @@ management_check_bytecount(struct context *c, struct management *man, struct tim } } +void +man_persist_client_stats (struct management *man,struct context *c) +{ +if (dco_enabled (&c->options) && (dco_get_peer_stats (c) ==0 )) + { +management_bytes_client (man, c->c2.dco_read_bytes, c->c2.dco_write_bytes); + } +} +#else /* ifdef ENABLE_MANAGEMENT */ void
src/openvpn/manage.h +3 -0
@@ -548,6 +548,9 @@ management_bytes_server(struct management *man, } } +void +man_persist_client_stats (struct management *man,struct context *c); +#endif /* ifdef ENABLE_MANAGEMENT */ /**
src/openvpn/openvpn.c +2 -0
@@ -97,6 +97,8 @@ tunnel_point_to_point(struct context *c)perf_pop (); } +persist_client_stats (c); +uninit_management_callback ();/* tear down tunnel instance (unless --persist-tun) */
Signature · 1 line
2.34.1
Hi,
That was fast!
Quoted 2 lines
Tested on Windows which is the only platform that currently supports stats from DCO in client mode.
Would be nice to have a comment (in code maybe?) that:
DCO resets stats on reconnect. Since client expects stats to be preserved across reconnects, we need to save DCO stats before tearing the tunnel down.
But anyway,
Code looks good, compiled and tested - stats are indeed preserved across reconnect.
I have not tested this beyond "push to my github instance and verify that it still builds", but if Lev says it's been tested and working, good enough. Stare-at-code finds me wondering why we didn't remove ENABLE_MANAGEMENT yet (my fault...) and need these extra indirections - but that's for 2.7 to clean up, I am afraid.
Your patch has been applied to the master and release/2.6 branch.
commit 0fdbb288db06792d5dd29acd14205d751041513d (master) commit 1f17444ad02e500a717e2674f6ef74c1d2c49567 (release/2.6)
Author: Selva Nair Date: Thu Dec 15 18:21:04 2022 -0500
Persist DCO client data channel traffic stats on restart
Signed-off-by: Selva Nair <[email protected]...>
Acked-by: Lev Stipakov <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg25742.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering