Skip to content

Commit 896e167

Browse files
authored
Merge pull request #4658 from natali-rs1985/T7716
T7716: VPP: Change defaults and add a warning about maximum routes count for current configuration
2 parents 4c8f5f0 + a92e140 commit 896e167

File tree

4 files changed

+37
-5
lines changed

4 files changed

+37
-5
lines changed

interface-definitions/vpp.xml.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,7 @@
778778
<help>Main heap page size</help>
779779
#include <include/unformat_log2_page_size.xml.i>
780780
</properties>
781+
<defaultValue>2M</defaultValue>
781782
</leafNode>
782783
<leafNode name="default-hugepage-size">
783784
<properties>
@@ -905,12 +906,14 @@
905906
<help>Size of stats segment</help>
906907
#include <include/unformat_memory_size.xml.i>
907908
</properties>
909+
<defaultValue>128M</defaultValue>
908910
</leafNode>
909911
<leafNode name="page-size">
910912
<properties>
911913
<help>Stats page size</help>
912914
#include <include/unformat_log2_page_size.xml.i>
913915
</properties>
916+
<defaultValue>2M</defaultValue>
914917
</leafNode>
915918
</children>
916919
</node>

python/vyos/vpp/config_resource_checks/resource_defaults.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
# Default size of buffers transferred via netlink
3232
'netlink_rx_buffer_size': 212992,
3333
# Default amount of memory allocated for VPP stats segment usage
34-
'statseg_heap_size': '96M',
34+
'statseg_heap_size': '128M',
3535
# Minimal amount of memory required to start VPP
3636
'min_memory': '8G',
3737
# Minimal number of physical CPU cores required to start VPP

python/vyos/vpp/config_verify.py

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ def verify_vpp_memory(config: dict):
216216
main_heap_size = mem_checks.memory_main_heap(config['settings'])
217217
main_heap_page_size = mem_checks.main_heap_page_size(config['settings'])
218218

219-
if main_heap_size < 51 << 20:
220-
raise ConfigError('The main heap size must be greater than or equal to 51M')
219+
if main_heap_size < 1 << 30:
220+
raise ConfigError('The main heap size must be greater than or equal to 1G')
221221

222222
readable_heap_page = bytes_to_human_memory(main_heap_page_size, 'K')
223223

@@ -368,8 +368,8 @@ def verify_vpp_statseg_size(settings: dict):
368368
statseg_size = mem_checks.statseg_size(settings)
369369

370370
if 'size' in settings.get('statseg'):
371-
if statseg_size < 1 << 20:
372-
raise ConfigError('The statseg size must be greater than or equal to 1M')
371+
if statseg_size < 128 << 20:
372+
raise ConfigError('The statseg size must be greater than or equal to 128M')
373373

374374
if 'page_size' in settings['statseg']:
375375
statseg_page_size = mem_checks.statseg_page_size(settings)
@@ -405,3 +405,29 @@ def verify_vpp_host_resources(config: dict):
405405
'or VPP could work not properly. Please set up '
406406
f'"vpp settings host-resources max-map-count" to {2 * hugepages} or higher'
407407
)
408+
409+
410+
def verify_routes_count(settings: dict, workers: int):
411+
"""
412+
Maximum routes count depending on main heap size,
413+
statistics segment size and workers
414+
"""
415+
counters = 2 # 2 counters for each route
416+
bytes = 16 # each counter consumes 16 bytes
417+
statseg_scale = 2
418+
statseg_size = settings['statseg']['size']
419+
statseg_size_in_bytes = human_memory_to_bytes(statseg_size)
420+
main_heap = settings['memory']['main_heap_size']
421+
main_heap_in_gb = human_memory_to_bytes(main_heap) >> 30
422+
423+
formula = (workers + 1) * counters * bytes * statseg_scale
424+
routes_count_statseg = statseg_size_in_bytes / formula
425+
routes_count_statseg = round(routes_count_statseg / 1_000_000, 2)
426+
routes_count_mh = main_heap_in_gb * 2
427+
routes_count_min = min(routes_count_statseg, routes_count_mh)
428+
Warning(
429+
f'NOTE: Current dataplane capacity (estimated): {routes_count_min} M IPv4 routes. '
430+
'Exceeding these values will lead to a dataplane out-of-memory condition and a crash. '
431+
'Extensive use of features like ACLs, NAT and others may reduce the numbers above. '
432+
'Please read the documentation for details: https://docs.vyos.io/'
433+
)

src/conf_mode/vpp.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
verify_vpp_statseg_size,
5555
verify_vpp_interfaces_dpdk_num_queues,
5656
verify_vpp_host_resources,
57+
verify_routes_count,
5758
)
5859
from vyos.vpp.config_filter import iface_filter_eth
5960
from vyos.vpp.utils import EthtoolGDrvinfo
@@ -465,6 +466,8 @@ def verify(config):
465466
f'Interface {iface_config["iface_name"]} is an xconnect member and cannot be removed'
466467
)
467468

469+
verify_routes_count(config['settings'], workers)
470+
468471

469472
def generate(config):
470473
if not config or ('removed_ifaces' in config and 'settings' not in config):

0 commit comments

Comments
 (0)