From a92e14001b107401b81ee4e5230d37715ea51044 Mon Sep 17 00:00:00 2001 From: Nataliia Solomko Date: Wed, 13 Aug 2025 18:30:27 +0300 Subject: T7716: VPP: Change defaults and add a warning about maximum routes count for current configuration --- interface-definitions/vpp.xml.in | 3 ++ .../config_resource_checks/resource_defaults.py | 2 +- python/vyos/vpp/config_verify.py | 34 +++++++++++++++++++--- src/conf_mode/vpp.py | 3 ++ 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/interface-definitions/vpp.xml.in b/interface-definitions/vpp.xml.in index dff56a228..2443cebc3 100644 --- a/interface-definitions/vpp.xml.in +++ b/interface-definitions/vpp.xml.in @@ -778,6 +778,7 @@ Main heap page size #include + 2M @@ -905,12 +906,14 @@ Size of stats segment #include + 128M Stats page size #include + 2M diff --git a/python/vyos/vpp/config_resource_checks/resource_defaults.py b/python/vyos/vpp/config_resource_checks/resource_defaults.py index 797b45701..d8316fcaf 100644 --- a/python/vyos/vpp/config_resource_checks/resource_defaults.py +++ b/python/vyos/vpp/config_resource_checks/resource_defaults.py @@ -31,7 +31,7 @@ default_resource_map = { # Default size of buffers transferred via netlink 'netlink_rx_buffer_size': 212992, # Default amount of memory allocated for VPP stats segment usage - 'statseg_heap_size': '96M', + 'statseg_heap_size': '128M', # Minimal amount of memory required to start VPP 'min_memory': '8G', # Minimal number of physical CPU cores required to start VPP diff --git a/python/vyos/vpp/config_verify.py b/python/vyos/vpp/config_verify.py index 1beb3141b..8902cdccb 100644 --- a/python/vyos/vpp/config_verify.py +++ b/python/vyos/vpp/config_verify.py @@ -216,8 +216,8 @@ def verify_vpp_memory(config: dict): main_heap_size = mem_checks.memory_main_heap(config['settings']) main_heap_page_size = mem_checks.main_heap_page_size(config['settings']) - if main_heap_size < 51 << 20: - raise ConfigError('The main heap size must be greater than or equal to 51M') + if main_heap_size < 1 << 30: + raise ConfigError('The main heap size must be greater than or equal to 1G') readable_heap_page = bytes_to_human_memory(main_heap_page_size, 'K') @@ -368,8 +368,8 @@ def verify_vpp_statseg_size(settings: dict): statseg_size = mem_checks.statseg_size(settings) if 'size' in settings.get('statseg'): - if statseg_size < 1 << 20: - raise ConfigError('The statseg size must be greater than or equal to 1M') + if statseg_size < 128 << 20: + raise ConfigError('The statseg size must be greater than or equal to 128M') if 'page_size' in settings['statseg']: statseg_page_size = mem_checks.statseg_page_size(settings) @@ -405,3 +405,29 @@ def verify_vpp_host_resources(config: dict): 'or VPP could work not properly. Please set up ' f'"vpp settings host-resources max-map-count" to {2 * hugepages} or higher' ) + + +def verify_routes_count(settings: dict, workers: int): + """ + Maximum routes count depending on main heap size, + statistics segment size and workers + """ + counters = 2 # 2 counters for each route + bytes = 16 # each counter consumes 16 bytes + statseg_scale = 2 + statseg_size = settings['statseg']['size'] + statseg_size_in_bytes = human_memory_to_bytes(statseg_size) + main_heap = settings['memory']['main_heap_size'] + main_heap_in_gb = human_memory_to_bytes(main_heap) >> 30 + + formula = (workers + 1) * counters * bytes * statseg_scale + routes_count_statseg = statseg_size_in_bytes / formula + routes_count_statseg = round(routes_count_statseg / 1_000_000, 2) + routes_count_mh = main_heap_in_gb * 2 + routes_count_min = min(routes_count_statseg, routes_count_mh) + Warning( + f'NOTE: Current dataplane capacity (estimated): {routes_count_min} M IPv4 routes. ' + 'Exceeding these values will lead to a dataplane out-of-memory condition and a crash. ' + 'Extensive use of features like ACLs, NAT and others may reduce the numbers above. ' + 'Please read the documentation for details: https://docs.vyos.io/' + ) diff --git a/src/conf_mode/vpp.py b/src/conf_mode/vpp.py index 6e02f9593..90e71e522 100755 --- a/src/conf_mode/vpp.py +++ b/src/conf_mode/vpp.py @@ -54,6 +54,7 @@ from vyos.vpp.config_verify import ( verify_vpp_statseg_size, verify_vpp_interfaces_dpdk_num_queues, verify_vpp_host_resources, + verify_routes_count, ) from vyos.vpp.config_filter import iface_filter_eth from vyos.vpp.utils import EthtoolGDrvinfo @@ -465,6 +466,8 @@ def verify(config): f'Interface {iface_config["iface_name"]} is an xconnect member and cannot be removed' ) + verify_routes_count(config['settings'], workers) + def generate(config): if not config or ('removed_ifaces' in config and 'settings' not in config): -- cgit v1.2.3