Gert Doering has uploaded a new patch set (#3) to the change originally created 
by Arne Schwabe. ( https://gerrit.openvpn.net/c/openvpn/+/2064?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by Răzvan Cojocaru


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 map in the future.
UDP connections only need to be added to this hash map in a later stage
of the connection process and then only for peers that do not support
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]>
Acked-by: Razvan Cojocaru <[email protected]>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2064
Message-Id: <[email protected]>
URL: 
https://www.mail-archive.com/[email protected]/msg40261.html
Signed-off-by: Gert Doering <[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/3

diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
index f211ef3..b69a209 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)",
@@ -4199,6 +4201,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 5aed191..3d2e932 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: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iad51b2f31e4215c58e160cc6239836015ea4d3cf
Gerrit-Change-Number: 2064
Gerrit-PatchSet: 3
Gerrit-Owner: Arne Schwabe <[email protected]>
Gerrit-Reviewer: Răzvan Cojocaru <[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