Attention is currently required from: plaisthos, ralf_lici.

Hello ordex, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1952?usp=email

to look at the new patch set (#2).


Change subject: dco: stop fetching peer stats during client disconnect
......................................................................

dco: stop fetching peer stats during client disconnect

The disconnect path asks DCO for a fresh peer dump after the multi
instance has already been removed from the peer-id lookup table. For
kernel-initiated disconnects, the peer has also already been deleted by
the time its notification is processed. The reply therefore cannot
update the disconnecting instance.

Moreover, each disconnect dumps all surviving peers, causing avoidable
netlink traffic and repeated work when many clients disconnect at once.

During shutdown or restart, fetch a single final peer snapshot before
closing any instances, while all peers can still be mapped to their
userspace contexts.

For individual disconnects, use the cached counters directly. Kernels
that provide a final statistics snapshot in the deletion notification
can update them before the disconnect environment is prepared.

Change-Id: Ic535bb1f0da1739f87e9d6bef6fd1061247b05de
Signed-off-by: Ralf Lici <[email protected]>
---
M dev-tools/cppcheck-suppression
M src/openvpn/multi.c
2 files changed, 14 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/52/1952/2

diff --git a/dev-tools/cppcheck-suppression b/dev-tools/cppcheck-suppression
index 299d7a3..38ca062 100644
--- a/dev-tools/cppcheck-suppression
+++ b/dev-tools/cppcheck-suppression
@@ -26,7 +26,7 @@
 # FP: posix.cfg claims suseconds_t is unsigned for some reason
 unsignedLessThanZero:src/openvpn/otime.h:148
 # IGN: multi code does weird things with pointers to local variables...
-autoVariables:src/openvpn/multi.c:4242
+autoVariables:src/openvpn/multi.c:4240
 autoVariables:src/openvpn/multi_io.c:324
 # IGN: the code header = 0 | (OPCODE << P_OPCODE_SHIFT) is used intentionally
 badBitmaskCheck:src/openvpn/mudp.c
diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
index 3e72b92..b7085dc 100644
--- a/src/openvpn/multi.c
+++ b/src/openvpn/multi.c
@@ -496,37 +496,29 @@
 }

 static void
-setenv_stats(struct multi_context *m, struct context *c)
+setenv_stats(struct context *c)
 {
-    if (dco_enabled(&m->top.options))
-    {
-        if (dco_get_peer_stats_multi(&m->top.c1.tuntap->dco, false) < 0)
-        {
-            return;
-        }
-    }
-
     setenv_counter(c->c2.es, "bytes_received", c->c2.link_read_bytes + 
c->c2.dco_read_bytes);
     setenv_counter(c->c2.es, "bytes_sent", c->c2.link_write_bytes + 
c->c2.dco_write_bytes);
 }

 static void
-multi_client_disconnect_setenv(struct multi_context *m, struct multi_instance 
*mi)
+multi_client_disconnect_setenv(struct multi_instance *mi)
 {
     /* setenv client real IP address */
     setenv_trusted(mi->context.c2.es, get_link_socket_info(&mi->context));

     /* setenv stats */
-    setenv_stats(m, &mi->context);
+    setenv_stats(&mi->context);

     /* setenv connection duration */
     setenv_long_long(mi->context.c2.es, "time_duration", now - mi->created);
 }

 static void
-multi_client_disconnect_script(struct multi_context *m, struct multi_instance 
*mi)
+multi_client_disconnect_script(struct multi_instance *mi)
 {
-    multi_client_disconnect_setenv(m, mi);
+    multi_client_disconnect_setenv(mi);

     if (plugin_defined(mi->context.plugins, OPENVPN_PLUGIN_CLIENT_DISCONNECT))
     {
@@ -634,7 +626,7 @@

     if (mi->context.c2.tls_multi->multi_state >= CAS_CONNECT_DONE)
     {
-        multi_client_disconnect_script(m, mi);
+        multi_client_disconnect_script(mi);
     }

     close_context(&mi->context, SIGTERM, CC_GC_FREE);
@@ -659,6 +651,12 @@
 {
     if (m->hash)
     {
+        /* fetch final stats while all peers can still be mapped to their 
instances */
+        if (dco_enabled(&m->top.options))
+        {
+            dco_get_peer_stats_multi(&m->top.c1.tuntap->dco, false);
+        }
+
         for (uint32_t i = 0; i <= m->max_peerid; i++)
         {
             struct multi_instance *mi = m->instances[i];
@@ -2750,7 +2748,7 @@
          * did not fail */
         if (mi->context.c2.tls_multi->multi_state == 
CAS_PENDING_DEFERRED_PARTIAL)
         {
-            multi_client_disconnect_script(m, mi);
+            multi_client_disconnect_script(mi);
         }

         mi->context.c2.tls_multi->multi_state = CAS_FAILED;

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1952?usp=email
To unsubscribe, or for help writing mail filters, visit 
http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic535bb1f0da1739f87e9d6bef6fd1061247b05de
Gerrit-Change-Number: 1952
Gerrit-PatchSet: 2
Gerrit-Owner: ralf_lici <[email protected]>
Gerrit-Reviewer: ordex <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: razvanc <[email protected]>
Gerrit-Attention: ralf_lici <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to