Change in openvpn[master]: Increase default size of internal hash maps to 1024
A message that is not in the archive (sent off-list or not yet received): gerrit.1773145887000.Ia699b0dfa407ac377970bb130434298eaaec592b@...2715...
plaisthos has uploaded this change for review. ( http://gerrit.openvpn.net/c/openvpn/+/1563?usp=email )
Change subject: Increase default size of internal hash maps to 1024
......................................................................
Increase default size of internal hash maps to 1024
The default of 256 seems quite low for today's standards and cause hash collisions quite quickly.
---
M doc/man-sections/advanced-options.rst
M src/openvpn/options.c
2 files changed, 3 insertions(+), 3 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/63/1563/1
doc/man-sections/advanced-options.rst +1 -1
@@ -36,7 +36,7 @@ hash-size r v - By default, both tables are sized at 256 buckets. + By default, both tables are sized at 1024 buckets. --bcast-buffers n Allocate ``n`` buffers for broadcast datagrams (default :code:`256`).
src/openvpn/options.c +2 -2
@@ -849,8 +849,8 @@#endif o->vlan_accept =VLAN_ALL ; o->vlan_pvid =1 ; - o->real_hash_size =256 ; - o->virtual_hash_size =256 ; + o->real_hash_size =1024 ; + o->virtual_hash_size =1024 ; o->n_bcast_buf =256 ; o->tcp_queue_limit =64 ; o->max_clients =1024 ;
Signature · 11 lines
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1563?usp=email To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ia699b0dfa407ac377970bb130434298eaaec592b Gerrit-Change-Number: 1563 Gerrit-PatchSet: 1 Gerrit-Owner: plaisthos <[email protected]...> Gerrit-CC: openvpn-devel <[email protected]>
Attention is currently required from: plaisthos.
flichtenheld has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1563?usp=email )
Change subject: Increase default size of internal hash maps to 1024
......................................................................
Patch Set 3:
(1 comment)
File src/openvpn/options.c:
http://gerrit.openvpn.net/c/openvpn/+/1563/comment/7744ca59_c2802330?usp=email :
PS3, Line 853: o->virtual_hash_size = 1024;
Do we have any justification for 1024 specifically? I.e. any way to say whether 2048 would be better or worse?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1563?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia699b0dfa407ac377970bb130434298eaaec592b
Gerrit-Change-Number: 1563
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-CC: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Thu, 12 Mar 2026 11:20:40 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
[Openvpn-devel] [S] Change in openvpn[master]: Increase default size of internal hash maps to 4 * --max-clients
In reply to a message not in the archiveAttention is currently required from: plaisthos.
plaisthos has uploaded a new patch set (#4). ( http://gerrit.openvpn.net/c/openvpn/+/1563?usp=email )
Change subject: Increase default size of internal hash maps to 4 * --max-clients
......................................................................
Increase default size of internal hash maps to 4 * --max-clients
The default of 256 seems quite low as with (at least) 1024 possible entries we have a guaranteed collisions. Using 4 times the number of possible entries for real addresses should reduce collisions quite a bit while also leaving some headroom for the virtual addresses hash where a client might have more than one address.
A reason to keep the limit so low are the memory requirements. Each bucket has the size of one linked-list pointer (4 byte or 32 bit and 8 byte for 64 bit). So 256 buckets use 1 or 2 kB while 4096 will use 16 kB or 32 kB.
When the current limit was set 20 years ago this might have been a meaningful memory saving but today the collision probability is more important.
---
M doc/man-sections/advanced-options.rst
M doc/man-sections/server-options.rst
M src/openvpn/options.c
3 files changed, 20 insertions(+), 4 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/63/1563/4
doc/man-sections/advanced-options.rst +2 -1
@@ -36,7 +36,8 @@ hash-size r v - By default, both tables are sized at 256 buckets. + By default, both tables are sized at 4 times ``--max-clients`` buckets. + With the default of 1024 of ``--max-clients`` this gives 4096 buckets. --bcast-buffers n Allocate ``n`` buffers for broadcast datagrams (default :code:`256`).
doc/man-sections/server-options.rst +1 -1
@@ -414,7 +414,7 @@ iroute-ipv6 ipv6addr/bits --max-clients n - Limit server to a maximum of ``n`` concurrent clients. + Limit server to a maximum of ``n`` concurrent clients. Defaults to 1024. --max-routes-per-client n Allow a maximum of ``n`` internal routes per client (default
src/openvpn/options.c +17 -2
@@ -849,8 +849,6 @@#endif o->vlan_accept =VLAN_ALL ; o->vlan_pvid =1 ; - o->real_hash_size =256 ; - o->virtual_hash_size =256 ; o->n_bcast_buf =256 ; o->tcp_queue_limit =64 ; o->max_clients =1024 ;
@@ -3724,6 +3722,22 @@ gc_free(&gc); }#endif /* if defined(_WIN32) || defined(TARGET_ANDROID) */ +/** +* Sets the internal hash maps sizes according to the max_clients +* +*/ +static void +helper_hashmap_sizes (struct options *o) +{ +if (!o->real_hash_size) + { + o->real_hash_size =4 * o->max_clients; + } +if (!o->virtual_hash_size) + { + o->virtual_hash_size =4 * o->max_clients; + } +}static void options_postprocess_mutate (struct options *o,struct env_set *es)
@@ -3738,6 +3752,7 @@helper_setdefault_topology (o);helper_keepalive (o);helper_tcp_nodelay (o); +helper_hashmap_sizes (o);options_postprocess_setdefault_ncpciphers (o);options_set_backwards_compatible_options (o);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1563?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: Ia699b0dfa407ac377970bb130434298eaaec592b
Gerrit-Change-Number: 1563
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-CC: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
[Openvpn-devel] [S] Change in openvpn[master]: Increase default size of internal hash maps to 4 * --max-clients
In reply to a message not in the archiveAttention is currently required from: plaisthos.
flichtenheld has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1563?usp=email )
Change subject: Increase default size of internal hash maps to 4 * --max-clients
......................................................................
Patch Set 4: Code-Review+2
(1 comment)
File src/openvpn/options.c:
http://gerrit.openvpn.net/c/openvpn/+/1563/comment/0f7cef1a_f02730ea?usp=email :
PS3, Line 853: o->virtual_hash_size = 1024;
Quoted 1 line
Do we have any justification for 1024 specifically? I.e. […]
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1563?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia699b0dfa407ac377970bb130434298eaaec592b
Gerrit-Change-Number: 1563
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Thu, 12 Mar 2026 13:12:32 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: flichtenheld <[email protected]...>
[Openvpn-devel] [S] Change in openvpn[master]: Increase default size of internal hash maps to 4 * --max-clients
In reply to a message not in the archiveAttention is currently required from: flichtenheld, plaisthos.
Hello flichtenheld,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1563?usp=email
to look at the new patch set (#5).
The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld
Change subject: Increase default size of internal hash maps to 4 * --max-clients
......................................................................
Increase default size of internal hash maps to 4 * --max-clients
The default of 256 seems quite low as with (at least) 1024 possible entries we have a guaranteed collisions. Using 4 times the number of possible entries for real addresses should reduce collisions quite a bit while also leaving some headroom for the virtual addresses hash where a client might have more than one address.
A reason to keep the limit so low are the memory requirements. Each bucket has the size of one linked-list pointer (4 byte or 32 bit and 8 byte for 64 bit). So 256 buckets use 1 or 2 kB while 4096 will use 16 kB or 32 kB.
When the current limit was set 20 years ago this might have been a meaningful memory saving but today the collision probability is more important.
---
M doc/man-sections/advanced-options.rst
M doc/man-sections/server-options.rst
M src/openvpn/options.c
3 files changed, 24 insertions(+), 4 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/63/1563/5
doc/man-sections/advanced-options.rst +2 -1
@@ -36,7 +36,8 @@ hash-size r v - By default, both tables are sized at 256 buckets. + By default, both tables are sized at 4 times ``--max-clients`` buckets. + With the default of 1024 of ``--max-clients`` this gives 4096 buckets. --bcast-buffers n Allocate ``n`` buffers for broadcast datagrams (default :code:`256`).
doc/man-sections/server-options.rst +1 -1
@@ -414,7 +414,7 @@ iroute-ipv6 ipv6addr/bits --max-clients n - Limit server to a maximum of ``n`` concurrent clients. + Limit server to a maximum of ``n`` concurrent clients. Defaults to 1024. --max-routes-per-client n Allow a maximum of ``n`` internal routes per client (default
src/openvpn/options.c +21 -2
@@ -849,8 +849,6 @@#endif o->vlan_accept =VLAN_ALL ; o->vlan_pvid =1 ; - o->real_hash_size =256 ; - o->virtual_hash_size =256 ; o->n_bcast_buf =256 ; o->tcp_queue_limit =64 ; o->max_clients =1024 ;
@@ -3724,6 +3722,22 @@ gc_free(&gc); }#endif /* if defined(_WIN32) || defined(TARGET_ANDROID) */ +/** +* Sets the internal hash maps sizes according to the max_clients +* +*/ +static void +helper_hashmap_sizes (struct options *o) +{ +if (!o->real_hash_size) + { + o->real_hash_size =4 * o->max_clients; + } +if (!o->virtual_hash_size) + { + o->virtual_hash_size =4 * o->max_clients; + } +}static void options_postprocess_mutate (struct options *o,struct env_set *es)
@@ -3739,6 +3753,11 @@helper_keepalive (o);helper_tcp_nodelay (o); +if (o->mode ==MODE_SERVER ) + { +helper_hashmap_sizes (o); + } +options_postprocess_setdefault_ncpciphers (o);options_set_backwards_compatible_options (o);options_process_mutate_prf (o);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1563?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: Ia699b0dfa407ac377970bb130434298eaaec592b
Gerrit-Change-Number: 1563
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
[Openvpn-devel] [S] Change in openvpn[master]: Increase default size of internal hash maps to 4 * --max-clients
In reply to a message not in the archiveAttention is currently required from: flichtenheld.
plaisthos has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1563?usp=email )
Change subject: Increase default size of internal hash maps to 4 * --max-clients
......................................................................
Patch Set 5:
(1 comment)
File src/openvpn/options.c:
http://gerrit.openvpn.net/c/openvpn/+/1563/comment/d29fabc9_bfbab811?usp=email :
PS3, Line 853: o->virtual_hash_size = 1024;
Quoted 1 line
Do we have any justification for 1024 specifically? I.e. […]
Not. Not really. Should I maybe change the default to be 4 * max_clients?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1563?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia699b0dfa407ac377970bb130434298eaaec592b
Gerrit-Change-Number: 1563
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 12 Mar 2026 15:27:13 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
[Openvpn-devel] [S] Change in openvpn[master]: Increase default size of internal hash maps to 4 * --max-clients
In reply to a message not in the archiveAttention is currently required from: plaisthos.
flichtenheld has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1563?usp=email )
Change subject: Increase default size of internal hash maps to 4 * --max-clients
......................................................................
Patch Set 5: Code-Review+2
(1 comment)
File src/openvpn/options.c:
http://gerrit.openvpn.net/c/openvpn/+/1563/comment/7accb437_15a12c0f?usp=email :
PS3, Line 853: o->virtual_hash_size = 1024;
Quoted 1 line
Not. Not really. […]
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1563?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia699b0dfa407ac377970bb130434298eaaec592b
Gerrit-Change-Number: 1563
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Mon, 16 Mar 2026 16:03:11 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: plaisthos <[email protected]...>
Comment-In-Reply-To: flichtenheld <[email protected]...>
[Openvpn-devel] [S] Change in openvpn[master]: Increase default size of internal hash maps to 4 * --max-clients
In reply to a message not in the archiveAttention is currently required from: plaisthos.
Hello flichtenheld,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1563?usp=email
to look at the new patch set (#6).
The change is no longer submittable: checks~ChecksSubmitRule is unsatisfied now.
Change subject: Increase default size of internal hash maps to 4 * --max-clients
......................................................................
Increase default size of internal hash maps to 4 * --max-clients
The default of 256 seems quite low as with (at least) 1024 possible entries we have a guaranteed collisions. Using 4 times the number of possible entries for real addresses should reduce collisions quite a bit while also leaving some headroom for the virtual addresses hash where a client might have more than one address.
A reason to keep the limit so low are the memory requirements. Each bucket has the size of one linked-list pointer (4 byte or 32 bit and 8 byte for 64 bit). So 256 buckets use 1 or 2 kB while 4096 will use 16 kB or 32 kB.
When the current limit was set 20 years ago this might have been a meaningful memory saving but today the collision probability is more important.
---
M doc/man-sections/advanced-options.rst
M doc/man-sections/server-options.rst
M src/openvpn/options.c
3 files changed, 24 insertions(+), 4 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/63/1563/6
doc/man-sections/advanced-options.rst +2 -1
@@ -36,7 +36,8 @@ hash-size r v - By default, both tables are sized at 256 buckets. + By default, both tables are sized at 4 times ``--max-clients`` buckets. + With the default of 1024 of ``--max-clients`` this gives 4096 buckets. --bcast-buffers n Allocate ``n`` buffers for broadcast datagrams (default :code:`256`).
doc/man-sections/server-options.rst +1 -1
@@ -414,7 +414,7 @@ iroute-ipv6 ipv6addr/bits --max-clients n - Limit server to a maximum of ``n`` concurrent clients. + Limit server to a maximum of ``n`` concurrent clients. Defaults to 1024. --max-routes-per-client n Allow a maximum of ``n`` internal routes per client (default
src/openvpn/options.c +21 -2
@@ -849,8 +849,6 @@#endif o->vlan_accept =VLAN_ALL ; o->vlan_pvid =1 ; - o->real_hash_size =256 ; - o->virtual_hash_size =256 ; o->n_bcast_buf =256 ; o->tcp_queue_limit =64 ; o->max_clients =1024 ;
@@ -3724,6 +3722,22 @@ gc_free(&gc); }#endif /* if defined(_WIN32) || defined(TARGET_ANDROID) */ +/** +* Sets the internal hash maps sizes according to the max_clients +* +*/ +static void +helper_hashmap_sizes (struct options *o) +{ +if (!o->real_hash_size) + { + o->real_hash_size =4 * o->max_clients; + } +if (!o->virtual_hash_size) + { + o->virtual_hash_size =4 * o->max_clients; + } +}static void options_postprocess_mutate (struct options *o,struct env_set *es)
@@ -3739,6 +3753,11 @@helper_keepalive (o);helper_tcp_nodelay (o); +if (o->mode ==MODE_SERVER ) + { +helper_hashmap_sizes (o); + } +options_postprocess_setdefault_ncpciphers (o);options_set_backwards_compatible_options (o);options_process_mutate_prf (o);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1563?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: Ia699b0dfa407ac377970bb130434298eaaec592b
Gerrit-Change-Number: 1563
Gerrit-PatchSet: 6
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
[Openvpn-devel] [S] Change in openvpn[master]: Increase default size of internal hash maps to 4 * --max-clients
In reply to a message not in the archiveAttention is currently required from: plaisthos.
ordex has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1563?usp=email )
Change subject: Increase default size of internal hash maps to 4 * --max-clients
......................................................................
Patch Set 6: Code-Review+2
(1 comment)
Patchset:
PS6:
I'd personally just add a remark in the commit next to 1024 to make it clear that this is the default max-client value, because at first glance it wasn't obvious to me.
Other than that, the patch looks good!
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1563?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia699b0dfa407ac377970bb130434298eaaec592b
Gerrit-Change-Number: 1563
Gerrit-PatchSet: 6
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Thu, 19 Mar 2026 14:41:11 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
[Openvpn-devel] [S] Change in openvpn[master]: Increase default size of internal hash maps to 4 * --max-clients
In reply to a message not in the archiveAttention is currently required from: flichtenheld, ordex, plaisthos.
Hello flichtenheld, ordex,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1563?usp=email
to look at the new patch set (#7).
The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld, Code-Review+2 by ordex
The change is no longer submittable: Code-Review and checks~ChecksSubmitRule are unsatisfied now.
Change subject: Increase default size of internal hash maps to 4 * --max-clients
......................................................................
Increase default size of internal hash maps to 4 * --max-clients
The default of 256 seems quite low as with (at least) 1024 possible entries (the --max-clients default setting) we have a guaranteed collisions. Using 4 times the number of possible entries for real addresses should reduce collisions quite a bit while also leaving some headroom for the virtual addresses hash where a client might have more than one address.
A reason to keep the limit so low are the memory requirements. Each bucket has the size of one linked-list pointer (4 byte or 32 bit and 8 byte for 64 bit). So 256 buckets use 1 or 2 kB while 4096 will use 16 kB or 32 kB.
When the current limit was set 20 years ago this might have been a meaningful memory saving but today the collision probability is more important.
---
M doc/man-sections/advanced-options.rst
M doc/man-sections/server-options.rst
M src/openvpn/options.c
3 files changed, 24 insertions(+), 4 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/63/1563/7
doc/man-sections/advanced-options.rst +2 -1
@@ -36,7 +36,8 @@ hash-size r v - By default, both tables are sized at 256 buckets. + By default, both tables are sized at 4 times ``--max-clients`` buckets. + With the default of 1024 of ``--max-clients`` this gives 4096 buckets. --bcast-buffers n Allocate ``n`` buffers for broadcast datagrams (default :code:`256`).
doc/man-sections/server-options.rst +1 -1
@@ -414,7 +414,7 @@ iroute-ipv6 ipv6addr/bits --max-clients n - Limit server to a maximum of ``n`` concurrent clients. + Limit server to a maximum of ``n`` concurrent clients. Defaults to 1024. --max-routes-per-client n Allow a maximum of ``n`` internal routes per client (default
src/openvpn/options.c +21 -2
@@ -849,8 +849,6 @@#endif o->vlan_accept =VLAN_ALL ; o->vlan_pvid =1 ; - o->real_hash_size =256 ; - o->virtual_hash_size =256 ; o->n_bcast_buf =256 ; o->tcp_queue_limit =64 ; o->max_clients =1024 ;
@@ -3724,6 +3722,22 @@ gc_free(&gc); }#endif /* if defined(_WIN32) || defined(TARGET_ANDROID) */ +/** +* Sets the internal hash maps sizes according to the max_clients +* +*/ +static void +helper_hashmap_sizes (struct options *o) +{ +if (!o->real_hash_size) + { + o->real_hash_size =4 * o->max_clients; + } +if (!o->virtual_hash_size) + { + o->virtual_hash_size =4 * o->max_clients; + } +}static void options_postprocess_mutate (struct options *o,struct env_set *es)
@@ -3739,6 +3753,11 @@helper_keepalive (o);helper_tcp_nodelay (o); +if (o->mode ==MODE_SERVER ) + { +helper_hashmap_sizes (o); + } +options_postprocess_setdefault_ncpciphers (o);options_set_backwards_compatible_options (o);options_process_mutate_prf (o);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1563?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: Ia699b0dfa407ac377970bb130434298eaaec592b
Gerrit-Change-Number: 1563
Gerrit-PatchSet: 7
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
[Openvpn-devel] [S] Change in openvpn[master]: Increase default size of internal hash maps to 4 * --max-clients
In reply to a message not in the archiveAttention is currently required from: flichtenheld, plaisthos.
ordex has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1563?usp=email )
Change subject: Increase default size of internal hash maps to 4 * --max-clients
......................................................................
Patch Set 7: Code-Review+2
(1 comment)
Patchset:
PS7:
Thanks!
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1563?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia699b0dfa407ac377970bb130434298eaaec592b
Gerrit-Change-Number: 1563
Gerrit-PatchSet: 7
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 19 Mar 2026 14:56:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
PATCH v7 1/1 Increase default size of internal hash maps to 4 * --max-clients
In reply to a message not in the archiveFrom: Arne Schwabe <[email protected]...>
The default of 256 seems quite low as with (at least) 1024 possible entries (the --max-clients default setting) we have a guaranteed collisions. Using 4 times the number of possible entries for real addresses should reduce collisions quite a bit while also leaving some headroom for the virtual addresses hash where a client might have more than one address.
A reason to keep the limit so low are the memory requirements. Each bucket has the size of one linked-list pointer (4 byte or 32 bit and 8 byte for 64 bit). So 256 buckets use 1 or 2 kB while 4096 will use 16 kB or 32 kB.
When the current limit was set 20 years ago this might have been a meaningful memory saving but today the collision probability is more important.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1563
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1563
This mail reflects revision 7 of this Change.
Acked-by according to Gerrit (reflected above):
Antonio Quartulli <[email protected]...>
doc/man-sections/advanced-options.rst +2 -1
@@ -36,7 +36,8 @@ hash-size r v - By default, both tables are sized at 256 buckets. + By default, both tables are sized at 4 times ``--max-clients`` buckets. + With the default of 1024 of ``--max-clients`` this gives 4096 buckets. --bcast-buffers n Allocate ``n`` buffers for broadcast datagrams (default :code:`256`).
doc/man-sections/server-options.rst +1 -1
@@ -414,7 +414,7 @@ iroute-ipv6 ipv6addr/bits --max-clients n - Limit server to a maximum of ``n`` concurrent clients. + Limit server to a maximum of ``n`` concurrent clients. Defaults to 1024. --max-routes-per-client n Allow a maximum of ``n`` internal routes per client (default
src/openvpn/options.c +21 -2
@@ -849,8 +849,6 @@#endif o->vlan_accept =VLAN_ALL ; o->vlan_pvid =1 ; - o->real_hash_size =256 ; - o->virtual_hash_size =256 ; o->n_bcast_buf =256 ; o->tcp_queue_limit =64 ; o->max_clients =1024 ;
@@ -3724,6 +3722,22 @@ gc_free(&gc); }#endif /* if defined(_WIN32) || defined(TARGET_ANDROID) */ +/** +* Sets the internal hash maps sizes according to the max_clients +* +*/ +static void +helper_hashmap_sizes (struct options *o) +{ +if (!o->real_hash_size) + { + o->real_hash_size =4 * o->max_clients; + } +if (!o->virtual_hash_size) + { + o->virtual_hash_size =4 * o->max_clients; + } +}static void options_postprocess_mutate (struct options *o,struct env_set *es)
@@ -3739,6 +3753,11 @@helper_keepalive (o);helper_tcp_nodelay (o); +if (o->mode ==MODE_SERVER ) + { +helper_hashmap_sizes (o); + } +options_postprocess_setdefault_ncpciphers (o);options_set_backwards_compatible_options (o);options_process_mutate_prf (o);
[Openvpn-devel] [PATCH applied] Re: Increase default size of internal hash maps to 4 * --max-clients
Stared at the code for a bit, and spent some thoughts on it. Makes sense.
I haven't actually tested this beyond "BB is green". The server testbed will give it a bit of testing, but this is not really meaningful either (because I have 3 clients connected at maximum)...
If the environment is very tight on memory, reducing --max-clients is way more effective (and shrinks the hash map accordingly).
Your patch has been applied to the master and release/2.7 branch (scalability, low impact).
commit 7b5ebf7c447db16953c9541fdd00c7aa56124fc5 (master) commit 216c76324d2ee9221346cdfb25891e634aff2b9e (release/2.7)
Author: Arne Schwabe Date: Wed Mar 25 13:45:26 2026 +0100
Increase default size of internal hash maps to 4 * --max-clients
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Antonio Quartulli <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1563
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36268.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
[Openvpn-devel] [S] Change in openvpn[master]: Increase default size of internal hash maps to 4 * --max-clients
In reply to a message not in the archivecron2 has uploaded a new patch set (#8) to the change originally created by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1563?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by ordex
Change subject: Increase default size of internal hash maps to 4 * --max-clients
......................................................................
Increase default size of internal hash maps to 4 * --max-clients
The default of 256 seems quite low as with (at least) 1024 possible entries (the --max-clients default setting) we have a guaranteed collisions. Using 4 times the number of possible entries for real addresses should reduce collisions quite a bit while also leaving some headroom for the virtual addresses hash where a client might have more than one address.
A reason to keep the limit so low are the memory requirements. Each bucket has the size of one linked-list pointer (4 byte or 32 bit and 8 byte for 64 bit). So 256 buckets use 1 or 2 kB while 4096 will use 16 kB or 32 kB.
When the current limit was set 20 years ago this might have been a meaningful memory saving but today the collision probability is more important.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1563
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36268.html
---
M doc/man-sections/advanced-options.rst
M doc/man-sections/server-options.rst
M src/openvpn/options.c
3 files changed, 24 insertions(+), 4 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/63/1563/8
doc/man-sections/advanced-options.rst +2 -1
@@ -36,7 +36,8 @@ hash-size r v - By default, both tables are sized at 256 buckets. + By default, both tables are sized at 4 times ``--max-clients`` buckets. + With the default of 1024 of ``--max-clients`` this gives 4096 buckets. --bcast-buffers n Allocate ``n`` buffers for broadcast datagrams (default :code:`256`).
doc/man-sections/server-options.rst +1 -1
@@ -414,7 +414,7 @@ iroute-ipv6 ipv6addr/bits --max-clients n - Limit server to a maximum of ``n`` concurrent clients. + Limit server to a maximum of ``n`` concurrent clients. Defaults to 1024. --max-routes-per-client n Allow a maximum of ``n`` internal routes per client (default
src/openvpn/options.c +21 -2
@@ -849,8 +849,6 @@#endif o->vlan_accept =VLAN_ALL ; o->vlan_pvid =1 ; - o->real_hash_size =256 ; - o->virtual_hash_size =256 ; o->n_bcast_buf =256 ; o->tcp_queue_limit =64 ; o->max_clients =1024 ;
@@ -3724,6 +3722,22 @@ gc_free(&gc); }#endif /* if defined(_WIN32) || defined(TARGET_ANDROID) */ +/** +* Sets the internal hash maps sizes according to the max_clients +* +*/ +static void +helper_hashmap_sizes (struct options *o) +{ +if (!o->real_hash_size) + { + o->real_hash_size =4 * o->max_clients; + } +if (!o->virtual_hash_size) + { + o->virtual_hash_size =4 * o->max_clients; + } +}static void options_postprocess_mutate (struct options *o,struct env_set *es)
@@ -3739,6 +3753,11 @@helper_keepalive (o);helper_tcp_nodelay (o); +if (o->mode ==MODE_SERVER ) + { +helper_hashmap_sizes (o); + } +options_postprocess_setdefault_ncpciphers (o);options_set_backwards_compatible_options (o);options_process_mutate_prf (o);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1563?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: Ia699b0dfa407ac377970bb130434298eaaec592b
Gerrit-Change-Number: 1563
Gerrit-PatchSet: 8
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
[Openvpn-devel] [S] Change in openvpn[master]: Increase default size of internal hash maps to 4 * --max-clients
In reply to a message not in the archivecron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1563?usp=email )
Change subject: Increase default size of internal hash maps to 4 * --max-clients
......................................................................
Increase default size of internal hash maps to 4 * --max-clients
The default of 256 seems quite low as with (at least) 1024 possible entries (the --max-clients default setting) we have a guaranteed collisions. Using 4 times the number of possible entries for real addresses should reduce collisions quite a bit while also leaving some headroom for the virtual addresses hash where a client might have more than one address.
A reason to keep the limit so low are the memory requirements. Each bucket has the size of one linked-list pointer (4 byte or 32 bit and 8 byte for 64 bit). So 256 buckets use 1 or 2 kB while 4096 will use 16 kB or 32 kB.
When the current limit was set 20 years ago this might have been a meaningful memory saving but today the collision probability is more important.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1563
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36268.html
---
M doc/man-sections/advanced-options.rst
M doc/man-sections/server-options.rst
M src/openvpn/options.c
3 files changed, 24 insertions(+), 4 deletions(-)
doc/man-sections/advanced-options.rst +2 -1
@@ -36,7 +36,8 @@ hash-size r v - By default, both tables are sized at 256 buckets. + By default, both tables are sized at 4 times ``--max-clients`` buckets. + With the default of 1024 of ``--max-clients`` this gives 4096 buckets. --bcast-buffers n Allocate ``n`` buffers for broadcast datagrams (default :code:`256`).
doc/man-sections/server-options.rst +1 -1
@@ -414,7 +414,7 @@ iroute-ipv6 ipv6addr/bits --max-clients n - Limit server to a maximum of ``n`` concurrent clients. + Limit server to a maximum of ``n`` concurrent clients. Defaults to 1024. --max-routes-per-client n Allow a maximum of ``n`` internal routes per client (default
src/openvpn/options.c +21 -2
@@ -849,8 +849,6 @@#endif o->vlan_accept =VLAN_ALL ; o->vlan_pvid =1 ; - o->real_hash_size =256 ; - o->virtual_hash_size =256 ; o->n_bcast_buf =256 ; o->tcp_queue_limit =64 ; o->max_clients =1024 ;
@@ -3724,6 +3722,22 @@ gc_free(&gc); }#endif /* if defined(_WIN32) || defined(TARGET_ANDROID) */ +/** +* Sets the internal hash maps sizes according to the max_clients +* +*/ +static void +helper_hashmap_sizes (struct options *o) +{ +if (!o->real_hash_size) + { + o->real_hash_size =4 * o->max_clients; + } +if (!o->virtual_hash_size) + { + o->virtual_hash_size =4 * o->max_clients; + } +}static void options_postprocess_mutate (struct options *o,struct env_set *es)
@@ -3739,6 +3753,11 @@helper_keepalive (o);helper_tcp_nodelay (o); +if (o->mode ==MODE_SERVER ) + { +helper_hashmap_sizes (o); + } +options_postprocess_setdefault_ncpciphers (o);options_set_backwards_compatible_options (o);options_process_mutate_prf (o);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1563?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia699b0dfa407ac377970bb130434298eaaec592b
Gerrit-Change-Number: 1563
Gerrit-PatchSet: 8
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>