Message ID | 20221215232104.1181936-1-selva.nair@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | [Openvpn-devel] Persist DCO client data channel traffic stats on restart | expand |
Hi, That was fast! > 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. Acked-by: Lev Stipakov <lstipakov@gmail.com>
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 <selva.nair@gmail.com> Acked-by: Lev Stipakov <lstipakov@gmail.com> Message-Id: <20221215232104.1181936-1-selva.nair@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25742.html Signed-off-by: Gert Doering <gert@greenie.muc.de> -- kind regards, Gert Doering
diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 74b38032..e0b42e1e 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -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. diff --git a/src/openvpn/init.h b/src/openvpn/init.h index f53b65ee..d0fb6ea1 100644 --- a/src/openvpn/init.h +++ b/src/openvpn/init.h @@ -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 */ diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index 9349b62a..82832436 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -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 diff --git a/src/openvpn/manage.h b/src/openvpn/manage.h index 700b15cf..30291e42 100644 --- a/src/openvpn/manage.h +++ b/src/openvpn/manage.h @@ -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 */ /** diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c index 15e21452..413a750b 100644 --- a/src/openvpn/openvpn.c +++ b/src/openvpn/openvpn.c @@ -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) */