Skip to contentSkip to conversation

management: refactor bytecount routines

PATCH In review Lev Stipakov 2 participants 2 messages Dec 12, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 management: refactor bytecount routines

From: Lev Stipakov <[email protected]...>

In preparation of DCO stats support, simplify call chains of bytecount routines. No functional changes.

---
 src/openvpn/forward.c |  4 +--
 src/openvpn/manage.c  | 64 ++++++++++++++++++++++++++++-------------
 src/openvpn/manage.h  | 66 ++++---------------------------------------
 3 files changed, 52 insertions(+), 82 deletions(-)
src/openvpn/forward.c +2 -2
index 5cd7eaa6..1cd20a0b 100644
@@ -948,7 +948,7 @@ process_incoming_link_part1(struct context *c, struct link_socket_info *lsi, boo
 #ifdef ENABLE_MANAGEMENT
         if (management)
         {
-            management_bytes_in(management, c->c2.buf.len);
+            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
@@ -1788,7 +1788,7 @@ process_outgoing_link(struct context *c)
 #ifdef ENABLE_MANAGEMENT
                 if (management)
                 {
-                    management_bytes_out(management, size);
+                    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 +44 -20

75 lines not on this page · raw message

src/openvpn/manage.h +6 -60

76 lines not on this page · raw message

Signature · 1 line
2.38.1.windows.1
#1 lore raw

Am 12.12.22 um 10:58 schrieb Lev Stipakov:

Quoted 4 lines

From: Lev Stipakov <[email protected]...>

In preparation of DCO stats support, simplify call chains of bytecount routines. No functional changes.

It would be nice to be a bit more verbose what you are actually simplyfing in the commit message. E.g. inlining all the various function that are used only once.

src/openvpn/manage.c man_bytecount(struct management *man, const int update_seconds) · line 503

Quoted 13 lines
src/openvpn/manage.c +12 -0
+
+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;
+        man_bytecount_output_client(man);
+    }
  }

I don't like this part of the change. We are here moving a inline function from the critical path of data channel packets that is called on every single packet into an non-inline function.

The old code was taking care that everything that was in that critical path can be inlined. The new code breaks that promise.

Arne