Arne Schwabe has uploaded this change for review. ( 
https://gerrit.openvpn.net/c/openvpn/+/2064?usp=email )


Change subject: Track number of assigned peer ids and use it for max-clients 
check
......................................................................

Track number of assigned peer ids and use it for max-clients check

In the past we used the real address hash as proxy for the number
of connected clients. TCP connections do not really need
this and we might remove adding them to this hash in the future and
UDP connections only really this later in the connection establishment
and then only for peers that are of capable of DATA_V2.

Instead have a simple counter that is kept up to date when a peer id
is assigned and freed. This also allows this to be decoupled from
the real addresses hash.

Reported-by: Ar-maan05 https://github.com/OpenVPN/openvpn/issues/1127
Github: Closes OpenVPN/openvpn#1127
Change-Id: Iad51b2f31e4215c58e160cc6239836015ea4d3cf
Signed-off-by: Arne Schwabe <[email protected]>
---
M src/openvpn/multi.c
M src/openvpn/multi.h
2 files changed, 7 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/64/2064/1

diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
index e302a81..82757f4 100644
--- a/src/openvpn/multi.c
+++ b/src/openvpn/multi.c
@@ -621,6 +621,8 @@
             {
                 m->max_peerid--;
             }
+
+            m->assigned_peer_ids--;
         }

         schedule_remove_entry(m->schedule, (struct schedule_entry *)mi);
@@ -749,7 +751,7 @@

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

-    if (hash_n_elements(m->hash) >= m->max_clients)
+    if (m->assigned_peer_ids >= m->max_clients)
     {
         msg(D_MULTI_ERRORS,
             "MULTI: new incoming connection would exceed maximum number of 
clients (%u)",
@@ -4219,6 +4221,8 @@
     {
         m->max_peerid = mi->context.c2.tls_multi->rx_peer_id;
     }
+
+    m->assigned_peer_ids++;
 }

 /**
diff --git a/src/openvpn/multi.h b/src/openvpn/multi.h
index 5db7147..cc7ccd3 100644
--- a/src/openvpn/multi.h
+++ b/src/openvpn/multi.h
@@ -174,6 +174,8 @@
     uint32_t max_peerid;               /**< highest currently allocated peer-id
                                         * and maximum allocated/valid index in
                                         * instances */
+    uint32_t assigned_peer_ids;        /**< Number of peer-ids that are
+                                        *   currently assigned */
     struct hash *hash;                 /**< VPN tunnel instances indexed by 
real
                                         *   address of the remote peer. */
     struct hash *vhash;                /**< VPN tunnel instances indexed by

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2064?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: Iad51b2f31e4215c58e160cc6239836015ea4d3cf
Gerrit-Change-Number: 2064
Gerrit-PatchSet: 1
Gerrit-Owner: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to