Attention is currently required from: Arne Schwabe.

Hello Arne Schwabe,

I'd like you to do a code review.
Please visit

    https://gerrit.openvpn.net/c/openvpn/+/2040?usp=email

to review the following change.


Change subject: p2p: don't report WAIT/AUTH for a new session while connected
......................................................................

p2p: don't report WAIT/AUTH for a new session while connected

In p2p mode, a hard reset that starts a new session moves the management
state to AUTH and WAIT even while the tunnel is up. If that session
never completes (e.g. an unauthenticated probe without tls-auth/tls-crypt,
or a peer that gives up), CONNECTED is never announced again and the
state stays WAIT although the tunnel works fine.

Don't announce AUTH/WAIT when an established session already exists.
A successful new session still re-announces CONNECTED via
CAS_RECONNECT_PENDING.

Also document that WAIT and AUTH are reported in p2p mode too.

Change-Id: Iea151988f2fa120b1262051572604e3f42ef4b1c
Signed-off-by: Antonio Quartulli <[email protected]>
---
M doc/management-notes.txt
M src/openvpn/ssl.c
2 files changed, 30 insertions(+), 10 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/40/2040/1

diff --git a/doc/management-notes.txt b/doc/management-notes.txt
index a28a1a8..5b32ba6 100644
--- a/doc/management-notes.txt
+++ b/doc/management-notes.txt
@@ -427,9 +427,10 @@
 These are the OpenVPN states:

 CONNECTING    -- OpenVPN's initial state.
-WAIT          -- (Client only) Waiting for initial response
-                 from server.
-AUTH          -- (Client only) Authenticating with server.
+WAIT          -- (Client and point-to-point only) Waiting for
+                 initial response from server or peer.
+AUTH          -- (Client and point-to-point only) Authenticating
+                 with server or peer.
 GET_CONFIG    -- (Client only) Downloading configuration options
                  from server.
 ASSIGN_IP     -- Assigning IP address to virtual network
diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c
index 086a6fc..a0edf69 100644
--- a/src/openvpn/ssl.c
+++ b/src/openvpn/ssl.c
@@ -2517,6 +2517,18 @@
 }

 /**
+ * Returns true if this multi context has an established session, i.e. the
+ * initial connection has completed and the tunnel is up.  A new session
+ * that is being negotiated in TM_INITIAL in this state does not change the
+ * state of the tunnel until it is promoted to TM_ACTIVE.
+ */
+static bool
+tls_multi_established(const struct tls_multi *multi)
+{
+    return multi->multi_state >= CAS_CONNECT_DONE;
+}
+
+/**
  * Move the session from S_INITIAL to S_PRE_START. This will also generate
  * the initial message based on ks->initial_opcode
  *
@@ -2554,12 +2566,6 @@
          session_id_print(&session->session_id, &gc));
     gc_free(&gc);

-#ifdef ENABLE_MANAGEMENT
-    if (management && ks->initial_opcode != P_CONTROL_SOFT_RESET_V1)
-    {
-        management_set_state(management, OPENVPN_STATE_WAIT, NULL, NULL, NULL, 
NULL, NULL);
-    }
-#endif
     return true;
 }

@@ -2883,6 +2889,18 @@
     if (ks->state == S_INITIAL)
     {
         continue_tls_process = session_move_pre_start(session, ks, false);
+#ifdef ENABLE_MANAGEMENT
+        /* Do not report a new session attempt (e.g. a peer restart in p2p
+         * mode or a stray hard reset packet) as WAIT when we already have
+         * an established session: the tunnel is still up and, unless the
+         * new session succeeds, nothing would ever report CONNECTED again */
+        if (continue_tls_process && management
+            && ks->initial_opcode != P_CONTROL_SOFT_RESET_V1
+            && !tls_multi_established(multi))
+        {
+            management_set_state(management, OPENVPN_STATE_WAIT, NULL, NULL, 
NULL, NULL, NULL);
+        }
+#endif
     }

     /* Are we timed out on receive? */
@@ -3891,7 +3909,8 @@
         }

 #ifdef ENABLE_MANAGEMENT
-        if (management)
+        /* see the WAIT state in tls_process_state() */
+        if (management && !tls_multi_established(multi))
         {
             management_set_state(management, OPENVPN_STATE_AUTH, NULL, NULL, 
NULL, NULL, NULL);
         }

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

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iea151988f2fa120b1262051572604e3f42ef4b1c
Gerrit-Change-Number: 2040
Gerrit-PatchSet: 1
Gerrit-Owner: Antonio Quartulli <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to